/* Agenda — tokens and components ported from docs/design/mockup.html */
:root {
  --bg: #eef2f7; --surface: #ffffff; --surface-2: #f5f7fb; --fg: #172033; --muted: #5b6880; --line: #dde3ec;
  --ink: #2350d8; --ink-soft: #e5ecff; --on-ink: #ffffff; --head: #2350d8;
  --good: #14845a; --good-soft: #e2f5ec; --warn: #b5560b; --warn-soft: #fdeedd; --bad: #c03636; --bad-soft: #fbe5e5;
  --display: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420; --surface: #182031; --surface-2: #131a29; --fg: #e7ecf5; --muted: #9aa6bd; --line: #2b3549;
    --ink: #7d9bff; --ink-soft: #24305a; --on-ink: #0f1420; --head: #1b2a5c;
    --good: #4fd39a; --good-soft: #173a2c; --warn: #f0a35a; --warn-soft: #3e2a15; --bad: #ff7b7b; --bad-soft: #421f22;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1420; --surface: #182031; --surface-2: #131a29; --fg: #e7ecf5; --muted: #9aa6bd; --line: #2b3549;
  --ink: #7d9bff; --ink-soft: #24305a; --on-ink: #0f1420; --head: #1b2a5c;
  --good: #4fd39a; --good-soft: #173a2c; --warn: #f0a35a; --warn-soft: #3e2a15; --bad: #ff7b7b; --bad-soft: #421f22;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surface-2); color: var(--fg);
  font-family: var(--body); font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  overflow: hidden; overscroll-behavior: none;
}
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.app { height: 100%; height: 100dvh; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; background: var(--surface-2); }

