/* =========================================================
   StudyOS — design tokens
   ========================================================= */
:root {
  --bg: #ffffff;
  --rail: #fbfbfa;
  --sunken: #f7f7f6;
  --hover: #f3f3f2;
  --active: #ededec;
  --line: #ececeb;
  --line-2: #e1e1df;
  --line-3: #d1d1ce;
  --tx: #121212;
  --tx-2: #5c5c59;
  --tx-3: #8d8d89;
  --ink: #121212;
  --on-ink: #ffffff;
  --red: #e5484d;
  --amber: #c27c0e;
  --green: #2f8a4c;
  --blue: #2f6fdb;
  --tint: 13%;
  --ring: 0 0 0 3px rgba(18, 18, 18, .08);
  --shadow-sm: 0 1px 1px rgba(0, 0, 0, .03), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-lg: 0 0 0 1px rgba(0, 0, 0, .06), 0 16px 40px -8px rgba(0, 0, 0, .18), 0 4px 10px -4px rgba(0, 0, 0, .08);
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --rail-w: 248px;
  --head-h: 60px;
  --tab-h: 58px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0e0e0e;
  --rail: #121212;
  --sunken: #131313;
  --hover: #1a1a1a;
  --active: #222221;
  --line: #1f1f1f;
  --line-2: #2a2a29;
  --line-3: #3a3a38;
  --tx: #ececea;
  --tx-2: #a3a3a0;
  --tx-3: #6f6f6c;
  --ink: #ececea;
  --on-ink: #0e0e0e;
  --red: #f2555a;
  --amber: #e2a336;
  --green: #4cc27a;
  --blue: #6a9cf5;
  --tint: 22%;
  --ring: 0 0 0 3px rgba(255, 255, 255, .08);
  --shadow-sm: none;
  --shadow-lg: 0 0 0 1px rgba(255, 255, 255, .07), 0 20px 50px -10px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* =========================================================
   Base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--tx);
  font: 400 14px/1.5 var(--font); letter-spacing: -0.006em;
  font-feature-settings: "ss01", "cv11"; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
a { color: inherit; }
svg { flex-shrink: 0; }
.ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ic.fill { fill: currentColor; stroke: none; }
.mono { font-family: var(--mono); font-feature-settings: normal; letter-spacing: 0; }
.t2 { color: var(--tx-2); }
.t3 { color: var(--tx-3); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.green { color: var(--green); }
.sm { font-size: 13px; }
.xs { font-size: 12px; }
.fw5 { font-weight: 500; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex-shrink: 0; display: inline-block; }
::selection { background: color-mix(in srgb, var(--blue) 25%, transparent); }

/* =========================================================
   App shell
   ========================================================= */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
body.auth .app, body.auth #tabbar { display: none; }

.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  background: var(--rail); border-right: 1px solid var(--line); padding: 12px 10px;
}
.acct { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; margin-bottom: 14px; }
.acct:hover { background: var(--hover); }
.avatar { width: 28px; height: 28px; border-radius: 7px; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.acct b { display: block; font-weight: 600; font-size: 13px; line-height: 1.25; }
.acct small { display: block; color: var(--tx-3); font-size: 12px; line-height: 1.25; }
.nav-i {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border-radius: 7px; width: 100%; flex-shrink: 0;
  color: var(--tx-2); font-weight: 450; font-size: 13.5px;
}
.nav-i .ic { color: var(--tx-3); }
.nav-i:hover { background: var(--hover); color: var(--tx); }
.nav-i.on { background: var(--active); color: var(--tx); font-weight: 550; }
.nav-i.on .ic { color: var(--tx); }
.nav-i .n { margin-left: auto; font-size: 12px; color: var(--tx-3); font-family: var(--mono); }
.nav-i .n.alert { color: var(--red); }
.rail-h { font-size: 12px; color: var(--tx-3); font-weight: 500; padding: 18px 8px 6px; display: flex; align-items: center; }
.rail-subj .nav-i { height: 28px; font-size: 13px; }
.rail-foot { margin-top: auto; padding-top: 12px; }
.sync { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--tx-3); padding: 6px 8px; }
.sync i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.sync.saving i { background: var(--amber); }
.sync.offline i { background: var(--red); }

