:root {
  --bg: #11112c;
  --surface: #fff8d7;
  --panel: #ffffff;
  --ink: #17142f;
  --muted: #575077;
  --line: rgba(23, 20, 47, 0.24);
  --line-strong: rgba(23, 20, 47, 0.42);
  --accent: #00a9a5;
  --accent-2: #ff3f9b;
  --accent-3: #ffd12e;
  --accent-soft: rgba(0, 169, 165, 0.18);
  --danger: #d01f5a;
  --shadow: 8px 8px 0 rgba(23, 20, 47, 0.72);
  --soft-shadow: 0 18px 40px rgba(8, 7, 26, 0.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18px 18px, rgba(255, 209, 46, 0.34) 0 5px, transparent 6px),
    linear-gradient(135deg, rgba(255, 63, 155, 0.28) 0 10px, transparent 10px 20px),
    linear-gradient(45deg, rgba(0, 169, 165, 0.24) 0 12px, transparent 12px 24px),
    var(--bg);
  background-size: 72px 72px, 40px 40px, 40px 40px;
  color: var(--ink);
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 48%, rgba(255, 255, 255, 0.15) 48% 52%, transparent 52%),
    linear-gradient(0deg, transparent 0 48%, rgba(255, 255, 255, 0.12) 48% 52%, transparent 52%);
  background-size: 96px 96px;
  mix-blend-mode: screen;
  opacity: 0.34;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #2ee6df, var(--accent));
  color: white;
  cursor: pointer;
  font-weight: 760;
  box-shadow: 3px 3px 0 var(--ink);
  text-shadow: 1px 1px 0 rgba(23, 20, 47, 0.45);
}

button:hover {
  filter: brightness(1.05) saturate(1.05);
  transform: translate(-1px, -1px);
}

button:disabled:hover {
  filter: none;
  transform: none;
}

button:active {
  box-shadow: 1px 1px 0 var(--ink);
  transform: translate(1px, 1px);
}

button:disabled {
  cursor: not-allowed;
  filter: none;
  opacity: 0.48;
}

button.secondary,
.icon-button.secondary {
  background: linear-gradient(180deg, #ffffff, var(--surface));
  color: var(--ink);
  border-color: var(--ink);
  text-shadow: none;
}

button.danger,
.icon-button.danger {
  background: linear-gradient(180deg, #fff, #ffe1ea);
  color: var(--danger);
  border-color: var(--ink);
  text-shadow: none;
}

button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

input,
select,
textarea {
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 11px;
  box-shadow: inset 2px 2px 0 rgba(23, 20, 47, 0.12);
}

textarea { resize: vertical; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(255, 209, 46, 0.75);
  outline-offset: 2px;
}

.app-shell {
  width: calc(100% - 32px);
  max-width: 1180px;
  margin: 18px auto 82px;
  display: grid;
  gap: 12px;
}

.auth-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-container input {
  min-width: 180px;
}

.auth-container .field {
  font-size: 0.75rem;
}

.auth-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--muted);
}

.topbar,
.workspace-toolbar,
.panel-heading,
.top-actions,
.toolbar-actions,
.meta-grid {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar,
.workspace-toolbar,
.panel-heading {
  justify-content: space-between;
}

.workspace-toolbar {
  margin-bottom: 12px;
}

.topbar {
  position: relative;
  padding: 16px;
  align-items: flex-start;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(255, 63, 155, 0.96), rgba(255, 209, 46, 0.92) 48%, rgba(0, 169, 165, 0.96)),
    var(--accent-2);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar > div:first-child {
  min-width: 0;
}

.topbar::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -18px;
  width: 180px;
  height: 72px;
  border: 3px solid rgba(23, 20, 47, 0.45);
  border-radius: 50%;
  transform: rotate(-12deg);
  opacity: 0.5;
  pointer-events: none;
}

.toolbar-actions {
  justify-content: flex-end;
}

.top-actions {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 { font-size: 2.35rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

.topbar .eyebrow {
  position: relative;
  z-index: 1;
  color: var(--ink);
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.45);
}

.topbar h1 {
  position: relative;
  z-index: 1;
  display: inline-block;
  color: #ffffff;
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  transform: skew(-8deg);
  text-shadow:
    3px 3px 0 var(--ink),
    6px 6px 0 var(--accent-2),
    9px 9px 0 var(--accent);
}

.layout {
  display: block;
  width: 100%;
}

.sidebar {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.workspace {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.mobile-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 auto 18px;
  padding: 8px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 248, 215, 0.95);
  box-shadow: 5px 5px 0 rgba(23, 20, 47, 0.72);
  backdrop-filter: blur(12px);
  width: 100%;
  max-width: 1180px;
}

.mobile-tab {
  min-height: 48px;
  padding: 9px 8px;
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  font-size: 0.86rem;
  flex-direction: row;
  text-shadow: none;
  box-shadow: none;
}

.mobile-tab svg {
  width: 18px;
  height: 18px;
}

.mobile-tab.active {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: white;
}

.mobile-page {
  display: none;
}

.mobile-page.active-mobile-page {
  display: block;
}

.config-panel.active-mobile-page,
.workout-view.active-mobile-page {
  display: grid;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 248, 215, 0.95));
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-heading {
  border-bottom: 2px dotted rgba(23, 20, 47, 0.28);
  padding-bottom: 10px;
}

