[hidden] { display: none !important; }
:root {
  color-scheme: light;
  --bg: #f8f7fb;
  --surface: #ffffff;
  --surface-2: #f0eef5;
  --surface-3: #e9e6ef;
  --text: #26232d;
  --muted: #77717f;
  --line: #e7e3eb;
  --accent: #5a4f7c;
  --accent-soft: #ece8f7;
  --accent-strong: #3c335a;
  --success: #4f7a63;
  --shadow: 0 12px 35px rgba(42, 35, 57, .08);
  --reader-size: 1rem;
  --radius-lg: 26px;
  --radius-md: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111014;
  --surface: #1a181e;
  --surface-2: #232129;
  --surface-3: #2c2933;
  --text: #f4f0f7;
  --muted: #aaa4b2;
  --line: #302d36;
  --accent: #b9addb;
  --accent-soft: #2c2740;
  --accent-strong: #ddd5f4;
  --success: #88b89b;
  --shadow: 0 16px 36px rgba(0, 0, 0, .26);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100dvh; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: calc(72px + var(--safe-top));
  padding: calc(14px + var(--safe-top)) 18px 12px;
  background: color-mix(in srgb, var(--bg) 89%, transparent);
  backdrop-filter: blur(18px) saturate(130%);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  transition: transform .25s ease, opacity .25s ease;
}
.header-copy { min-width: 0; flex: 1; }
.eyebrow { display: block; font-size: .67rem; letter-spacing: .14em; font-weight: 800; color: var(--muted); }
.app-header h1, .sheet-heading h2 { margin: 2px 0 0; font-size: 1.22rem; line-height: 1.15; }
.header-actions { display: flex; gap: 6px; }
.icon-button {
  width: 42px; height: 42px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text);
  font-size: 1.24rem; cursor: pointer;
}
.icon-button:active { transform: scale(.96); }

main { width: min(100%, 860px); margin: 0 auto; }
.view { padding: 20px 16px calc(30px + var(--safe-bottom)); }
.week-hero {
  margin: 4px 0 28px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--accent-soft) 44%, var(--surface)));
  box-shadow: var(--shadow);
}
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 7px; }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 12%, transparent); }
.status-dot.warn { background: #b28046; }
.status-label { font-size: .78rem; color: var(--muted); font-weight: 700; }
.week-hero h2 { margin: 20px 0 5px; font-size: clamp(1.75rem, 7vw, 2.6rem); letter-spacing: -.035em; line-height: 1.06; }
.week-hero p { margin: 0; color: var(--muted); line-height: 1.55; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.primary-button, .secondary-button, .tool-button, .plain-action {
  border: 0; cursor: pointer; border-radius: 14px; font-weight: 750;
}
.primary-button { padding: 12px 16px; color: #fff; background: var(--accent-strong); }
html[data-theme="dark"] .primary-button { color: #18141f; }
.secondary-button { padding: 12px 16px; color: var(--accent-strong); background: var(--accent-soft); }

.meeting-group { margin: 0 0 30px; }
.group-heading { display: flex; align-items: center; gap: 12px; margin: 0 4px 11px; color: var(--muted); font-size: .69rem; font-weight: 850; letter-spacing: .13em; }
.group-line { height: 1px; flex: 1; background: var(--line); }
.card-grid { display: grid; gap: 10px; }
.section-card {
  width: 100%; min-height: 88px; padding: 14px 16px;
  display: grid; grid-template-columns: 54px 1fr 22px; align-items: center; gap: 13px;
  text-align: left; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); cursor: pointer;
  box-shadow: 0 5px 18px rgba(28, 24, 36, .025);
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.section-card:active { transform: scale(.985); }
.section-card:hover { border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); }
.section-card.feature { background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--accent-soft) 40%, var(--surface))); }
.card-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 16px; background: var(--surface-2); font-size: 1.35rem; color: var(--accent-strong); }
.card-copy { min-width: 0; }
.card-copy strong { display: block; font-size: 1rem; }
.card-copy small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .78rem; }
.chevron { justify-self: end; color: var(--muted); font-size: 1.6rem; font-weight: 300; }

.offline-note {
  margin: 8px 0 0; padding: 14px 16px; display: flex; gap: 12px; align-items: center;
  border-radius: 16px; background: var(--surface-2); color: var(--muted);
}
.offline-note > span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); font-weight: 900; }
.offline-note strong { display: block; color: var(--text); font-size: .86rem; }
.offline-note small { display: block; margin-top: 2px; line-height: 1.4; }

.reader-view { padding-top: 0; }
.reader-toolbar {
  position: sticky; top: calc(72px + var(--safe-top)); z-index: 25;
  margin: 0 -16px; padding: 8px 16px;
  background: color-mix(in srgb, var(--bg) 91%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); transition: transform .25s ease, opacity .25s ease;
}
.reader-toolbar-row { display: flex; align-items: center; gap: 8px; max-width: 760px; margin: 0 auto; }
.tool-button { padding: 9px 12px; color: var(--text); background: var(--surface-2); }
.font-value { min-width: 48px; text-align: center; color: var(--muted); font-size: .78rem; font-weight: 700; }
.toolbar-spacer { flex: 1; }
.reader-shell { max-width: 740px; margin: 0 auto; padding: 28px 2px 80px; font-size: var(--reader-size); }
.reader-kicker { color: var(--accent); font-weight: 850; font-size: .73em; letter-spacing: .12em; text-transform: uppercase; }
.reader-title { margin: 7px 0 10px; font-size: clamp(1.72rem, calc(var(--reader-size) * 2), 2.6rem); line-height: 1.12; letter-spacing: -.035em; }
.reader-source { display: none !important; align-items: center; gap: 7px; margin: 3px 0 26px; padding: 7px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .72em; font-weight: 750; text-decoration: none; }
.reader-article + .reader-article { margin-top: 34px; padding-top: 30px; border-top: 1px solid var(--line); }
.reader-article-title { margin: 0 0 20px; font-size: 1.16em; line-height: 1.35; color: var(--text); }

