:root {
  --bg: #edf3ea;
  --surface: #ffffff;
  --ink: #162315;
  --muted: #4f6250;
  --accent: #256239;
  --accent-2: #0f8a5b;
  --line: #d2dfd1;
  --good: #2f7d42;
  --warn: #b07617;
  --bad: #b33535;
  --shadow: 0 14px 28px rgba(18, 34, 20, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 90% 0%, rgba(176, 226, 188, 0.45), rgba(176, 226, 188, 0) 35%),
    radial-gradient(circle at 12% 85%, rgba(188, 226, 214, 0.4), rgba(188, 226, 214, 0) 36%),
    var(--bg);
  color: var(--ink);
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 16px 56px;
}

header h1 {
  margin: 0;
  font-size: 1.95rem;
  font-family: "Sora", "Manrope", sans-serif;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-link {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.home-link:hover {
  background: #f6f8f5;
}

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}

h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

label {
  display: block;
  margin-top: 10px;
  font-weight: 600;
}

input, textarea, button {
  width: 100%;
  margin-top: 6px;
  border-radius: 8px;
  border: 1px solid #cfd8cd;
  padding: 10px;
  font: inherit;
}

select {
  width: 100%;
  margin-top: 6px;
  border-radius: 8px;
  border: 1px solid #cfd8cd;
  padding: 10px;
  font: inherit;
  background: #fff;
}

button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
}

button.secondary {
  background: #506857;
}

button:hover {
  filter: brightness(1.05);
}

.task-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: #fcfdfb;
}

.task-item input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.task-item button {
  width: auto;
  margin: 0 0 0 auto;
  padding: 6px 10px;
}

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

.tiny {
  font-size: 0.82rem;
}


.muted.ok {
  color: var(--good);
}

.muted.warn {
  color: var(--warn);
}

.hidden {
  display: none;
}

.date-row {
  max-width: 240px;
}

.inventory-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.inventory-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfdfb;
}

.inventory-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.inventory-name {
  margin: 0;
  font-weight: 600;
}

.inventory-controls {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.inventory-controls input {
  margin: 0;
}

.inventory-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.score-grid {
  display: grid;
  gap: 10px;
}

.trend-grid {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.trend-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfdfb;
}

.trend-svg {
  display: block;
  width: 100%;
  height: 56px;
}

.streak-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfdfb;
  margin-bottom: 10px;
}

.score-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfdfb;
}

.score-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.score-value {
  margin: 2px 0 4px;
  font-size: 1.45rem;
  font-weight: 700;
  font-family: "Sora", "Manrope", sans-serif;
}

.bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e5ece3;
  overflow: hidden;
  margin-top: 8px;
}

.bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 180ms ease;
}

.status-pill {
  display: inline-block;
  margin-top: 12px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-pill.good {
  background: #e6f4e9;
  color: var(--good);
}

.status-pill.warn {
  background: #fff4df;
  color: var(--warn);
}

.status-pill.bad {
  background: #fdeaea;
  color: var(--bad);
}

.status-pill.neutral {
  background: #eff2ef;
  color: var(--muted);
}

.reminder-settings {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.reminder-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0;
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 600;
}

.inline-toggle input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.reminder-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfdfb;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.reminder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reminder-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.reminder-controls input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.reminder-controls input[type="time"] {
  margin: 0;
}

.reminder-feed {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.reminder-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfdfb;
}

.reminder-item p {
  margin: 0;
}

.reminder-item .actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.reminder-item .actions button {
  margin: 0;
}

.lite-grid {
  display: grid;
  gap: 10px;
}

.lite-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfdfb;
  margin-top: 10px;
}

.benchmark-card h2 {
  margin-bottom: 10px;
}

.benchmark-grid {
  display: grid;
  gap: 10px;
}

.benchmark-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: linear-gradient(160deg, #fcfffc, #f3faf4);
}

.planner-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.planner-col {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fcfefc;
}

.planner-col h3 {
  margin: 2px 0 8px;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 0.95rem;
}

.planner-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #fff;
}

