:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dde5;
  --accent: #1f4f78;
  --accent-soft: #e8f0f7;
  --positive: #2f6f53;
  --positive-soft: #e9f4ef;
  --caution: #946200;
  --caution-soft: #fff3d6;
  --alert: #9f3a38;
  --alert-soft: #fbe9e8;
  --danger: #a12f2f;
  --shadow: 0 8px 28px rgba(17, 24, 39, .07);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, .file-label:focus-within {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(102px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 30px; line-height: 1; letter-spacing: -.03em; }
h2 { margin-bottom: 0; font-size: 26px; letter-spacing: -.025em; }
h3 { margin-bottom: 8px; font-size: 18px; }
.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.muted { color: var(--muted); line-height: 1.45; font-size: 14px; }

.progress-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) var(--progress, 0%), var(--line) 0);
  position: relative;
  flex: 0 0 auto;
}
.progress-ring::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: inherit;
  background: var(--bg);
}
.progress-ring span { z-index: 1; font-size: 12px; font-weight: 800; }

.view { display: none; }
.view.is-active { display: block; }

.setup-card,
.privacy-card,
.hero-card,
.task-card,
.route-card,
.settings-card,
.stock-row,
.day-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.setup-card {
  padding: 22px;
  box-shadow: var(--shadow);
}
.setup-card h2 { margin-bottom: 10px; }
.setup-card > p:not(.eyebrow):not(.status-message) { color: var(--muted); line-height: 1.5; }
.setup-import { width: 100%; margin-top: 6px; }
.privacy-card { margin-top: 12px; padding: 16px 18px; }
.privacy-card strong { display: block; margin-bottom: 5px; }
.privacy-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.mode-switch {
  display: grid;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 14px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.mode-button {
  min-width: 0;
  min-height: 46px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  padding: 8px;
}
.mode-button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 9px rgba(17,24,39,.08);
}

.hero-card {
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.hero-card h2 { margin: 0 0 8px; font-size: 24px; }
.hero-card p { margin-bottom: 0; color: var(--muted); line-height: 1.45; }

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}
.choice-button {
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 58px;
  padding: 8px 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .03em;
  overflow-wrap: anywhere;
}
.choice-button.positive.is-active { background: var(--positive-soft); color: var(--positive); border-color: color-mix(in srgb, var(--positive) 32%, var(--surface)); }
.choice-button.caution.is-active { background: var(--caution-soft); color: var(--caution); border-color: color-mix(in srgb, var(--caution) 32%, var(--surface)); }
.choice-button.alert.is-active { background: var(--alert-soft); color: var(--alert); border-color: color-mix(in srgb, var(--alert) 32%, var(--surface)); }
.choice-button.neutral.is-active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.plan-banner {
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: 14px;
  font-weight: 760;
  line-height: 1.35;
}
.plan-banner.positive { background: var(--positive-soft); color: var(--positive); }
.plan-banner.caution { background: var(--caution-soft); color: var(--caution); }
.plan-banner.alert { background: var(--alert-soft); color: var(--alert); }
.plan-banner.neutral { background: var(--accent-soft); color: var(--accent); }

.route-card { padding: 16px; margin-bottom: 14px; }
.route-card h3 { font-size: 16px; }
.route-options { display: grid; gap: 8px; }
.route-button {
  min-height: 52px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}
.route-button.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.route-button small { display: block; color: var(--muted); margin-top: 3px; font-weight: 500; line-height: 1.35; }