.assignment-intro { margin-bottom: 20px; }
.assignment-intro h2 { margin: 7px 0 8px; font-size: clamp(1.35rem, calc(var(--reader-size) * 1.55), 2rem); line-height: 1.16; letter-spacing: -.025em; }
.assignment-intro p { margin: 0; color: var(--muted); line-height: 1.55; font-size: .9em; }
.assignment-list { display: grid; gap: 10px; }
.assignment-item { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); transition: border-color .18s ease, background .18s ease; }
.assignment-item.open { border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); }
.assignment-toggle { width: 100%; min-height: 72px; padding: 14px 15px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.assignment-toggle-copy { min-width: 0; display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 10px; }
.assignment-number { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--surface-2); color: var(--accent-strong); font-size: .72rem; font-weight: 850; letter-spacing: .04em; }
.assignment-label { font-size: .96em; font-weight: 800; line-height: 1.35; }
.assignment-chevron { flex: 0 0 auto; color: var(--muted); font-size: 1.35rem; transform: rotate(0deg); transition: transform .18s ease; }
.assignment-toggle[aria-expanded="true"] .assignment-chevron { transform: rotate(180deg); }
.assignment-body { padding: 2px 16px 18px 59px; border-top: 1px solid var(--line); }
.assignment-body .reader-block:first-child { margin-top: 16px; }
.assignment-body .reader-block:last-child { margin-bottom: 0; }
@media (max-width: 480px) {
  .assignment-body { padding-left: 16px; }
}
.reader-block { margin: 0 0 1.18em; line-height: 1.72; letter-spacing: .002em; }
.reader-block.heading { margin-top: 2.15em; margin-bottom: .8em; color: var(--accent-strong); font-size: 1.04em; font-weight: 900; letter-spacing: .02em; }
.reader-block.question { margin-top: 1.55em; margin-bottom: .7em; font-weight: 800; line-height: 1.55; }
.reader-block.quote { padding: 14px 16px; border-left: 3px solid var(--accent); border-radius: 0 12px 12px 0; background: var(--surface-2); }
.reader-block.list { position: relative; padding-left: 1.25em; }
.reader-block.list::before { content: "•"; position: absolute; left: .25em; color: var(--accent); }
.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--text); }

.reader-reveal {
  position: fixed; right: 14px; top: calc(10px + var(--safe-top)); z-index: 70;
  width: 42px; height: 42px; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--surface) 82%, transparent); color: var(--text); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s ease; cursor: pointer;
}
body.immersive .app-header, body.immersive .reader-toolbar { transform: translateY(-140%); opacity: 0; pointer-events: none; }
body.immersive .reader-reveal { opacity: .22; pointer-events: auto; }
body.immersive .reader-reveal:hover, body.immersive .reader-reveal:focus { opacity: 1; }
body.immersive .reader-shell { padding-top: 18px; }

.settings-sheet { position: fixed; inset: 0; z-index: 90; visibility: hidden; }
.settings-sheet.open { visibility: visible; }
.sheet-backdrop { position: absolute; inset: 0; border: 0; background: rgba(15, 12, 20, .44); opacity: 0; transition: opacity .25s ease; }
.settings-sheet.open .sheet-backdrop { opacity: 1; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 84dvh; overflow: auto;
  padding: 10px 20px calc(22px + var(--safe-bottom));
  border-radius: 28px 28px 0 0; background: var(--surface); box-shadow: 0 -20px 60px rgba(0,0,0,.18);
  transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
}
.settings-sheet.open .sheet-panel { transform: translateY(0); }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 17px; border-radius: 999px; background: var(--surface-3); }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.setting-block { padding: 18px 0; border-top: 1px solid var(--line); }
.setting-block.compact { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.setting-label { display: block; margin-bottom: 10px; color: var(--muted); font-size: .77rem; font-weight: 800; }
.setting-block.compact .setting-label { margin: 0; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.segmented button { padding: 10px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 750; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 7px rgba(0,0,0,.07); }
.range-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.range-row input { width: 100%; accent-color: var(--accent); }
.large-a { font-size: 1.35rem; }
.plain-action { padding: 9px 12px; background: var(--surface-2); color: var(--text); }
.sheet-footnote { margin: 8px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.55; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); z-index: 120;
  max-width: calc(100vw - 32px); padding: 11px 15px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: .8rem; font-weight: 700; box-shadow: var(--shadow);
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none; transition: .25s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (min-width: 680px) {
  .view { padding-left: 28px; padding-right: 28px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .meeting-group:first-of-type .section-card:last-child { grid-column: span 2; }
  .sheet-panel { left: 50%; right: auto; width: min(520px, 100%); transform: translate(-50%, 105%); }
  .settings-sheet.open .sheet-panel { transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
