:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f3f6fa;
  --surface-blue: #eef5ff;
  --text: #151922;
  --muted: #4b5565;
  --soft: #8791a1;
  --line: #e3e7ee;
  --line-strong: #d3dae5;
  --blue: #2563eb;
  --blue-strong: #174cc2;
  --green: #0c9f78;
  --yellow: #b9872d;
  --red: #db3b45;
  --purple: #6f5bd6;
  --gold: #b88a44;
  --gold-soft: #fff7e8;
  --ink: #151922;
  --shadow: 0 12px 34px rgba(22, 28, 40, 0.07);
  --shadow-strong: 0 22px 58px rgba(22, 28, 40, 0.12);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111318;
  --surface: #181b21;
  --surface-soft: #20242c;
  --surface-blue: #162235;
  --gold-soft: rgba(184, 138, 68, 0.14);
  --text: #f7f9fc;
  --muted: #c3cad4;
  --soft: #8f98a8;
  --line: #2a2f38;
  --line-strong: #3a414c;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  --shadow-strong: 0 18px 42px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

section[id],
article[id],
aside[id] {
  scroll-margin-top: 92px;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 38%, #eef3f8 100%);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

:root[data-theme="dark"] body {
  background: linear-gradient(180deg, #0f1218 0%, var(--bg) 60%, #151922 100%);
}

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

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 40px;
  border-bottom: 1px solid rgba(229, 232, 235, 0.78);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 68% 28%, #ffffff 0 5px, transparent 6px),
    linear-gradient(135deg, var(--ink), var(--gold));
  box-shadow: 0 10px 24px rgba(184, 138, 68, 0.18);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.98rem;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: var(--soft);
  font-size: 0.74rem;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 4px;
}

.nav-links a {
  min-height: 36px;
  border-radius: 999px;
  color: var(--muted);
  padding: 0 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.nav-links a:hover {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 5px 14px rgba(33, 37, 41, 0.06);
}

.ghost-button,
.secondary-button,
.primary-button,
.danger-button {
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 800;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.ghost-button,
.secondary-button {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--text);
}

.ghost-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.primary-button {
  background: linear-gradient(135deg, #151922, #303746);
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(21, 25, 34, 0.22);
}

.primary-button:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #0d1118, #2b3342);
  box-shadow: 0 18px 34px rgba(21, 25, 34, 0.28);
}

.danger-button {
  background: #fff1f2;
  border-color: #ffd5d8;
  color: var(--red);
}

:root[data-theme="dark"] .danger-button {
  background: rgba(229, 72, 77, 0.14);
  border-color: rgba(229, 72, 77, 0.28);
}

.ghost-button {
  width: 44px;
  padding: 0;
}

.icon-moon {
  width: 16px;
  height: 16px;
  border: 2px solid var(--blue);
  border-radius: 999px;
  box-shadow: inset -5px -2px 0 var(--blue);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 80px;
}

.briefing-strip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(246, 249, 253, 0.96)),
    linear-gradient(90deg, rgba(184, 138, 68, 0.18), rgba(37, 99, 235, 0.12));
  box-shadow: var(--shadow);
  padding: 14px 16px;
  overflow: hidden;
}

:root[data-theme="dark"] .briefing-strip {
  background:
    linear-gradient(135deg, rgba(24, 27, 33, 0.96), rgba(32, 36, 44, 0.96)),
    linear-gradient(90deg, rgba(184, 138, 68, 0.16), rgba(37, 99, 235, 0.1));
}

.briefing-strip::before {
  content: "";
  width: 4px;
  align-self: stretch;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold), var(--blue));
}

.briefing-strip > div {
  display: grid;
  gap: 3px;
  flex: 1;
}

.briefing-kicker {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.briefing-strip strong {
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.35;
}

.briefing-strip small {
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.briefing-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 900;
}

.command-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 16px;
  align-items: stretch;
}

.command-copy,
.scanner-panel,
.panel,
.kpi-card,
.ritual-card,
.coach-card,
.storage-strip article,
.chart-card,
.muscle-map,
.insight-board,
.record-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.command-copy {
  padding: 42px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.94)),
    linear-gradient(180deg, rgba(184, 138, 68, 0.12), transparent 55%);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 680px;
  margin-bottom: 16px;
  font-size: 2.92rem;
  line-height: 1.1;
  letter-spacing: 0;
  word-break: keep-all;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.72;
  word-break: keep-all;
}

.panel-copy {
  margin: 8px 0 0;
  color: var(--soft);
  font-size: 0.92rem;
  line-height: 1.55;
  word-break: keep-all;
}

