/* Gradevine — calm, legible, serious without feeling clinical. */
:root {
  color-scheme: dark;
  --bg: #1B1A17;
  --panel: #242320;
  --panel-2: #2B2A25;
  --text: #F3F0E8;
  --muted: #A6A198;
  --faint: #6E6A60;
  --accent: #9DBE8C;          /* sage-green actions */
  --accent-ink: #1E2A1A;
  --amber: #DFA93F;           /* attention */
  --red: #C4715F;             /* confirmed urgency only */
  --line: #35332C;
  --chip-bg: #2E2D27;
  --radius: 12px;
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #FAF7F1;
  --panel: #FFFFFF;
  --panel-2: #F3EFE6;
  --text: #22301F;
  --muted: #5F6B58;
  --faint: #8A937F;
  --accent: #4E7A45;
  --accent-ink: #FFFFFF;
  --amber: #9A6B14;
  --red: #A84A3A;
  --line: #E4DFD2;
  --chip-bg: #EFEAE0;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
.num { font-variant-numeric: tabular-nums; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 6px;
  max-width: 1100px; margin: 0 auto;
}
.app-logo { width: 36px; height: 36px; border-radius: 9px; }
.app-title { font-size: 20px; font-weight: 700; letter-spacing: 0.2px; flex: 1; }
.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--text);
  font-size: 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.freshness-strip {
  max-width: 1100px; margin: 0 auto;
  padding: 4px 16px 10px;
  font-size: 13px; color: var(--muted);
}
.freshness-strip strong { color: var(--text); font-weight: 600; }

/* Main view */
.view {
  max-width: 1100px; margin: 0 auto;
  padding: 12px 16px calc(96px + env(safe-area-inset-bottom));
}
.section-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  margin: 22px 0 10px;
}
.section-sub { font-size: 14px; color: var(--muted); margin: -6px 0 10px; }

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.card.tappable { cursor: pointer; }
.card.tappable:active { background: var(--panel-2); }

/* Attention banner */
.banner {
  background: var(--panel);
  border: 1px solid var(--amber);
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
  padding: 14px 16px; margin: 6px 0 4px;
}
.banner .banner-title { font-weight: 700; font-size: 16px; }
.banner .banner-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* Segmented toggle */
.seg {
  display: inline-flex; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px; margin: 4px 0 12px;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600; font-family: var(--font);
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  min-height: 40px;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* Feed */
.feed-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer; text-decoration: none; color: inherit;
}
.feed-item:active { background: var(--panel-2); }
.feed-item.assessment { border-left: 4px solid var(--accent); }
.feed-item .score {
  font-size: 22px; font-weight: 700; white-space: nowrap;
  font-variant-numeric: tabular-nums; min-width: 76px; text-align: right;
}
.feed-item .meta { flex: 1; min-width: 0; }
.feed-item .title { font-weight: 600; font-size: 15px; }
.feed-item .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.chip {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  background: var(--chip-bg); color: var(--muted);
  border-radius: 6px; padding: 2px 8px; margin-left: 6px;
  vertical-align: 1px; letter-spacing: 0.02em;
}
.chip.school { color: var(--accent); border: 1px solid var(--accent); background: transparent; }
.chip.groups { color: var(--amber); border: 1px solid var(--amber); background: transparent; }
.subject-group { margin-bottom: 18px; }
.subject-head {
  display: flex; align-items: baseline; gap: 8px;
  margin: 16px 0 8px; font-weight: 700; font-size: 15px;
}
.subject-head .grade { margin-left: auto; color: var(--muted); font-weight: 600; }

/* Awaiting / upcoming */
.await-row, .up-row {
  display: flex; gap: 10px; align-items: baseline;
  padding: 10px 2px; border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.await-row:last-child, .up-row:last-child { border-bottom: 0; }
.status-tag {
  font-size: 12px; font-weight: 700; color: var(--amber);
  white-space: nowrap;
}
.day-head {
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  margin: 14px 0 2px;
}
.day-head.overdue { color: var(--red); }
.up-time { color: var(--muted); font-size: 13px; white-space: nowrap; margin-left: auto; }
.overdue-label { color: var(--red); font-weight: 700; font-size: 13px; }
.footnote { font-size: 12.5px; color: var(--faint); margin-top: 10px; }
.empty-note {
  background: var(--panel); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  color: var(--muted); font-size: 14px; margin-bottom: 10px;
}

/* Trends */
.trend-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 600px) { .trend-grid { grid-template-columns: 1fr 1fr; } }
.trend-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  cursor: pointer; text-decoration: none; color: inherit;
  display: block;
}
.trend-card:active { background: var(--panel-2); }
.trend-card .course-name { font-weight: 700; font-size: 15px; }
.trend-card .pct { font-size: 34px; font-weight: 800; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.trend-card .na { font-size: 26px; font-weight: 700; color: var(--muted); margin: 6px 0 2px; }
.trend-card .sec { font-size: 13px; color: var(--muted); }
.honest-note {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px;
  font-size: 14px; color: var(--muted);
}
.honest-note strong { color: var(--text); }

/* Focus */
.focus-group-label {
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin: 20px 0 8px;
}
.focus-card { border-left: 4px solid var(--amber); cursor: pointer; }
.focus-card.confirmed { border-left-color: var(--red); }
.focus-card .f-title { font-weight: 700; font-size: 16px; }
.focus-card .f-evidence { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.focus-card .f-why { font-size: 14.5px; margin-top: 8px; }
.focus-card .f-starter { font-size: 14px; margin-top: 8px; color: var(--text); }
.focus-card .f-starter::before { content: "Ask about it: "; font-weight: 700; color: var(--muted); }
.conf-chip {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; margin-top: 10px;
}

/* Course detail */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; color: var(--accent);
  font-size: 15px; font-weight: 600; font-family: var(--font);
  cursor: pointer; padding: 8px 0; min-height: var(--tap);
}
.detail-head { margin: 4px 0 6px; }
.detail-head h1 { font-size: 24px; margin: 0 0 2px; }
.detail-head .sec { color: var(--muted); font-size: 14px; }
.detail-grade { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 8px 0 2px; }
.cat-row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: 14.5px;
}
.cat-row:last-child { border-bottom: 0; }
.cat-row .w { color: var(--muted); }
.assign-row {
  display: flex; gap: 10px; align-items: baseline;
  padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.assign-row:last-child { border-bottom: 0; }
.assign-row .t { flex: 1; min-width: 0; }
.assign-row .s { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.assign-row .d { display: block; font-size: 12.5px; color: var(--faint); }
.late-flag { color: var(--amber); font-size: 12.5px; font-weight: 700; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; min-height: 60px; justify-content: center;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tab .tab-glyph { font-size: 20px; line-height: 1; }
.tab[aria-current="page"] { color: var(--accent); }

.noscript { padding: 24px; text-align: center; color: var(--muted); }
.error-box {
  background: var(--panel); border: 1px solid var(--red);
  border-radius: var(--radius); padding: 18px; margin-top: 20px;
}
.offline-pill {
  display: inline-block; font-size: 12px; font-weight: 700; color: var(--amber);
  border: 1px solid var(--amber); border-radius: 999px; padding: 2px 10px; margin-left: 8px;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