main { min-width: 0; }
.head {
  position: sticky; top: 0; z-index: 20; height: var(--head-h); display: flex; align-items: center; gap: 10px;
  padding: 0 28px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.head h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.015em; white-space: nowrap; }
.head h1 span { color: var(--tx-3); font-weight: 450; }
.head .sub { color: var(--tx-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.body { padding: 24px 28px 64px; max-width: 1280px; }
.body.flush { padding: 0; max-width: none; }

/* =========================================================
   Controls
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 7px;
  font-size: 13px; font-weight: 500; white-space: nowrap; color: var(--tx);
  background: var(--bg); border: 1px solid var(--line-2); box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); border-color: var(--line-3); }
.btn:active { transform: translateY(.5px); }
.btn.ink { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn.ink:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.btn.quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--tx-2); }
.btn.quiet:hover { background: var(--hover); color: var(--tx); }
.btn.danger { color: var(--red); }
.btn.lg { height: 40px; padding: 0 16px; font-size: 14px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn kbd { margin-left: 2px; }
.ibtn { width: 32px; height: 32px; border-radius: 7px; display: inline-grid; place-items: center; color: var(--tx-2); }
.ibtn:hover { background: var(--hover); color: var(--tx); }
.group { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; box-shadow: var(--shadow-sm); background: var(--bg); }
.group > button { height: 30px; padding: 0 10px; font-size: 13px; font-weight: 500; color: var(--tx-2); display: inline-flex; align-items: center; }
.group > button + button { border-left: 1px solid var(--line-2); }
.group > button:hover { background: var(--hover); color: var(--tx); }
.group > button.on { background: var(--active); color: var(--tx); }
.group > button:first-child { border-radius: 6px 0 0 6px; }
.group > button:last-child { border-radius: 0 6px 6px 0; }
kbd { font: 500 11px/1 var(--mono); color: var(--tx-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 2px 5px; background: var(--bg); }

.input, select.input, textarea.input {
  width: 100%; min-width: 0; height: 36px; padding: 0 11px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--bg);
  outline: none; transition: border-color .12s, box-shadow .12s; font-size: 14px;
}
textarea.input { height: auto; padding: 8px 11px; resize: vertical; line-height: 1.5; }
.input:hover { border-color: var(--line-3); }
.input:focus { border-color: var(--tx-3); box-shadow: var(--ring); }
.input::placeholder { color: var(--tx-3); }
select.input { padding-right: 8px; }
.label { display: block; font-size: 12.5px; font-weight: 500; color: var(--tx-2); margin: 16px 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--tx-2); cursor: pointer; margin-top: 16px; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--ink); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { height: 36px; padding: 0 10px; font-size: 13px; font-weight: 500; color: var(--tx-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--tx); }
.tabs button.on { color: var(--tx); border-color: var(--tx); }
.tabs button span { font-family: var(--mono); font-size: 11px; color: var(--tx-3); margin-left: 6px; }

/* =========================================================
   Lists
   ========================================================= */
.sect { margin-bottom: 28px; }
.sect-h { display: flex; align-items: baseline; gap: 10px; padding: 0 0 8px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600; }
.sect-h .meta { font-weight: 400; color: var(--tx-3); font-size: 12.5px; }
.sect-h .meta.red { color: var(--red); }
.grp { display: flex; align-items: center; gap: 8px; padding: 14px 0 6px; font-size: 12px; font-weight: 500; color: var(--tx-3); }
.grp .n { font-family: var(--mono); }
.grp.red { color: var(--red); }
.empty { padding: 28px 0; color: var(--tx-3); font-size: 13px; }

.sw { position: relative; overflow: hidden; }
.sw[data-dir="r"] { background: var(--green); }
.sw[data-dir="l"] { background: var(--red); }
.sw[data-dir]::before { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; font-size: 13px; font-weight: 500; }
.sw[data-dir="r"]::before { content: "Complete"; left: 14px; }
.sw[data-dir="l"]::before { content: "Delete"; right: 14px; }
.task {
  position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 9px 6px 9px 2px; border-bottom: 1px solid var(--line); background: var(--bg); touch-action: pan-y;
}
.task:hover { background: var(--sunken); }
.cb { width: 16px; height: 16px; margin: 2px 0 0 2px; border-radius: 50%; border: 1.5px solid var(--line-3); display: grid; place-items: center; color: transparent; transition: background .12s, border-color .12s; }
.cb:hover { border-color: var(--tx-2); }
.cb.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.cb svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.t-main { min-width: 0; cursor: pointer; }
.t-title { font-weight: 450; line-height: 1.4; word-break: break-word; }
.t-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; margin-top: 2px; font-size: 12.5px; color: var(--tx-3); }
.t-meta .s { display: inline-flex; align-items: center; gap: 6px; color: var(--tx-2); }
.t-meta .red { color: var(--red); }
.t-meta .amber { color: var(--amber); }
.flag { font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.flag.hi { color: var(--red); }
.flag.test { color: var(--blue); }
.task.done .t-title { color: var(--tx-3); text-decoration: line-through; text-decoration-color: var(--line-3); }
.t-side { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .12s; }
.task:hover .t-side { opacity: 1; }
.bar { display: inline-block; width: 36px; height: 3px; border-radius: 2px; background: var(--line-2); overflow: hidden; vertical-align: middle; margin-left: 4px; }
.bar i { display: block; height: 100%; background: var(--tx-2); }

/* =========================================================
   Today
   ========================================================= */
.today-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 380px; min-height: calc(100vh - var(--head-h)); }
.today-main { padding: 24px 32px 64px; min-width: 0; }
.today-side { border-left: 1px solid var(--line); background: var(--rail); padding: 20px 0 40px; min-width: 0; }
.today-side .side-h { padding: 0 20px 12px; display: flex; align-items: baseline; gap: 8px; }
.today-side .side-h b { font-size: 13px; font-weight: 600; }

.now { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; align-items: end; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.now-k { font-size: 12.5px; color: var(--tx-3); display: flex; align-items: center; gap: 8px; }
.now-k .live { width: 6px; height: 6px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 20%, transparent); }
.now-t { font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -0.025em; display: flex; align-items: center; gap: 10px; }
.now-t .dot { width: 10px; height: 10px; border-radius: 3px; }
.now-r { text-align: right; font-size: 12.5px; color: var(--tx-3); }
.now-r b { display: block; font-size: 15px; font-weight: 500; color: var(--tx); font-family: var(--mono); letter-spacing: -0.02em; }
.now-p { grid-column: 1 / -1; height: 2px; background: var(--line); margin-top: 12px; border-radius: 2px; overflow: hidden; }
.now-p i { display: block; height: 100%; background: var(--tx); }

.cmd { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 9px; box-shadow: var(--shadow-sm); margin-bottom: 4px; transition: border-color .12s, box-shadow .12s; }
.cmd:focus-within { border-color: var(--tx-3); box-shadow: var(--ring); }
.cmd .ic { color: var(--tx-3); }
.cmd input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 100%; font-size: 14px; }
.cmd input::placeholder { color: var(--tx-3); }
.parse { display: flex; flex-wrap: wrap; gap: 4px 16px; min-height: 20px; padding: 4px 2px 0; font-size: 12.5px; color: var(--tx-3); }
.parse b { color: var(--tx); font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 10px; margin: 20px 0 28px; }
.stat { padding: 12px 16px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat span { font-size: 12px; color: var(--tx-3); }
.stat b { display: block; font: 500 20px/1.3 var(--mono); letter-spacing: -0.03em; margin-top: 2px; }
.stat b.red { color: var(--red); }

.dl { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px 12px; font-size: 13px; padding: 0 20px; }
.dl dt { color: var(--tx-3); }
.dl dd { margin: 0; }

/* =========================================================
   Time grid (day / week)
   ========================================================= */
.tg { --hour: 56px; position: relative; }
.tg-head { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(0, 1fr)); position: sticky; top: var(--head-h); z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.tg-head > div { padding: 10px 10px 8px; display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; color: var(--tx-3); }
.tg-head > div + div { border-left: 1px solid var(--line); }
.tg-head b { font-size: 20px; font-weight: 500; color: var(--tx); letter-spacing: -0.03em; font-family: var(--mono); }
.tg-head .today b { background: var(--red); color: #fff; border-radius: 6px; padding: 0 6px; }
.tg-head .today { color: var(--red); }
.tg-body { display: grid; grid-template-columns: 56px minmax(0, 1fr); position: relative; }
.tg-gut { position: relative; }
.tg-gut span { position: absolute; right: 10px; transform: translateY(-50%); font: 11px var(--mono); color: var(--tx-3); }
.tg-cols {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); position: relative;
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px); background-size: 100% var(--hour);
}
.tg-col { position: relative; border-left: 1px solid var(--line); }
.tg-col.off { background: repeating-linear-gradient(-45deg, transparent 0 7px, var(--sunken) 7px 8px); }
.tg-off { position: absolute; top: 10px; left: 10px; right: 10px; font-size: 12px; color: var(--tx-3); }
.ev {
  position: absolute; left: 3px; right: 4px; padding: 4px 8px 4px 9px; border-radius: 6px; overflow: hidden; text-align: left;
  background: color-mix(in srgb, var(--c) var(--tint), var(--bg)); color: color-mix(in srgb, var(--c) 72%, var(--tx));
  box-shadow: inset 3px 0 0 var(--c); display: flex; flex-direction: column; gap: 0; font-size: 12px; line-height: 1.3;
  transition: filter .12s;
}
button.ev:hover { filter: brightness(.97) saturate(1.1); }
[data-theme="dark"] button.ev:hover { filter: brightness(1.15); }
.ev-t { font-weight: 600; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-m { opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
.ev-n { margin-left: auto; font: 600 10.5px/16px var(--mono); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 4px; background: var(--c); color: #fff; text-align: center; }
.ev.past { opacity: .55; }
.ev.tight { padding: 3px 8px 3px 9px; justify-content: center; }
.ev.tight .ev-m { display: none; }
.ev.fs { --c: var(--tx-2); background: var(--sunken); color: var(--tx-2); box-shadow: inset 3px 0 0 var(--line-3); }
.ev.fs.past { opacity: 1; }
.tg-now { position: absolute; left: -1px; right: 0; height: 2px; background: var(--red); z-index: 3; pointer-events: none; }
.tg-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

.daypick { display: none; }

/* month */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.month .dow { padding: 8px 10px; font-size: 12px; color: var(--tx-3); border-bottom: 1px solid var(--line); }
.md { min-height: 112px; padding: 6px 8px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; min-width: 0; text-align: left; }
.md:nth-child(7n + 1) { border-left: 0; }
.md:hover { background: var(--sunken); }
.md .d { font: 500 12.5px/22px var(--mono); width: 24px; height: 22px; text-align: center; border-radius: 5px; margin-bottom: 2px; }
.md.o { color: var(--tx-3); }
.md.o .d { color: var(--tx-3); }
.md.off { background: repeating-linear-gradient(-45deg, transparent 0 7px, var(--sunken) 7px 8px); }
.md.today .d { background: var(--red); color: #fff; }
.md.sel { box-shadow: inset 0 0 0 1.5px var(--tx); }
.md .e { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--tx-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md .e.done { color: var(--tx-3); text-decoration: line-through; }
.md .more { font-size: 11.5px; color: var(--tx-3); }
.md .dots { display: none; gap: 3px; }
.md .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c); }
.month-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.month-side { border-left: 1px solid var(--line); padding: 20px 0; background: var(--rail); }

/* lessons list (agenda) */
.lsn { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 20px; cursor: pointer; }
.lsn:hover { background: var(--hover); }
.lsn .tm { font: 12px var(--mono); color: var(--tx-3); line-height: 1.3; }
.lsn .nm { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lsn .nm b { font-weight: 500; }
.lsn .nm small { color: var(--tx-3); font-size: 12px; }
.lsn.past { opacity: .5; }
.lsn .due { font-size: 12px; color: var(--amber); }

/* =========================================================
   Focus
   ========================================================= */
.focus { display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: calc(100vh - var(--head-h)); }
.focus-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 28px; gap: 26px; }
.focus-side { border-left: 1px solid var(--line); background: var(--rail); padding: 20px 0; }
.clock-k { font-size: 12.5px; color: var(--tx-3); text-align: center; }
.clock { font: 300 clamp(72px, 13vw, 132px)/1 var(--mono); letter-spacing: -0.06em; text-align: center; }
.clock-task { font-size: 14px; color: var(--tx-2); text-align: center; max-width: 520px; }
.clock-bar { width: min(520px, 100%); height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.clock-bar i { display: block; height: 100%; background: var(--tx); transition: width .5s linear; }
.clock-ctl { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.focus-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(520px, 100%); }
.cyc { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.cyc i { width: 18px; height: 3px; border-radius: 2px; background: var(--line-2); }
.cyc i.on { background: var(--tx); }
.spark { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 96px; padding: 4px 20px 0; }
.spark div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; font: 11px var(--mono); color: var(--tx-3); }
.spark i { width: 100%; max-width: 22px; border-radius: 3px; background: var(--line-2); min-height: 2px; }
.spark .t i { background: var(--tx); }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding: 7px 20px; font-size: 13px; align-items: center; }
.kv b { font: 500 12.5px var(--mono); }
.side-sect { padding: 0 0 20px; }
.side-sect + .side-sect { border-top: 1px solid var(--line); padding-top: 16px; }
.side-sect h3 { margin: 0 0 8px; padding: 0 20px; font-size: 12.5px; font-weight: 500; color: var(--tx-3); display: flex; }

/* =========================================================
   Grades
   ========================================================= */
.summary { display: flex; gap: 40px; align-items: flex-end; flex-wrap: wrap; padding-bottom: 24px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.summary span { display: block; font-size: 12.5px; color: var(--tx-3); }
.summary b { display: block; font: 500 34px/1.1 var(--mono); letter-spacing: -0.04em; margin-top: 4px; }
.summary b.mid { font-size: 18px; font-family: var(--font); letter-spacing: -0.01em; margin-top: 10px; }
.gt { width: 100%; border-collapse: collapse; }
.gt th { text-align: left; font-size: 12px; font-weight: 500; color: var(--tx-3); padding: 10px 8px; border-bottom: 1px solid var(--line); }
.gt td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.gt tr:hover td { background: var(--sunken); }
.gt .num { text-align: right; font-family: var(--mono); }
.gs { display: flex; flex-wrap: wrap; gap: 4px 10px; font: 500 14px var(--mono); }
.gs button { color: var(--g); padding: 0 1px; border-radius: 3px; }
.gs button:hover { background: var(--hover); }
.gavg { font: 500 15px var(--mono); }
.gpick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 18px; }
.gpick button { height: 52px; border-radius: 8px; border: 1px solid var(--line-2); font: 500 22px var(--mono); color: var(--g); box-shadow: var(--shadow-sm); }
.gpick button:hover, .gpick button.on { border-color: var(--g); background: color-mix(in srgb, var(--g) 8%, var(--bg)); }

/* =========================================================
   Videos
   ========================================================= */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.vcard { text-align: left; min-width: 0; }
.vthumb { position: relative; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: var(--sunken); border: 1px solid var(--line); }
.vthumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.vthumb .play { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .15s; background: rgba(0, 0, 0, .25); color: #fff; }
.vcard:hover .play { opacity: 1; }
.vcard b { display: block; font-weight: 500; margin-top: 10px; }
.vcard small { color: var(--tx-3); font-size: 12.5px; }
.upl { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.upl .bar { width: 160px; height: 4px; }
.upl .bar i { background: var(--tx); transition: width .2s; }
.drop { border: 1px dashed var(--line-3); border-radius: 10px; padding: 36px 20px; text-align: center; color: var(--tx-3); font-size: 13px; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--tx); background: var(--sunken); }
.player { width: 100%; max-height: 64vh; border-radius: 8px; background: #000; display: block; }

/* =========================================================
   Assistant
   ========================================================= */
.chat { display: flex; flex-direction: column; height: calc(100vh - var(--head-h)); }
.msgs { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.msgs-in { max-width: 720px; margin: 0 auto; padding: 28px 28px 20px; display: flex; flex-direction: column; gap: 22px; }
.m-u { align-self: flex-end; max-width: 80%; padding: 9px 14px; border-radius: 14px 14px 4px 14px; background: var(--active); white-space: pre-wrap; word-break: break-word; }
.m-a { line-height: 1.65; word-break: break-word; }
.m-a p { margin: 0 0 10px; }
.m-a p:last-child { margin-bottom: 0; }
.m-a ul, .m-a ol { margin: 0 0 10px; padding-left: 20px; }
.m-a li { margin: 3px 0; }
.m-a h4 { margin: 16px 0 6px; font-size: 14px; font-weight: 600; }
.m-a code { font: 12.5px var(--mono); background: var(--sunken); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
.m-a pre { background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.m-a pre code { border: 0; padding: 0; background: none; }
.m-a table { border-collapse: collapse; margin: 6px 0 12px; font-size: 13px; display: block; overflow-x: auto; }
.m-a th, .m-a td { border-bottom: 1px solid var(--line); padding: 6px 14px 6px 0; text-align: left; }
.m-a th { font-weight: 500; color: var(--tx-3); }
.m-act { align-self: flex-start; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--tx-2); padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; }
.m-act .ic { color: var(--green); width: 14px; height: 14px; }
.m-err { font-size: 13px; color: var(--red); display: flex; align-items: center; gap: 10px; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--tx-3); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .2; } }
.intro { padding: 12vh 0 0; }
.intro h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.intro p { margin: 0; color: var(--tx-2); }
.prompts { margin-top: 24px; border-top: 1px solid var(--line); }
.prompts button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); color: var(--tx-2); font-size: 13.5px; }
.prompts button:hover { color: var(--tx); }
.prompts .ic { color: var(--tx-3); margin-left: auto; }
.composer-w { padding: 0 28px 20px; }
.composer { max-width: 720px; margin: 0 auto; border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-sm); background: var(--bg); padding: 10px 10px 10px 14px; display: flex; gap: 10px; align-items: flex-end; }
.composer:focus-within { border-color: var(--tx-3); box-shadow: var(--ring); }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; min-height: 24px; max-height: 180px; line-height: 1.5; padding: 3px 0; font-size: 14px; }
.composer .btn { width: 32px; padding: 0; }
.composer-note { max-width: 720px; margin: 8px auto 0; font-size: 11.5px; color: var(--tx-3); text-align: center; }
.setup { max-width: 520px; padding: 40px 28px; }
.setup h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.setup ol { margin: 16px 0 0; padding-left: 18px; color: var(--tx-2); }
.setup li { margin: 6px 0; }

/* =========================================================
   Auth
   ========================================================= */
#auth { display: none; }
body.auth #auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); min-height: 100vh; }
.auth-l { display: flex; flex-direction: column; padding: 28px 40px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.auth-form { width: min(360px, 100%); margin: auto; padding: 40px 0; }
.auth-form h1 { margin: 0 0 6px; font-size: 24px; font-weight: 600; letter-spacing: -0.025em; }
.auth-form p.lead { margin: 0 0 24px; color: var(--tx-2); }
.auth-form .label { margin-top: 14px; }
.auth-form .btn { margin-top: 22px; }
.auth-err { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 12px; }
.auth-alt { margin-top: 20px; font-size: 13px; color: var(--tx-2); }
.auth-alt button { color: var(--tx); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-3); }
.auth-foot { font-size: 12px; color: var(--tx-3); }
.auth-r { background: var(--sunken); border-left: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; padding: 48px; overflow: hidden; }
.auth-r h2 { margin: 0 0 8px; font-size: 22px; font-weight: 600; letter-spacing: -0.025em; max-width: 440px; line-height: 1.25; }
.auth-r p { margin: 0 0 28px; color: var(--tx-2); max-width: 440px; }
.preview { border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg); box-shadow: var(--shadow-lg); overflow: hidden; max-width: 640px; pointer-events: none; }
.preview .tg { --hour: 34px; }
.preview .tg-head { position: static; }
.preview .tg-head b { font-size: 15px; }
.preview .ev-m { display: none; }