.hero-actions,
.data-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.scanner-panel {
  padding: 28px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(21, 25, 34, 0.04), rgba(184, 138, 68, 0.1)),
    var(--surface);
}

.phone-preview {
  width: min(100%, 360px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(180deg, var(--surface), var(--surface-soft));
  box-shadow: var(--shadow-strong);
  padding: 20px;
}

.phone-header,
.phone-list p,
.chart-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.phone-header {
  margin-bottom: 18px;
  color: var(--soft);
  font-size: 0.86rem;
}

.phone-header strong {
  color: var(--gold);
}

.phone-stat {
  border-radius: var(--radius);
  background: var(--surface-blue);
  padding: 18px;
}

.phone-stat span,
.phone-list span,
.kpi-card span,
.metric-box span {
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.phone-stat strong {
  display: block;
  margin-top: 7px;
  font-size: 2rem;
  color: var(--text);
}

.phone-progress {
  height: 10px;
  margin: 18px 0;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}

.phone-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ink), var(--gold));
}

.phone-list {
  display: grid;
  gap: 8px;
}

.phone-list p {
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.phone-list p:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.storage-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.storage-strip article {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.storage-strip strong,
.storage-strip small {
  display: block;
}

.storage-strip strong {
  font-size: 0.95rem;
}

.storage-strip small {
  margin-top: 4px;
  color: var(--soft);
  font-size: 0.82rem;
  line-height: 1.4;
}

.strip-icon {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--gold-soft);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.kpi-card {
  min-height: 124px;
  padding: 18px;
}

.kpi-card strong {
  display: block;
  margin: 12px 0 7px;
  color: var(--text);
  font-size: 2rem;
  line-height: 1.05;
}

.kpi-card small {
  color: var(--muted);
  line-height: 1.42;
}

.ritual-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr 1.1fr 0.8fr;
  gap: 12px;
  margin: 14px 0;
}

.ritual-card {
  min-height: 126px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
}

:root[data-theme="dark"] .ritual-card,
:root[data-theme="dark"] .command-copy {
  background: linear-gradient(180deg, rgba(24, 27, 33, 0.98), rgba(32, 36, 44, 0.94));
}

.ritual-card span,
.supplement-topline span,
.guide-feature span {
  color: var(--soft);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ritual-card strong {
  display: block;
  margin: 10px 0 8px;
  color: var(--text);
  font-size: 1.32rem;
  line-height: 1.15;
}

.ritual-card small {
  color: var(--muted);
  line-height: 1.45;
}

.level-meter {
  height: 9px;
  margin: 14px 0 9px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.level-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ink), var(--gold), var(--blue));
  transition: width 280ms ease;
}

.quest-card {
  border-color: color-mix(in srgb, var(--gold) 36%, var(--line));
}

.coach-deck {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.coach-card {
  padding: 18px;
}

.coach-card span {
  color: var(--soft);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.coach-card strong {
  display: block;
  margin: 10px 0 8px;
  color: var(--text);
  font-size: 1.28rem;
  line-height: 1.2;
}

.coach-main {
  background:
    linear-gradient(135deg, rgba(21, 25, 34, 0.96), rgba(46, 55, 69, 0.96)),
    linear-gradient(90deg, rgba(184, 138, 68, 0.22), transparent);
  color: #ffffff;
}

.coach-main strong,
.coach-main p {
  color: #ffffff;
}

.coach-main span {
  color: #d8bf92;
}

.coach-card p,
.coach-card small {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.coach-main p {
  opacity: 0.78;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.34fr) minmax(240px, 0.24fr) minmax(0, 0.42fr);
  gap: 14px;
  align-items: start;
}

.photo-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.45fr) minmax(0, 0.55fr);
  gap: 14px;
  align-items: start;
}

.panel {
  padding: 20px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading.split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.entry-form label {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.entry-form input,
.entry-form select,
.entry-form textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  outline: 0;
  padding: 12px;
  font-weight: 700;
}

.entry-form textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.entry-form input:focus,
.entry-form select:focus,
.entry-form textarea:focus {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(49, 130, 246, 0.14);
}

.unit {
  position: absolute;
  right: 12px;
  bottom: 14px;
  color: var(--soft);
  font-size: 0.75rem;
  pointer-events: none;
}

.full,
.wide {
  grid-column: 1 / -1;
}

.import-button {
  position: relative;
}

.import-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  background: var(--surface-blue);
  color: var(--blue);
  padding: 0 12px;
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.compare-panel,
.supplement-panel {
  margin: 14px 0;
}

.range-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 4px;
}

