:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #15171c;
  --text-2: #4a4f5c;
  --muted: #7a8090;
  --line: #e6e8ee;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --warn: #c2410c;
  --warn-soft: #fff4ec;
  --ok: #15803d;
  --ok-soft: #ecfbf1;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 14px;
  font-family: "Inter", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --text: #eceef3;
    --text-2: #b7bcc8;
    --muted: #8a90a0;
    --line: #262a35;
    --accent: #8b87ff;
    --accent-soft: #23234a;
    --warn: #fb9a5c;
    --warn-soft: #2d1d12;
    --ok: #5fd38a;
    --ok-soft: #13271b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .9rem; }
p { margin: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: .65rem .85rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { line-height: 1.5; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; background: var(--accent); color: #fff; border: 0;
  border-radius: 10px; padding: .6rem 1.1rem; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: .3rem .7rem;
  cursor: pointer; color: var(--text-2); transition: background .15s; white-space: nowrap;
}
.ghost:hover { background: var(--surface-2); }
.inline { display: inline; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--warn); font-weight: 500; }
.count { color: var(--muted); font-size: .78rem; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- shell */
.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  padding: 1.25rem .85rem; background: var(--surface); border-right: 1px solid var(--line); overflow-x: hidden;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1rem; padding: 0 .5rem 1.25rem; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
}
.brand-mark.big { width: 48px; height: 48px; border-radius: 14px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem; border-radius: 9px;
  color: var(--text-2); font-weight: 500; transition: background .12s, color .12s;
}
.nav a svg { width: 17px; height: 17px; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-label { font-size: .72rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 1.5rem .6rem .5rem; }
.nav.courses a { font-weight: 450; }
.nav a { min-width: 0; }
.course-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 3px; background: var(--c); flex: none; margin: 0 4px; }
.logout { margin-top: auto; padding: 1rem .5rem 0; }
.pad { padding: 0 .6rem; }

.main { padding: 1.25rem 2.25rem 3rem; min-width: 0; max-width: 1280px; }
.topbar {
  display: flex; align-items: center; gap: .6rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 .9rem; margin-bottom: 1.75rem; box-shadow: var(--shadow); max-width: 640px;
}
.topbar svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.topbar input { border: 0; box-shadow: none; padding: .7rem 0; background: transparent; }

/* ---------- common blocks */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow); }
.columns { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 1.25rem; align-items: start; }
.stack-col { display: grid; gap: 1.25rem; }
/* Grid/flex children default to min-width: auto, so one long unbreakable string (a URL in an
   announcement) would widen the whole column past the screen. Let them shrink and wrap instead. */
.columns > *, .stack-col > *, .stats > * { min-width: 0; }
.title, .gist, .snippet, .prose, .plain { overflow-wrap: anywhere; }
.section-title { display: flex; align-items: center; gap: .5rem; margin-top: .25rem; }
.empty { color: var(--muted); padding: .75rem 0; }
.eyebrow { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: .35rem; }