/* =========================================================
   Overlays
   ========================================================= */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .32); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; animation: fade .12s ease; }
[data-theme="dark"] .overlay { background: rgba(0, 0, 0, .6); }
.dialog { width: min(520px, 100%); max-height: 78vh; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); border-radius: 12px; box-shadow: var(--shadow-lg); animation: pop .14s ease; }
.dialog.wide { width: min(760px, 100%); }
.d-h { display: flex; align-items: center; gap: 8px; padding: 14px 16px 0 20px; }
.d-h h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.d-b { padding: 4px 20px 20px; }
.d-f { display: flex; align-items: center; gap: 8px; padding: 12px 16px 12px 20px; border-top: 1px solid var(--line); background: var(--rail); border-radius: 0 0 12px 12px; position: sticky; bottom: 0; }
.title-in { border: 0 !important; box-shadow: none !important; padding: 0 !important; height: 44px !important; font-size: 18px !important; font-weight: 500; letter-spacing: -0.015em; }
.hint { font-size: 12.5px; color: var(--tx-3); margin-top: 8px; min-height: 18px; }
.hint b { color: var(--tx); font-weight: 500; }
.steps { display: flex; flex-direction: column; gap: 4px; }
.step { display: flex; gap: 8px; align-items: center; }
.step input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ink); flex-shrink: 0; }
.step .input { height: 32px; }
.set-sect { padding: 16px 0 4px; border-top: 1px solid var(--line); margin-top: 16px; }
.set-sect:first-child { border-top: 0; margin-top: 0; padding-top: 8px; }
.set-sect h3 { margin: 0; font-size: 13px; font-weight: 600; }
.set-sect p { margin: 2px 0 0; font-size: 12.5px; color: var(--tx-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-2); font-size: 12px; color: var(--tx-2); }
.chip:hover { border-color: var(--line-3); color: var(--tx); }
.menu { padding: 6px; }
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; height: 44px; padding: 0 12px; border-radius: 8px; font-size: 15px; }
.menu button:hover { background: var(--hover); }
.menu .ic { width: 18px; height: 18px; color: var(--tx-3); }