.range-tab {
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 900;
}

.range-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 16px rgba(22, 28, 40, 0.07);
}

.compare-grid,
.supplement-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.compare-grid article,
.supplement-card,
.guide-feature,
.guide-link {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.compare-grid article {
  padding: 16px;
}

.compare-grid span {
  color: var(--soft);
  font-size: 0.75rem;
  font-weight: 900;
}

.compare-grid strong {
  display: block;
  margin: 9px 0 7px;
  color: var(--text);
  font-size: 1.28rem;
  line-height: 1.15;
}

.compare-grid strong[data-state="positive"] {
  color: var(--green);
}

.compare-grid strong[data-state="warning"] {
  color: var(--red);
}

.compare-grid small {
  color: var(--muted);
  line-height: 1.42;
}

.supplement-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.supplement-card {
  padding: 16px;
  background:
    linear-gradient(180deg, var(--surface), var(--surface-soft));
}

.supplement-card[data-state="positive"] {
  border-color: color-mix(in srgb, var(--green) 28%, var(--line));
}

.supplement-card[data-state="warning"] {
  border-color: color-mix(in srgb, var(--red) 30%, var(--line));
}

.supplement-topline,
.supplement-actions,
.header-actions,
.record-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.supplement-topline {
  justify-content: space-between;
}

.supplement-topline strong {
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  padding: 5px 8px;
  font-size: 0.7rem;
}

.supplement-card h3 {
  margin: 12px 0 8px;
}

.supplement-card p {
  margin-bottom: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.supplement-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.supplement-card dl > div {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.supplement-card dt {
  color: var(--soft);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.supplement-card dd {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.86rem;
}

.supplement-actions {
  flex-wrap: wrap;
  margin-top: 14px;
}

.supplement-actions a,
.guide-feature a,
.guide-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 900;
}

.supplement-actions a,
.guide-feature a {
  min-height: 34px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-size: 0.78rem;
}

.guide-feature {
  display: grid;
  gap: 8px;
  padding: 14px;
  margin-bottom: 12px;
  background:
    linear-gradient(135deg, var(--surface), var(--gold-soft));
}

.guide-feature strong {
  font-size: 1.2rem;
}

.guide-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  padding-right: 2px;
}

.guide-link {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  transition: transform 140ms ease, background 140ms ease;
}

.guide-link:hover {
  transform: translateY(-1px);
  background: var(--surface);
}

.guide-link span {
  color: var(--text);
  font-size: 0.9rem;
}

.guide-link small {
  color: var(--soft);
  font-size: 0.74rem;
}

.header-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.compact-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.76rem;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.chart-card,
.muscle-map,
.insight-board {
  padding: 16px;
  box-shadow: none;
  background: var(--surface-soft);
}

.chart-title {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

.chart-title strong {
  color: var(--blue);
  font-size: 0.84rem;
}

canvas {
  display: block;
  width: 100%;
  min-height: 190px;
}

.muscle-map,
.insight-board {
  margin-top: 12px;
}

.muscle-bars {
  display: grid;
  gap: 9px;
}

.muscle-row {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr) 86px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.muscle-row strong {
  color: var(--text);
  text-align: right;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #84c5ff);
  transition: width 320ms ease;
}

.insight-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.insight-list li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  padding: 13px;
  line-height: 1.58;
}

.insight-list strong {
  color: var(--text);
}

.table-panel {
  margin: 14px 0;
}

.record-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.record-card {
  box-shadow: none;
  padding: 14px;
}

.record-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.record-card h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.25;
}

.record-card time {
  color: var(--soft);
  font-size: 0.76rem;
  font-weight: 800;
}

.record-card .body-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-blue);
  color: var(--blue);
  padding: 0 9px;
  font-size: 0.72rem;
  font-weight: 900;
}

.record-card-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.inline-delete {
  min-height: 26px;
  border: 1px solid #ffd5d8;
  border-radius: 999px;
  background: #fff1f2;
  color: var(--red);
  cursor: pointer;
  padding: 0 8px;
  font-size: 0.7rem;
  font-weight: 900;
}

.record-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.record-metrics span {
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  padding: 9px 8px;
  font-size: 0.76rem;
  line-height: 1.35;
}

.record-metrics strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 0.88rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 12px;
  text-align: left;
  font-size: 0.86rem;
}

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

th {
  background: var(--surface-soft);
  color: var(--soft);
  font-size: 0.72rem;
  font-weight: 900;
}

td {
  color: var(--muted);
}