.chip {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 500; color: var(--text-2);
  padding: .1rem .5rem .1rem .45rem; border-radius: 999px; background: color-mix(in srgb, var(--c) 12%, transparent);
}
.chip { max-width: 100%; white-space: nowrap; }
.chip > span { overflow: hidden; text-overflow: ellipsis; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.tag { font-size: .74rem; font-weight: 500; padding: .08rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--text-2); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.soft { background: transparent; border: 1px solid var(--line); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .3rem; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows li:last-child { padding-bottom: 0; }
.rows.compact li { padding: .5rem 0; }
.rows li.is-done .title { color: var(--muted); text-decoration: line-through; }
.what { min-width: 0; }
.title { font-weight: 550; color: var(--text); }
a.title:hover { color: var(--accent); }
.gist { color: var(--text-2); font-size: .86rem; margin-top: .2rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- today */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.sync { display: flex; align-items: center; gap: .6rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.stat-num { display: block; font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .84rem; }
.stat.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.stat.warn .stat-num { color: var(--warn); }

.day + .day { margin-top: 1.1rem; }
.day-label { font-weight: 650; font-size: .88rem; margin-bottom: .45rem; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); margin-left: .3rem; }
.timeline li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: .5rem; padding: .5rem 0 .5rem .9rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .95rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.time { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; padding-top: .1rem; white-space: nowrap; }
.attention { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.attention h2 { color: var(--warn); }
.attention > p { margin: -.5rem 0 .8rem; }

/* ---------- course */
.course-hero {
  position: relative; overflow: hidden; border-radius: 18px; padding: 1.6rem 1.75rem; margin-bottom: 1.5rem; color: #fff;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 55%, #111));
}
.course-hero .eyebrow { color: rgba(255, 255, 255, .8); }
.hero-stats { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin-top: .9rem; font-size: .88rem; color: rgba(255, 255, 255, .88); }
.hero-stats strong { color: #fff; font-size: 1rem; }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .85rem; margin-bottom: 1.75rem; }
.topic-card {
  display: block; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--c);
  border-radius: 12px; padding: .9rem 1rem; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.topic-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16, 24, 40, .08); }
.topic-head { display: flex; justify-content: space-between; gap: .5rem; line-height: 1.3; }
.clamp { color: var(--text-2); font-size: .85rem; margin-top: .45rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.search-inline { padding: .6rem; }
.search-inline input { border: 0; box-shadow: none; }

/* ---------- item / topic */
.page-head { margin-bottom: 1.5rem; }
.page-head > p { margin-top: .4rem; max-width: 640px; }
.back { display: inline-block; color: var(--muted); font-size: .86rem; font-weight: 500; margin-bottom: .5rem; }
.back:hover { color: var(--accent); }
.actions { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.prose { font-size: .95rem; line-height: 1.7; overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { font-size: 1.05rem; text-transform: none; letter-spacing: 0; color: var(--text); margin: 1.2rem 0 .4rem; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: .5rem 0; }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose code { background: var(--surface-2); padding: .1rem .3rem; border-radius: 5px; font-size: .88em; }
.prose pre { overflow-x: auto; background: var(--surface-2); padding: .85rem; border-radius: 10px; }
.prose table { border-collapse: collapse; }
.prose td, .prose th { border: 1px solid var(--line); padding: .35rem .6rem; }
.footnote { margin-top: 1.25rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.plain { font-size: .94rem; line-height: 1.7; color: var(--text-2); overflow-wrap: anywhere; }
.plain p { margin: 0 0 .6rem; white-space: pre-line; }
.doc-section + .doc-section { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.doc-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: .4rem; }
pre.body { white-space: pre-wrap; word-wrap: break-word; font-family: inherit; font-size: .92rem; line-height: 1.65; margin: 0; color: var(--text-2); }
img.original { display: block; width: 100%; max-height: 70vh; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- search / forms */
.search-bar { display: grid; grid-template-columns: 1fr 210px auto; gap: .6rem; padding: .7rem; }
.results-count { margin: 1rem 0 .5rem; }
.results { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.snippet { color: var(--text-2); margin-top: .5rem; font-size: .9rem; white-space: pre-line; }
.form { display: grid; gap: 1rem; max-width: 720px; }
.form label { display: grid; gap: .4rem; font-weight: 600; font-size: .88rem; }

/* ---------- login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: radial-gradient(circle at 30% 20%, var(--accent-soft), var(--bg) 60%); }
.login-card {
  width: min(380px, 100%); display: grid; gap: .9rem; justify-items: start; background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px; padding: 2rem; box-shadow: 0 20px 50px rgba(16, 24, 40, .1);
}
.login-card h1 { font-size: 1.5rem; margin-top: .5rem; }
.login-card .btn { width: 100%; justify-content: center; }

/* ---------- small screens */
@media (max-width: 1000px) {
  .columns { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: .75rem 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding-bottom: .6rem; }
  .nav { display: flex; overflow-x: auto; gap: .25rem; scrollbar-width: none; }
  .nav a { white-space: nowrap; flex: none; }
  .nav-label, .logout { display: none; }
  .nav.courses { margin-top: .35rem; }
  .main { padding: 1rem 16px 2.5rem; }
  .topbar { margin-bottom: 1.25rem; }
  h1 { font-size: 1.45rem; }
  .search-bar { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 64px minmax(0, 1fr); }
}
