:root {
  color-scheme: light;
  --navy: #10263a;
  --ink: #172b3d;
  --muted: #68798a;
  --paper: #f4f7fa;
  --white: #ffffff;
  --line: #dfe6ec;
  --yellow: #f4c84a;
  --red: #b93838;
  --red-bg: #fff0ef;
  --amber: #965900;
  --amber-bg: #fff4dc;
  --green: #217746;
  --green-bg: #e9f6ed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

button, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell {
  width: min(100%, 560px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  margin: -12px -18px 18px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  color: white;
  background: var(--navy);
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid #52697d;
  border-radius: 12px;
  color: var(--yellow);
  font-size: 22px;
}

.topbar h1 { margin: 2px 0 0; font-size: 17px; font-weight: 750; letter-spacing: -.25px; }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 1.1px; }
.topbar .eyebrow { color: #b8c8d7; }
.icon-button { margin-left: auto; border: 0; background: transparent; color: white; font-size: 27px; line-height: 1; }
.icon-button:active { transform: rotate(35deg); }

.loading-card, .empty-card, .error-card {
  padding: 26px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  text-align: center;
}
.loading-card { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 100px; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.queue-line { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 18px; }
.queue-line h2 { margin: 3px 0 0; font-size: 30px; letter-spacing: -.7px; }
.text-button, .back-button { border: 0; padding: 9px 12px; border-radius: 10px; color: var(--navy); background: #e7edf2; font-weight: 700; }
.day-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border-radius: 13px; background: #e7edf2; }
.day-tab { min-height: 42px; border: 0; border-radius: 10px; color: #586b7d; background: transparent; font-weight: 750; }
.day-tab.selected { color: var(--navy); background: white; box-shadow: 0 1px 4px #10263a1a; }
.date-label { margin: 12px 2px 15px; color: var(--muted); font-size: 13px; font-weight: 600; }

.next-card { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; padding: 15px; border: 1px solid #f1d99d; border-radius: 16px; background: #fffaf0; }
.next-icon { display: grid; width: 43px; height: 43px; flex: 0 0 43px; place-items: center; border-radius: 13px; color: var(--amber); background: #ffedc2; font-size: 23px; font-weight: 800; }
.next-title { margin: 4px 0 0; font-size: 16px; font-weight: 800; }
.next-time { margin: 3px 0 0; color: var(--amber); font-size: 14px; font-weight: 700; }

.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 10px; }
.section-heading h3 { margin: 0; font-size: 17px; }
.count-pill { padding: 4px 9px; border-radius: 99px; color: #586b7d; background: #e7edf2; font-size: 12px; font-weight: 750; }
.period-list { display: grid; gap: 9px; }
.period-row { display: flex; align-items: center; justify-content: space-between; min-height: 65px; padding: 12px 14px; border: 1px solid var(--line); border-left: 5px solid; border-radius: 13px; background: white; }
.period-row.off { border-left-color: var(--red); }
.period-row.transition { border-left-color: var(--yellow); }
.period-row.on { border-left-color: var(--green); }
.period-state { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 700; }
.state-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; background: currentColor; }
.off .period-state { color: var(--red); }
.transition .period-state { color: var(--amber); }
.on .period-state { color: var(--green); }
.period-time { color: var(--ink); font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.empty-card { margin-top: 12px; }
.empty-icon { display: block; color: #c18b08; font-size: 32px; }
.empty-card h3 { margin: 8px 0; font-size: 17px; }
.empty-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.source-note { display: flex; align-items: center; gap: 7px; margin-top: 19px; color: var(--muted); font-size: 12px; }
.source-dot { width: 8px; height: 8px; border-radius: 50%; background: #368456; }
.source-note a { margin-left: auto; color: var(--navy); font-weight: 700; text-decoration: none; }
.disclaimer { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.back-button { margin: 0 0 20px; }
.settings-heading { margin-bottom: 22px; }
.settings-heading h2 { margin: 5px 0; font-size: 27px; letter-spacing: -.4px; }
.settings-heading > p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.field-label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 750; }
.queue-select { width: 100%; min-height: 50px; margin-bottom: 16px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: white; font-size: 16px; font-weight: 700; }
.settings-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: white; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 73px; padding: 12px 14px; }
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.setting-row strong { display: block; font-size: 14px; }
.setting-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.switch { position: relative; display: inline-flex; width: 48px; height: 28px; flex: 0 0 48px; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #cbd4dc; transition: .2s; }
.switch span::before { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: white; box-shadow: 0 1px 3px #0003; content: ""; transition: .2s; }
.switch input:checked + span { background: #287449; }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid #6c9ac0; outline-offset: 2px; }
.primary-button { width: 100%; min-height: 49px; margin-top: 16px; border: 0; border-radius: 12px; color: white; background: var(--navy); font-weight: 800; }
.primary-button:disabled { opacity: .55; }
.save-message { min-height: 20px; margin: 10px 0 0; color: var(--green); font-size: 13px; text-align: center; }

.error-card { margin-top: 15px; }
.error-mark { display: grid; width: 42px; height: 42px; margin: 0 auto; place-items: center; border-radius: 50%; color: var(--red); background: var(--red-bg); font-size: 24px; font-weight: 900; }
.error-card h2 { margin: 12px 0 6px; font-size: 19px; }
.error-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.toast { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); left: 18px; z-index: 5; width: fit-content; max-width: calc(100% - 36px); margin: auto; padding: 12px 16px; transform: translateY(20px); border-radius: 12px; color: white; background: var(--navy); opacity: 0; pointer-events: none; transition: .2s; }
.toast.visible { transform: translateY(0); opacity: 1; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