td strong {
  color: var(--text);
}

.row-delete {
  min-width: 46px;
  min-height: 34px;
  border: 1px solid #ffd5d8;
  border-radius: var(--radius);
  background: #fff1f2;
  color: var(--red);
  cursor: pointer;
  font-weight: 900;
}

:root[data-theme="dark"] .row-delete {
  border-color: rgba(229, 72, 77, 0.28);
  background: rgba(229, 72, 77, 0.12);
}

:root[data-theme="dark"] .inline-delete {
  border-color: rgba(229, 72, 77, 0.28);
  background: rgba(229, 72, 77, 0.12);
}

.empty-cell {
  padding: 26px;
  color: var(--soft);
  text-align: center;
}

.photo-grid {
  grid-template-columns: minmax(320px, 0.45fr) minmax(0, 0.55fr);
}

.file-zone {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 13px;
}

.file-zone input {
  min-height: auto;
  border: 0;
  padding: 8px 0 0;
  background: transparent;
}

.comparison-view {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.comparison-view figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.comparison-view img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  background: var(--surface-soft);
  object-fit: cover;
}

.comparison-view figcaption {
  padding: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.metric-stack {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.metric-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.metric-box strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 1.15rem;
}

.model-panel {
  margin-top: 14px;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.model-grid > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 16px;
}

.model-grid p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.source-links a {
  border-radius: 999px;
  background: var(--surface-blue);
  color: var(--blue);
  padding: 10px 12px;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 800;
}

.save-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 40;
  min-width: min(92vw, 320px);
  transform: translate(-50%, 14px);
  border-radius: var(--radius);
  background: #191f28;
  color: #ffffff;
  box-shadow: var(--shadow-strong);
  padding: 13px 16px;
  text-align: center;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.save-toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.mobile-tabbar {
  display: none;
}

@media (max-width: 1120px) {
  .command-grid,
  .workspace-grid,
  .photo-grid {
    grid-template-columns: 1fr;
  }

  .storage-strip,
  .kpi-grid,
  .ritual-grid,
  .coach-deck,
  .compare-grid,
  .model-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .record-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 740px) {
  body {
    padding-bottom: 78px;
  }

  .topbar {
    padding: 12px 14px;
  }

  .brand small,
  .nav-links {
    display: none;
  }

  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .command-copy,
  .scanner-panel,
  .panel {
    padding: 16px;
  }

  .briefing-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .briefing-strip::before {
    width: 100%;
    height: 4px;
  }

  h1 {
    font-size: 2.2rem;
    line-height: 1.12;
  }

  h2 {
    font-size: 1.18rem;
  }

  .lead {
    font-size: 0.96rem;
  }

  .hero-actions,
  .data-tools {
    display: grid;
    grid-template-columns: 1fr;
  }

  .storage-strip,
  .kpi-grid,
  .ritual-grid,
  .coach-deck,
  .compare-grid,
  .supplement-grid,
  .chart-grid,
  .entry-form,
  .comparison-view,
  .metric-stack,
  .model-grid,
  .record-cards {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    min-height: auto;
  }

  .kpi-card strong {
    font-size: 1.7rem;
  }

  .panel-heading.split {
    flex-direction: column;
  }

  .muscle-row {
    grid-template-columns: 78px minmax(0, 1fr) 70px;
  }

  .record-cards {
    margin-bottom: 0;
  }

  .table-wrap {
    display: none;
  }

  .mobile-tabbar {
    position: fixed;
    right: 10px;
    bottom: 10px;
    left: 10px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: var(--shadow-strong);
    padding: 6px;
    backdrop-filter: blur(18px);
  }

  .mobile-tabbar a {
    min-height: 42px;
    border-radius: var(--radius);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 900;
  }

  .mobile-tabbar a:hover {
    background: var(--surface-blue);
    color: var(--blue);
  }
}

@media print {
  .topbar,
  .hero-actions,
  .briefing-strip,
  .data-entry,
  .photo-entry,
  .data-tools,
  .mobile-tabbar,
  .save-toast {
    display: none !important;
  }

  body {
    background: #ffffff;
    color: #151515;
    padding-bottom: 0;
  }

  .page-shell {
    width: 100%;
    padding: 0;
  }

  .command-grid,
  .workspace-grid,
  .photo-grid,
  .kpi-grid,
  .chart-grid,
  .model-grid {
    display: block;
  }

  .panel,
  .kpi-card,
  .chart-card,
  .muscle-map,
  .insight-board,
  .record-card {
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 12px;
  }
}