.pill.p1 { color: #9a1e1e; border-color: #f0cbcb; background: #fff1f1; }
.pill.p2 { color: #934f00; border-color: #f0dcc0; background: #fff7ea; }
.pill.p3 { color: #2a5a37; border-color: #d2e7d7; background: #eef9f0; }
.pill.p4 { color: #425240; border-color: #dee7dd; background: #f3f6f3; }

.inline-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.inline-actions button {
  margin: 0;
  width: auto;
  padding: 6px 8px;
}

/* ─── Supplement cards (enriched daily routine) ─── */
.supp-card {
  align-items: flex-start;
  padding: 12px;
}

.supp-card input[type="checkbox"] {
  margin-top: 3px;
}

.supp-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.supp-name {
  font-weight: 600;
  line-height: 1.3;
}

.supp-dose {
  font-size: 0.82rem;
  color: var(--muted);
}

.supp-why {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}

.supp-evidence {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  margin-top: 2px;
}

.supp-evidence:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  /* ── Layout & overflow prevention ────────────── */
  .container {
    padding: 14px 10px 40px;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* ── Typography ──────────────────────────────── */
  header h1 {
    font-size: 1.3rem;
    line-height: 1.3;
  }

  .header-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .eyebrow {
    font-size: 0.72rem;
    margin-bottom: 4px;
  }

  h2 {
    font-size: 1.05rem;
  }

  .score-value {
    font-size: 1.25rem;
  }

  .tiny {
    font-size: 0.78rem;
  }

  /* ── Cards ───────────────────────────────────── */
  .card {
    padding: 14px 12px;
    margin-top: 10px;
    border-radius: 10px;
  }

  /* ── Forms: 16px font prevents iOS zoom ──────── */
  input, textarea, select {
    font-size: 16px;
    padding: 12px 10px;
    min-height: 44px;
  }

  textarea {
    min-height: 80px;
  }

  /* ── Buttons: touch-friendly 44px min ────────── */
  button {
    min-height: 44px;
    padding: 12px 14px;
    font-size: 0.95rem;
  }

  button.secondary {
    min-height: 44px;
    padding: 12px 14px;
  }

  .theme-toggle {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 12px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .home-link {
    min-height: 44px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
  }

  /* ── Task list: easy to tap/check ────────────── */
  .task-item {
    padding: 10px 12px;
    gap: 12px;
    min-height: 48px;
  }

  .task-item input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    cursor: pointer;
  }

  .task-item button {
    min-height: 40px;
    min-width: 44px;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .supp-card input[type="checkbox"] {
    margin-top: 2px;
  }

  /* ── Inline actions (planner move buttons) ───── */
  .inline-actions {
    gap: 4px;
    flex-wrap: wrap;
  }

  .inline-actions button {
    min-height: 40px;
    min-width: 40px;
    padding: 8px;
    font-size: 0.78rem;
  }

  /* ── Score grids: stack vertically ───────────── */
  .score-grid {
    grid-template-columns: 1fr;
  }

  .score-box {
    padding: 12px;
  }

  /* ── Trend grid: stack vertically ────────────── */
  .trend-grid {
    grid-template-columns: 1fr;
  }

  .trend-item {
    padding: 10px;
  }

  /* ── Streak box ──────────────────────────────── */
  .streak-box {
    padding: 12px;
  }

  /* ── Benchmark grid: stack vertically ────────── */
  .benchmark-grid {
    grid-template-columns: 1fr;
  }

  .benchmark-item {
    padding: 10px;
  }

  /* ── Lite grid (backlog, goals, badges) ──────── */
  .lite-grid {
    grid-template-columns: 1fr;
  }

  .lite-box {
    padding: 12px 10px;
    margin-top: 8px;
  }

  /* ── Planner grid: columns stack vertically ──── */
  .planner-grid {
    grid-template-columns: 1fr;
  }

  .planner-col {
    padding: 10px;
    border-radius: 10px;
  }

  .planner-col h3 {
    font-size: 0.9rem;
  }

  /* ── Pill badges ─────────────────────────────── */
  .pill {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  /* ── Status pill ─────────────────────────────── */
  .status-pill {
    font-size: 0.8rem;
    padding: 8px 12px;
    display: block;
    text-align: center;
  }

  /* ── Inventory ───────────────────────────────── */
  .inventory-item {
    padding: 10px;
  }

  .inventory-head {
    flex-wrap: wrap;
    gap: 6px;
  }

  .inventory-controls {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .inventory-controls input {
    min-height: 44px;
  }

  /* ── Reminder settings ───────────────────────── */
  .reminder-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .reminder-toolbar button {
    width: 100%;
  }

  .inline-toggle {
    min-height: 44px;
    gap: 10px;
  }

  .inline-toggle input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
  }

  .reminder-row {
    padding: 10px;
  }

  .reminder-controls {
    grid-template-columns: auto 1fr;
    gap: 8px;
  }

  .reminder-controls input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
  }

  .reminder-controls input[type="time"] {
    min-height: 44px;
    font-size: 16px;
  }

  .reminder-item .actions {
    flex-wrap: wrap;
  }

  .reminder-item .actions button {
    min-height: 40px;
    flex: 1;
    min-width: 80px;
  }

  /* ── Date row ────────────────────────────────── */
  .date-row {
    max-width: 100%;
  }

  /* ── Import/export section ───────────────────── */
  input[type="file"] {
    min-height: 44px;
    padding: 10px;
  }

  /* ── Bar (progress bars) ─────────────────────── */
  .bar {
    height: 12px;
    margin-top: 6px;
  }

  /* ── Planner meta text ───────────────────────── */
  .planner-meta {
    font-size: 0.72rem;
  }
}

@media (min-width: 720px) {
  .benchmark-grid {
    grid-template-columns: 1fr 1fr;
  }
  .score-grid {
    grid-template-columns: 1fr 1fr;
  }
  .trend-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .lite-grid {
    grid-template-columns: 1fr 1fr;
  }
  .planner-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ── Dark Mode ───────────────────────────────── */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1610;
    --surface: #1a2318;
    --ink: #d4e5d0;
    --muted: #8ba888;
    --accent: #4faa6a;
    --accent-2: #38c87a;
    --line: #2c3d2a;
    --good: #4faa6a;
    --warn: #d4a33a;
    --bad: #d44e4e;
    --shadow: 0 14px 28px rgba(0, 0, 0, 0.25);
  }

  :root:not([data-theme="light"]) body {
    background:
      radial-gradient(circle at 90% 0%, rgba(40, 80, 50, 0.3), transparent 35%),
      radial-gradient(circle at 12% 85%, rgba(30, 70, 60, 0.25), transparent 36%),
      var(--bg);
  }

  :root:not([data-theme="light"]) .home-link {
    background: var(--surface);
  }

  :root:not([data-theme="light"]) .home-link:hover {
    background: #243022;
  }

  :root:not([data-theme="light"]) input,
  :root:not([data-theme="light"]) textarea,
  :root:not([data-theme="light"]) select {
    background: var(--bg);
    color: var(--ink);
    border-color: var(--line);
  }

  :root:not([data-theme="light"]) button {
    color: var(--ink);
  }
}

[data-theme="dark"] {
  --bg: #0f1610;
  --surface: #1a2318;
  --ink: #d4e5d0;
  --muted: #8ba888;
  --accent: #4faa6a;
  --accent-2: #38c87a;
  --line: #2c3d2a;
  --good: #4faa6a;
  --warn: #d4a33a;
  --bad: #d44e4e;
  --shadow: 0 14px 28px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at 90% 0%, rgba(40, 80, 50, 0.3), transparent 35%),
    radial-gradient(circle at 12% 85%, rgba(30, 70, 60, 0.25), transparent 36%),
    var(--bg);
}

[data-theme="dark"] .home-link {
  background: var(--surface);
}

[data-theme="dark"] .home-link:hover {
  background: #243022;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
}

[data-theme="dark"] button {
  color: var(--ink);
}

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
}

.theme-toggle:hover {
  background: var(--line);
}

/* ─── Breadcrumb ─── */
.breadcrumb {
  margin: 0 0 4px;
}
.breadcrumb ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
}
.breadcrumb li { display: flex; align-items: center; gap: 4px; }
.breadcrumb li + li::before { content: "/"; color: var(--muted); }
.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  border-radius: 4px;
  padding: 2px 6px;
}
.breadcrumb a:hover { color: var(--ink); background: rgba(0,0,0,0.05); }
.breadcrumb [aria-current] { color: var(--ink); font-weight: 500; }

/* ─── Accessibility: sr-only ─── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.sr-only:focus,
.sr-only:focus-visible {
  position: fixed;
  top: 8px;
  left: 8px;
  width: auto;
  height: auto;
  padding: 8px 16px;
  margin: 0;
  overflow: visible;
  clip-path: none;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  border-radius: 8px;
  z-index: 9999;
  text-decoration: none;
}

/* ─── Accessibility: focus-visible indicators ─── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.task-item input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Keyboard shortcut help overlay ─── */
.kb-help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.kb-help-overlay.open {
  display: flex;
}

.kb-help-panel {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.kb-help-panel h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.kb-help-panel dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  align-items: baseline;
}

.kb-help-panel dt {
  font-weight: 600;
}

.kb-help-panel dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.kb-help-panel kbd {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
}

.kb-help-panel .kb-help-close {
  margin-top: 16px;
  width: 100%;
}

.kb-help-section {
  margin-top: 14px;
}

.kb-help-section:first-of-type {
  margin-top: 0;
}

.kb-help-section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
  grid-column: 1 / -1;
}

/* ─── Section focus target ─── */
.card[id]:target {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 14px;
}

@media (prefers-reduced-motion: reduce) {
  .card[id]:target {
    outline: none;
  }
}
