:root {
  --bg: #f7f7fb; --surface: #ffffff; --surface-2: #f1f2f7; --text: #0f172a; --muted: #667085; --line: #e6e8ef;
  --zeus: #0080bb; --zeus-soft: #e3f4fc; --emn: #d90016; --emn-soft: #fde8ea; --emn-navy: #0b2c6f;
  --accent: #111827; --on-accent: #ffffff; --ok: #12805c; --warn: #b54708; --danger: #c01c28;
  --radius: 16px; --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c111d; --surface: #151b2b; --surface-2: #1d2436; --text: #eef0f6; --muted: #98a2b3; --line: #262f45;
    --zeus: #3fb6ec; --zeus-soft: #0f2d3f; --emn: #ff5a68; --emn-soft: #3a1418; --emn-navy: #9db4ff;
    --accent: #eef0f6; --on-accent: #0c111d; --ok: #47cd89; --warn: #fdb022; --danger: #ff6b6b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.01em; }
.muted { color: var(--muted); margin: 0 0 16px; font-size: 15px; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 14px; }

/* Buttons & inputs (44px+ touch targets) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; font-weight: 600; cursor: pointer; text-align: center; }
.btn:active { transform: scale(.98); }
a.btn { text-decoration: none; color: inherit; }
a.btn.primary { color: var(--on-accent); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; margin-top: 12px; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn:disabled { opacity: .55; }
input { width: 100%; font: inherit; font-size: 16px; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); }
input:focus { outline: 2px solid var(--zeus); outline-offset: 1px; border-color: transparent; }
label { display: block; font-size: 14px; font-weight: 600; margin: 8px 0 6px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pill-btn { min-height: 36px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer; }

/* Login / onboarding */
.screen.center { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b)); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px 22px; }
.panel.narrow { width: 100%; max-width: 420px; }
.brand-logos { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.brand-logos img { height: 57px; width: auto; display: block; }
.brand-logos img.emn { border-radius: 12px; }
.brand-logos span { color: var(--muted); font-size: 22px; font-weight: 300; }
.brand-logos.small { gap: 10px; margin-bottom: 16px; }
.brand-logos.small img { height: 40px; }
.brand-logos.small img.emn { border-radius: 9px; }
.logo-img { display: block; height: 20px; width: auto; flex: none; }
.logo-img.emn { width: 20px; border-radius: 5px; }
.logo-img.lg { height: 40px; }
.logo-img.emn.lg { width: 40px; border-radius: 9px; }
.sheet-school { display: flex; align-items: center; gap: 12px; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-row .status-dot { margin-right: -2px; }
.group-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.group-btn { aspect-ratio: 1; min-height: 56px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); font-size: 20px; font-weight: 700; cursor: pointer; display: grid; place-items: center; }
.group-btn small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: -6px; }
.group-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.group-btn[aria-pressed="true"] small { color: inherit; opacity: .7; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px); padding: calc(8px + var(--safe-t)) 12px 8px; border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; max-width: 1200px; margin: 0 auto; padding: 0 4px; }
.month { border: 0; background: none; font-size: 22px; font-weight: 750; letter-spacing: -.02em; padding: 4px 0; cursor: pointer; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.week-strip { display: flex; align-items: center; gap: 2px; max-width: 1200px; margin: 6px auto 0; }
.nav-arrow { width: 32px; height: 56px; border: 0; background: none; color: var(--muted); font-size: 26px; cursor: pointer; border-radius: 10px; flex: none; }
.days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day-chip { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 7px; border: 0; border-radius: 14px; background: transparent; cursor: pointer; min-height: 56px; }
.day-chip .dow { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.day-chip .num { font-size: 18px; font-weight: 700; width: 34px; height: 30px; display: grid; place-items: center; border-radius: 10px; }
.day-chip .dots { display: flex; gap: 3px; height: 5px; }
.day-chip .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--zeus); }
.day-chip .dots i.emn { background: var(--emn); }
.day-chip.today .num { color: var(--zeus); }
.day-chip[aria-selected="true"] { background: var(--accent); }
.day-chip[aria-selected="true"] .dow, .day-chip[aria-selected="true"] .num { color: var(--on-accent); }
.week-mode .day-chip[aria-selected="true"] { background: transparent; }
.week-mode .day-chip[aria-selected="true"] .dow { color: var(--muted); }
.week-mode .day-chip[aria-selected="true"] .num { color: inherit; }
.week-mode .day-chip.today .num { color: var(--zeus); }

.banner { max-width: 720px; margin: 12px auto 0; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); color: var(--text); font-size: 14px; width: calc(100% - 32px); }

/* Views */
.view { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--tab-h) + var(--safe-b) + 24px); touch-action: pan-y; }
.view.wide { max-width: 1200px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 4px 2px 14px; }
.day-head h2 { font-size: 20px; }
.day-head .sum { color: var(--muted); font-size: 14px; white-space: nowrap; }
.list { display: grid; gap: 10px; }