.panel-heading h2,
.workspace-toolbar h2 {
  color: var(--ink);
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  font-weight: 900;
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 790;
}

.field span,
.check-field span {
  letter-spacing: 0.02em;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  color: var(--ink);
  font-weight: 820;
}

.check-field input {
  width: 18px;
  height: 18px;
}

.full { width: 100%; }

.icon-button,
.file-label {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-label input {
  display: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--accent-3);
  color: var(--ink);
  padding: 4px 9px;
  font-size: 0.76rem;
  font-weight: 850;
}

.summary-box {
  margin: 12px 0;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(0, 169, 165, 0.12) 50%, transparent 50%),
    var(--surface);
  background-size: 16px 16px;
  padding: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.summary-box strong {
  color: var(--ink);
}

.helper-text {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.config-panel {
  display: grid;
  gap: 14px;
}

.config-section {
  display: grid;
  gap: 10px;
  border-top: 2px dotted rgba(23, 20, 47, 0.28);
  padding-top: 14px;
}

.config-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.lift-grid,
.accessory-grid,
.builder-grid {
  display: grid;
  gap: 10px;
}

.lift-row,
.accessory-row,
.builder-day {
  display: grid;
  gap: 8px;
  align-items: end;
}

.accessory-row {
  grid-template-columns: minmax(0, 1.4fr) minmax(76px, 0.55fr) minmax(86px, 0.65fr) 42px;
}

.accessory-delete-button {
  align-self: end;
}

.workout-nav {
  display: grid;
  gap: 8px;
  max-height: none;
  overflow: auto;
}

.workout-button {
  width: 100%;
  justify-content: space-between;
  border-color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 63, 155, 0.12), rgba(0, 169, 165, 0.12)),
    var(--surface);
  color: var(--ink);
  text-align: left;
}

.workout-button.active {
  border-color: var(--ink);
  background: linear-gradient(135deg, var(--accent-3), #fff3a4);
  box-shadow: 4px 4px 0 var(--accent-2);
}

.workout-button.complete {
  background:
    linear-gradient(135deg, rgba(0, 169, 165, 0.28), rgba(255, 255, 255, 0.8)),
    var(--surface);
}

.workout-button small {
  min-width: 28px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 760;
  text-align: center;
}

.meta-grid {
  justify-content: flex-start;
  margin-bottom: 12px;
}

.meta-grid .field {
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 4px 4px 0 rgba(23, 20, 47, 0.18);
}

.workout-table {
  width: 100%;
  border-collapse: collapse;
}

.workout-table th,
.workout-table td {
  border-bottom: 1px solid rgba(23, 20, 47, 0.2);
  padding: 8px;
  text-align: left;
  vertical-align: middle;
}

.workout-table th {
  background: var(--ink);
  color: var(--accent-3);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.workout-table tr:last-child td {
  border-bottom: 0;
}

.done-col {
  width: 52px;
  text-align: center;
}

.done-col input {
  width: 18px;
  height: 18px;
}

.table-input {
  min-width: 0;
  padding: 8px;
}

.section-input { min-width: 110px; }
.narrow-input { min-width: 72px; }
.notes-input { min-width: 170px; }

.notes-field {
  margin-top: 12px;
}

.recap-panel {
  display: grid;
  gap: 12px;
}

.recap-card {
  display: grid;
  gap: 8px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 209, 46, 0.2), rgba(0, 169, 165, 0.14)),
    var(--surface);
  padding: 14px;
}

.recap-row {
  display: grid;
  gap: 4px;
  border-bottom: 2px dotted rgba(23, 20, 47, 0.22);
  padding-bottom: 8px;
}

.recap-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.recap-row span {
  color: var(--muted);
  font-weight: 780;
  text-align: left;
}