.ph-head {
  background: var(--head); color: #fff;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) 10px max(18px, env(safe-area-inset-left, 0px));
}
.head-row { display: flex; align-items: center; gap: 4px; }
.head-text { flex: 1; min-width: 0; }
.ph-head small { display: block; opacity: .85; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-head h1 { font-size: 1.3rem; line-height: 1.25; color: #fff; }
.hstatus { margin: 2px 0 0; font-size: .75rem; opacity: .85; min-height: 1.1em; }

.icon-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  background: none; border: 0; border-radius: 12px; color: #fff; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { background: rgb(255 255 255 / .15); }
.icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.icon-btn.plain { color: var(--muted); }
.icon-btn.plain:focus-visible { outline-color: var(--ink); }
.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pull { height: 0; overflow: hidden; display: grid; place-items: center; font-size: .75rem; color: var(--muted); transition: height .15s; }
.pull.ready span::after { content: " ↓"; }

.ph-body {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  padding: 14px max(14px, env(safe-area-inset-right, 0px)) 18px max(14px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 12px; outline: none;
}

.tabs {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.tabs button {
  background: none; border: 0; min-height: 56px; padding: 8px 2px 8px;
  font: 500 .7rem var(--body); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer; position: relative;
}
.tabs button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linejoin: round; }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.dot { position: absolute; top: 5px; right: calc(50% - 20px); background: var(--bad); color: #fff; font-size: .6rem; font-weight: 600; border-radius: 9px; padding: 0 5px; line-height: 15px; }

/* ---------- content ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.card h4 { margin: 0 0 8px; font: 600 .78rem var(--body); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.new { border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-soft); }

.row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); width: 100%; }
.card > .row:first-of-type, .card > h4 + .row { border-top: 0; padding-top: 0; }
.row .t { font: 600 .75rem var(--body); color: var(--muted); min-width: 42px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.row .c { flex: 1; min-width: 0; }
.s { font-weight: 600; overflow-wrap: anywhere; }
.d { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.hw { background: var(--warn-soft); color: var(--fg); border-radius: 8px; padding: 6px 8px; margin-top: 4px; font-size: .85rem; overflow-wrap: anywhere; white-space: pre-line; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
button.row { background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; min-height: 44px; }
.card > button.row:first-of-type { border-top: 0; padding-top: 0; }
button.row:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
.more { margin: 8px 0 0; font-size: .8rem; color: var(--muted); }

.grade { font: 700 1.15rem var(--display); min-width: 34px; height: 34px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; flex: none; font-variant-numeric: tabular-nums; }
.grade.avg { font-size: .9rem; min-width: 50px; }
.g10 { background: var(--good-soft); color: var(--good); }
.g9 { background: var(--ink-soft); color: var(--ink); }
.g7 { background: var(--warn-soft); color: var(--warn); }
.g5 { background: var(--bad-soft); color: var(--bad); }
.g-none { background: var(--surface-2); color: var(--muted); }

.pill { display: inline-block; font-size: .7rem; font-weight: 600; border-radius: 999px; padding: 1px 8px; vertical-align: 1px; white-space: nowrap; }
.p-good { background: var(--good-soft); color: var(--good); }
.p-bad, .p-abs { background: var(--bad-soft); color: var(--bad); }
.p-info { background: var(--ink-soft); color: var(--ink); }

.daypick { position: relative; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -2px; padding: 2px; scroll-padding: 0 8px; flex: none; }
.daypick::-webkit-scrollbar { display: none; }
.daypick button {
  flex: 1 0 52px; min-height: 52px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 6px 4px; font: 500 .75rem var(--body); color: var(--fg); cursor: pointer;
}
.daypick button b { display: block; font: 600 1rem var(--display); }
.daypick button.today { border-color: var(--ink); }
.daypick button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

.stat { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; min-width: 0; }
.stat b { display: block; font: 700 1.4rem var(--display); font-variant-numeric: tabular-nums; }
.stat small { display: block; color: var(--muted); font-size: .72rem; line-height: 1.3; }

.bar { height: 8px; background: var(--bad); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--good); }
.note-text { margin: 8px 0 0; font-size: .85rem; color: var(--muted); }

.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; flex: none; }
.seg button { flex: 1; min-height: 44px; border: 0; background: none; border-radius: 8px; padding: 6px; font: 500 .85rem var(--body); color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink-soft); color: var(--ink); }

.msg { margin: 6px 0 0; overflow-wrap: anywhere; }
.empty { color: var(--muted); font-size: .85rem; margin: 0; }
.empty.center { text-align: center; padding: 40px 0; }

/* ---------- settings sheet ---------- */
.sheet {
  width: 100%; max-width: 640px; margin: auto auto 0; border: 0; border-radius: 20px 20px 0 0;
  background: var(--surface); color: var(--fg);
  padding: 16px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
}
.sheet::backdrop { background: rgb(0 0 0 / .45); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { font-size: 1.2rem; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 6px 0; border-top: 1px solid var(--line); cursor: pointer; }
.setting small { display: block; color: var(--muted); font-size: .8rem; }
.hint { margin: 4px 0 12px; font-size: .85rem; color: var(--warn); background: var(--warn-soft); border-radius: 10px; padding: 8px 10px; }

.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0;
  width: 52px; height: 32px; border-radius: 16px; background: var(--line); position: relative; cursor: pointer; transition: background .15s;
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .15s; }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; cursor: default; }
.switch:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; margin-top: 10px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg);
  font: 600 .95rem var(--body); text-decoration: none; cursor: pointer;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: #2350d8; border-color: #2350d8; color: #fff; }
.btn.danger { color: var(--bad); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- login ---------- */
body.login { overflow: auto; background: var(--bg); display: grid; place-items: center; min-height: 100%;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px; text-align: center; }
.login-card img { border-radius: 18px; }
.login-card h1 { font-size: 1.6rem; margin-top: 12px; }
.login-card .lead { color: var(--muted); margin: 6px 0 18px; }
.login-card .error { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin: 0 0 8px; text-align: left; }

@media (prefers-reduced-motion: reduce) { .spin svg { animation: none; } * { transition: none !important; } }