.section-label {
  margin: 22px 2px 8px;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.task-card { overflow: hidden; }
.task-row {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.task-row:last-child { border-bottom: 0; }
.task-row input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
}
.task-copy { min-width: 0; }
.task-title { display: block; font-weight: 720; line-height: 1.25; }
.task-note { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.task-time { color: var(--muted); font-size: 12px; font-weight: 750; white-space: nowrap; }
.task-row.is-complete .task-title { text-decoration: line-through; color: var(--muted); }
.optional-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: 1px;
}

.stop-card {
  margin-top: 14px;
  padding: 15px 16px;
  border-radius: 14px;
  background: #202938;
  color: white;
}
.stop-card strong { display: block; font-size: 15px; margin-bottom: 3px; }
.stop-card span { display: block; font-size: 12px; opacity: .78; line-height: 1.35; }

.empty-state {
  padding: 28px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  min-height: 44px;
  padding: 0 8px;
  font-weight: 750;
}

.week-grid { display: grid; gap: 10px; }
.day-card { padding: 14px; }
.day-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.day-name { font-weight: 850; }
.day-date { color: var(--muted); font-size: 12px; margin-top: 2px; }
.quality-chip {
  max-width: 48%;
  text-align: center;
  padding: 6px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quality-chip.positive { color: var(--positive); background: var(--positive-soft); }
.quality-chip.caution { color: var(--caution); background: var(--caution-soft); }
.quality-chip.alert { color: var(--alert); background: var(--alert-soft); }
.quality-chip.neutral { color: var(--muted); background: var(--surface-2); }
.day-progress { display: grid; gap: 10px; }
.mini-progress label { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.mini-progress label span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: inherit; }

.stock-list { display: grid; gap: 10px; margin-top: 16px; }
.stock-row { padding: 14px; display: grid; grid-template-columns: minmax(0,1fr) 104px; gap: 12px; align-items: center; }
.stock-row label { font-weight: 720; line-height: 1.25; }
.stock-row small { display: block; color: var(--muted); margin-top: 4px; font-size: 11px; line-height: 1.25; }
.stock-input-wrap { display: grid; grid-template-columns: 1fr; }
.stock-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 16px;
  text-align: right;
  background: var(--surface);
  color: var(--ink);
}
.stock-low { color: var(--alert); font-weight: 750; }
.stock-ok { color: var(--positive); font-weight: 750; }

.settings-card { padding: 18px; margin-bottom: 12px; }
.settings-card p { color: var(--muted); line-height: 1.45; font-size: 14px; margin-bottom: 14px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.primary-button, .secondary-button, .danger-button {
  min-height: 46px;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 760;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.primary-button { background: var(--accent); color: white; }
.secondary-button { background: var(--surface); color: var(--ink); border-color: var(--line); }
.danger-button { background: var(--danger); color: white; }
.file-label { cursor: pointer; }
.file-label input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.danger-card { border-color: #efcaca; }
.status-message { min-height: 18px; margin: 10px 0 0 !important; font-size: 13px; color: var(--muted); }
.source-note { color: var(--muted); font-size: 11px; line-height: 1.45; padding: 8px 4px 0; }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 760px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255,255,255,.94);
  border-top: 1px solid var(--line);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 10;
}
.nav-button {
  min-height: 54px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 720;
  border-radius: 12px;
}
.nav-button.is-active { color: var(--accent); background: var(--accent-soft); }
.nav-icon { font-size: 19px; line-height: 1; }

@media (min-width: 600px) {
  .app-shell { padding-left: 24px; padding-right: 24px; }
  .week-grid { grid-template-columns: 1fr 1fr; }
  .stock-list { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 370px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .choice-grid { gap: 6px; }
  .choice-button { font-size: 12px; }
  .task-row { grid-template-columns: 28px minmax(0,1fr); }
  .task-time { grid-column: 2; justify-self: start; }
  .stock-row { grid-template-columns: minmax(0,1fr) 90px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #151b23;
    --surface-2: #202833;
    --ink: #f4f6f8;
    --muted: #9ca7b5;
    --line: #2c3744;
    --accent: #78a9d1;
    --accent-soft: #172b3d;
    --positive: #86c9a7;
    --positive-soft: #173126;
    --caution: #e3bd69;
    --caution-soft: #3b3019;
    --alert: #e39a96;
    --alert-soft: #3e2324;
    --danger: #b94b4b;
    --shadow: none;
  }
  .bottom-nav { background: rgba(21,27,35,.94); }
  .stop-card { background: #05080c; }
}