.recap-text {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.empty-state {
  color: var(--muted);
  line-height: 1.45;
}

body .mobile-page:not(.active-mobile-page) {
  display: none;
}

body .mobile-page.active-mobile-page {
  display: block;
}

body .config-panel.active-mobile-page,
body .workout-view.active-mobile-page,
body .recap-panel.active-mobile-page {
  display: grid;
}

@media (max-width: 1319px) {
  button {
    min-height: 44px;
  }

  .top-actions {
    margin-left: 0;
  }

  .workspace-toolbar {
    align-items: flex-start;
  }

  .toolbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: center;
  }

  .toolbar-actions .secondary:not(.icon-button) {
    min-width: 0;
  }

  .toolbar-actions .icon-button {
    width: 100%;
  }

  .table-wrap {
    border: 0;
    overflow: visible;
  }

  .workout-table,
  .workout-table tbody,
  .workout-table tr,
  .workout-table td {
    display: block;
    width: 100%;
  }

  .workout-table thead {
    display: none;
  }

  .workout-table tbody {
    display: grid;
    gap: 10px;
  }

  .workout-table tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 10px;
  }

  .workout-table td {
    border-bottom: 0;
    padding: 6px 0;
  }

  .workout-table td:not(.empty-state)::before {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .workout-table td:nth-child(1)::before { content: "Done"; }
  .workout-table td:nth-child(2)::before { content: "Section"; }
  .workout-table td:nth-child(3)::before { content: "Exercise"; }
  .workout-table td:nth-child(4)::before { content: "Sets"; }
  .workout-table td:nth-child(5)::before { content: "Reps"; }
  .workout-table td:nth-child(6)::before { content: "Intensity"; }
  .workout-table td:nth-child(7)::before { content: "Weight"; }
  .workout-table td:nth-child(8)::before { content: "Notes"; }

  .workout-table td.done-col:last-child {
    display: flex;
    justify-content: flex-end;
  }

  .workout-table td.done-col:last-child::before {
    content: "";
    display: none;
  }

  .done-col {
    width: 100%;
    text-align: left;
  }

  .table-input,
  .section-input,
  .narrow-input,
  .notes-input {
    min-width: 0;
    width: 100%;
  }

  .workout-table td.empty-state,
  .workout-table td[colspan] {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px;
  }
}

@media (min-width: 1320px) {
  .lift-row {
    grid-template-columns: minmax(110px, 1fr) repeat(2, minmax(76px, 0.65fr));
  }

  .accessory-row {
    grid-template-columns: minmax(120px, 1.3fr) 70px 80px 42px;
  }

  .builder-day {
    grid-template-columns: minmax(100px, 0.9fr) minmax(130px, 1.1fr) minmax(110px, 0.9fr) minmax(150px, 1.2fr);
  }

  .meta-grid .field {
    width: 100%;
    max-width: 220px;
  }

  .recap-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
  }

  .recap-row span {
    text-align: right;
  }
}

@media (min-width: 1320px) {
  .app-shell {
    width: calc(100% - 48px);
    max-width: 1180px;
    margin: 22px auto 48px;
  }

  .topbar {
    padding: 16px;
    align-items: center;
  }

  h1 { font-size: clamp(2rem, 4vw, 3.15rem); }

  .mobile-tabs {
    display: none;
  }

  body .mobile-page,
  body .mobile-page.active-mobile-page {
    display: block;
  }

  body .config-panel,
  body .config-panel.active-mobile-page,
  body .workout-view,
  body .workout-view.active-mobile-page,
  body .recap-panel,
  body .recap-panel.active-mobile-page {
    display: grid;
  }

  .layout {
    display: grid;
    grid-template-columns: minmax(310px, 380px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }

  .workout-nav {
    max-height: 420px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: calc(100% - 24px);
    max-width: 430px;
  }

  h1 { font-size: 2rem; }

  .eyebrow {
    font-size: 0.7rem;
  }

  .topbar {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
  }

  .topbar > div:first-child {
    width: 100%;
    min-width: 0;
  }

  .topbar h1 {
    transform: skew(-5deg);
  }

  .top-actions {
    justify-content: center;
    gap: 7px;
    margin: 4px auto 0;
  }

  .workspace-toolbar {
    justify-content: center;
    text-align: center;
  }

  .workspace-toolbar > div:first-child {
    width: 100%;
  }

  .toolbar-actions {
    justify-content: center;
  }

  .panel {
    padding: 13px;
  }
}

/* Iron Prayers-style navigation: one centered active view at every size. */
.app-shell {
  width: calc(100% - 32px);
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}

.layout {
  display: block;
  width: 100%;
}

.mobile-tabs {
  display: grid;
}

.sidebar,
.workspace {
  margin-left: auto;
  margin-right: auto;
}

.sidebar {
  max-width: 720px;
}

.workspace {
  max-width: 1180px;
}

body .mobile-page,
body .mobile-page:not(.active-mobile-page) {
  display: none;
}

body .mobile-page.active-mobile-page {
  display: block;
}

body .config-panel.active-mobile-page,
body .workout-view.active-mobile-page,
body .recap-panel.active-mobile-page {
  display: grid;
}

@media (max-width: 620px) {
  .app-shell {
    width: calc(100% - 24px);
    max-width: 430px;
  }

  .mobile-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 12px;
    padding: 7px;
  }

  .mobile-tab {
    min-height: 48px;
    padding: 7px 5px;
    flex-direction: column;
    gap: 3px;
    font-size: 0.72rem;
  }
}