.card { position: relative; display: grid; grid-template-columns: 58px 1fr; gap: 12px; width: 100%; text-align: left; padding: 14px 14px 14px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer; overflow: hidden; }
.card:active { transform: scale(.99); }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--zeus); }
.card.emn::before { background: var(--emn); }
.card .time { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; padding-left: 4px; }
.card .time b { font-size: 16px; }
.card .time span { color: var(--muted); font-size: 14px; }
.card .body { min-width: 0; }
.card .school { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-height: 20px; font-size: 12px; font-weight: 700; color: var(--zeus); text-transform: uppercase; letter-spacing: .04em; }
.card.emn .school { color: var(--emn); }
.card .title { font-size: 17px; font-weight: 650; line-height: 1.25; margin: 2px 0 4px; overflow-wrap: anywhere; }
.card .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 14px; }
.card .meta span { display: inline-flex; align-items: center; gap: 4px; }
.card .meta svg { width: 14px; height: 14px; flex: none; }
.card.past { opacity: .55; }
.card.hidden-ev { opacity: .45; border-style: dashed; }
.card .tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); text-transform: none; letter-spacing: 0; }
.card.now { border-color: color-mix(in srgb, var(--zeus) 50%, var(--line)); box-shadow: 0 6px 20px -10px color-mix(in srgb, var(--zeus) 60%, transparent); }
.card.emn.now { border-color: color-mix(in srgb, var(--emn) 50%, var(--line)); box-shadow: 0 6px 20px -10px color-mix(in srgb, var(--emn) 60%, transparent); }
.card .now-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--ok); color: #fff; letter-spacing: .04em; text-transform: uppercase; }
.card .progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--ok); }
.gap { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; padding: 0 6px; }
.gap::before, .gap::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 6px; }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 4px; }
.skeleton { height: 86px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Week view */
.week { display: grid; gap: 22px; }
.week-day h3 { display: flex; align-items: baseline; gap: 8px; font-size: 15px; margin: 0 2px 8px; }
.week-day h3 small { color: var(--muted); font-weight: 500; }
.week-day.is-today h3 { color: var(--zeus); }
.week-day .none { color: var(--muted); font-size: 14px; padding: 10px 4px; }
.week .card { grid-template-columns: 50px 1fr; padding: 11px 12px 11px 10px; }
.week .card .title { font-size: 15px; }
.week .card .time b { font-size: 14px; } .week .card .time span { font-size: 13px; }
@media (min-width: 960px) {
  .week { grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); gap: 12px; align-items: start; }
  .week .card { grid-template-columns: 1fr; gap: 4px; }
  .week .card .time { flex-direction: row; gap: 4px; }
  .week .card .time span::before { content: "– "; }
}

/* Me / settings */
.section { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px 16px; margin-bottom: 14px; }
.section h2 { font-size: 17px; margin-bottom: 2px; }
.section .muted { font-size: 14px; margin-bottom: 14px; }
.group-grid.small { grid-template-columns: repeat(6, 1fr); gap: 8px; }
.group-grid.small .group-btn { aspect-ratio: auto; min-height: 48px; font-size: 17px; border-radius: 13px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-size: 14px; color: var(--muted); }
.rows { display: grid; }
.rowi { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-height: 56px; }
.rowi:first-child { border-top: 0; }
.rowi .t { min-width: 0; overflow-wrap: anywhere; }
.rowi small { display: block; color: var(--muted); font-size: 13px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--zeus); outline-offset: 2px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.status-dot.warn { background: var(--warn); }
details.help summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 10px 0 2px; color: var(--zeus); list-style: none; }
details.help summary::-webkit-details-marker { display: none; }
details.help ol { margin: 8px 0 0; padding-left: 20px; font-size: 14px; color: var(--muted); }
details.help li { margin: 4px 0; }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(3, 1fr); height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px); border-top: 1px solid var(--line); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"] svg { stroke-width: 2.3; }
@media (min-width: 960px) {
  .tabbar { left: 50%; right: auto; bottom: 16px; transform: translateX(-50%); width: 360px; height: 60px; padding: 0; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 10px 30px -12px rgb(0 0 0 / .25); }
}

/* Bottom sheet */
.sheet { margin: auto auto 0; width: 100%; max-width: 560px; max-height: 88dvh; border: 0; border-radius: 24px 24px 0 0; padding: 8px 20px calc(20px + var(--safe-b)); background: var(--surface); color: var(--text); overflow: auto; }
.sheet[open] { animation: up .22s cubic-bezier(.2, .9, .3, 1); }
.sheet::backdrop { background: rgb(8 12 22 / .45); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 640px) { .sheet { margin: auto; border-radius: 24px; } }
.grabber { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 4px auto 14px; }
.sheet .pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; }
.pill.zeus { background: var(--zeus-soft); color: var(--zeus); } .pill.emn { background: var(--emn-soft); color: var(--emn); }
.sheet h2 { font-size: 22px; margin: 10px 0 14px; overflow-wrap: anywhere; }
.facts { display: grid; gap: 12px; margin: 0 0 16px; }
.fact { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; font-size: 16px; }
.fact svg { width: 20px; height: 20px; color: var(--muted); margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fact small { display: block; color: var(--muted); font-size: 13px; }
.desc { white-space: pre-wrap; font-size: 14px; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin: 0 0 16px; max-height: 160px; overflow: auto; }
.note { font-size: 14px; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.actions { display: grid; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); transform: translateX(-50%); background: var(--accent); color: var(--on-accent); padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 500; z-index: 20; max-width: calc(100vw - 32px); display: flex; gap: 14px; align-items: center; box-shadow: 0 10px 30px -10px rgb(0 0 0 / .4); }
.toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 4px; }

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