:root {
  --bg: #f7f7fb; --surface: #ffffff; --text: #1b1d29; --muted: #5b5f73;
  --accent: #4a5bd4; --accent-text: #ffffff; --line: #e2e4ee;
  --tier-strong: #1d7a4c; --tier-soft: #8a6d1f;
  --pad: 16px; --radius: 14px;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12131a; --surface: #1c1e28; --text: #eceef6; --muted: #a2a7bb;
    --accent: #7d8cf0; --accent-text: #12131a; --line: #2b2e3c;
    --tier-strong: #5fd39a; --tier-soft: #d9bd6a;
  }
}
:root[data-theme="dark"] {
  --bg: #12131a; --surface: #1c1e28; --text: #eceef6; --muted: #a2a7bb;
  --accent: #7d8cf0; --accent-text: #12131a; --line: #2b2e3c;
  --tier-strong: #5fd39a; --tier-soft: #d9bd6a;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 var(--pad);
}
h1 { font-size: 1.5rem; margin: 1.25rem 0 0.5rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
p { margin: 0.5rem 0; }
.muted { color: var(--muted); font-size: 0.9rem; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--pad); margin: 12px 0;
}
.btn {
  display: block; width: 100%; min-height: 56px; border: 0;
  border-radius: var(--radius); background: var(--accent); color: var(--accent-text);
  font-size: 1.05rem; font-weight: 600; cursor: pointer; padding: 14px;
}
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.field { display: block; margin: 14px 0; }
.field span { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
.tier { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.tier-A1, .tier-A2 { color: var(--tier-strong); }
.tier-B, .tier-C { color: var(--tier-soft); }
.reason { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.window { font-size: 2rem; font-weight: 700; margin: 6px 0; }
.countdown { font-size: 1.1rem; color: var(--muted); }
nav.tabs { display: flex; gap: 6px; margin: 16px 0; flex-wrap: wrap; }
nav.tabs button {
  flex: 1 1 auto; min-width: 72px; min-height: 44px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); border-radius: 10px; cursor: pointer;
}
nav.tabs button[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.notice { border-left: 3px solid var(--accent); padding-left: 12px; }
[hidden] { display: none !important; }

.daybar {
  position: relative; height: 22px; margin: 10px 0 2px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
}
.daybar .seg { position: absolute; top: 0; bottom: 0; }
.seg-nap { background: var(--accent); opacity: 0.75; }
.seg-night { background: var(--tier-strong); opacity: 0.6; }
.daybar-axis {
  position: relative; height: 14px; margin-bottom: 8px;
  font-size: 0.7rem; color: var(--muted);
}
.daybar-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.daybar-axis span:first-child { transform: translateX(0); }
.daybar-axis span:last-child { transform: translateX(-100%); }
.sleep-list { list-style: none; padding: 0; margin: 8px 0 0; }
.sleep-list li {
  padding: 8px 10px; margin: 4px 0;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg);
  cursor: pointer; min-height: 44px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.sleep-list li strong { font-weight: 600; }
.past-sleep {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--surface);
}
.past-sleep summary {
  cursor: pointer; min-height: 44px; display: flex; align-items: center;
  font-weight: 600; color: var(--accent);
}
.past-sleep[open] summary { margin-bottom: 4px; }