#toasts { position: fixed; z-index: 70; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-radius: 9px; background: var(--ink); color: var(--on-ink); font-size: 13px; box-shadow: var(--shadow-lg); animation: pop .14s ease; }
.toast span { flex: 1; min-width: 0; }
.toast button { font-weight: 600; padding: 4px 8px; border-radius: 6px; opacity: .85; }
.toast button:hover { opacity: 1; background: color-mix(in srgb, var(--on-ink) 14%, transparent); }
.pill { position: fixed; z-index: 30; right: 20px; bottom: 20px; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--ink); color: var(--on-ink); font: 500 13px var(--mono); box-shadow: var(--shadow-lg); }
.pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.pill i.paused { background: var(--amber); }
body[data-view="focus"] .pill, body[data-view="assistant"] .pill { display: none; }
#tabbar { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.99); } }
@keyframes up { from { transform: translateY(100%); } }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1180px) {
  .today-wrap { grid-template-columns: minmax(0, 1fr) 320px; }
  .focus { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (min-width: 861px) { .m-only { display: none !important; } }
@media (max-width: 860px) {
  .d-only { display: none !important; }
  body { font-size: 15px; }
  .app { display: block; }
  .rail { display: none; }
  .head { padding: 0 16px; height: 54px; --head-h: 54px; }
  .head h1 { font-size: 17px; }
  .body { padding: 16px 16px calc(var(--tab-h) + 80px + env(safe-area-inset-bottom)); }
  .today-wrap, .focus, .month-wrap { display: block; }
  .today-main { padding: 16px; }
  .today-side, .focus-side, .month-side { border-left: 0; border-top: 1px solid var(--line); background: var(--bg); padding-bottom: calc(var(--tab-h) + 80px + env(safe-area-inset-bottom)); }
  .focus-main { padding: 28px 16px; min-height: 0; }
  .focus-opts { grid-template-columns: 1fr; }
  .now-t { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .t-side { opacity: 1; }
  .tg { --hour: 52px; }
  .tg-head { top: 54px; }
  .daypick { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); position: sticky; top: 54px; z-index: 6; background: var(--bg); }
  .daypick button { padding: 8px 0 10px; text-align: center; font-size: 11px; color: var(--tx-3); text-transform: uppercase; letter-spacing: .04em; position: relative; }
  .daypick b { display: block; font: 500 17px/1.4 var(--mono); color: var(--tx); letter-spacing: -0.02em; text-transform: none; }
  .daypick button.on b { background: var(--ink); color: var(--on-ink); border-radius: 7px; width: 34px; margin: 2px auto 0; }
  .daypick button.today:not(.on) b { color: var(--red); }
  .daypick button.has::after { content: ""; position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--amber); }
  .md { min-height: 56px; padding: 4px; align-items: center; }
  .md .e, .md .more { display: none; }
  .md .dots { display: flex; }
  .gt .hide-m { display: none; }
  .vgrid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .msgs-in { padding: 20px 16px; }
  .composer-w { padding: 0 12px 12px; }
  .chat { height: calc(100dvh - 54px - var(--tab-h) - env(safe-area-inset-bottom)); }
  .intro { padding-top: 4vh; }
  #tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-top: 1px solid var(--line);
  }
  #tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 500; color: var(--tx-3); position: relative; }
  #tabbar .ic { width: 22px; height: 22px; stroke-width: 1.5; }
  #tabbar button.on { color: var(--tx); }
  #tabbar button.on .ic { stroke-width: 1.9; }
  #tabbar .n { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff; font: 600 10px/16px var(--mono); }
  .fab {
    position: fixed; z-index: 35; right: 16px; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom));
    width: 52px; height: 52px; border-radius: 16px; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; box-shadow: var(--shadow-lg);
  }
  .fab .ic { width: 22px; height: 22px; stroke-width: 2; }
  body[data-view="assistant"] .fab, body[data-view="focus"] .fab, body[data-view="videos"] .fab, body[data-view="grades"] .fab { display: none; }
  .pill { left: 16px; right: auto; bottom: calc(var(--tab-h) + 20px + env(safe-area-inset-bottom)); }
  #toasts { left: 16px; right: 16px; width: auto; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); }
  .overlay { align-items: flex-end; padding: 0; }
  .dialog { width: 100%; max-height: 92dvh; border-radius: 14px 14px 0 0; animation: up .22s cubic-bezier(.2, .8, .2, 1); }
  .d-f { border-radius: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .input, select.input { height: 42px; font-size: 16px; }
  textarea.input, .composer textarea, .cmd input { font-size: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  body.auth #auth { display: block; }
  .auth-r { display: none; }
  .auth-l { min-height: 100dvh; padding: 20px; }
}
@media (min-width: 861px) { .fab { display: none; } }
