:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --panel-2: #efede7;
  --ink: #1c1b19;
  --muted: #6d6a62;
  --line: #e2dfd7;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --danger: #b4412f;
  --mark: #fff1a8;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --panel: #1e1e1c;
    --panel-2: #262623;
    --ink: #ecebe6;
    --muted: #9b988f;
    --line: #33322e;
    --accent: #7fbfa9;
    --accent-ink: #10201b;
    --danger: #e88470;
    --mark: #5a4c12;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 2px;
}
.brand { font-weight: 700; letter-spacing: -.01em; font-size: 17px; padding: 4px 10px 16px; display: flex; gap: 10px; align-items: center; }
.brand-dot { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 14px; }
.nav-h { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px;
  text-decoration: none; color: var(--ink);
}
.nav a:hover { background: var(--panel-2); }
.nav a.on { background: var(--panel); box-shadow: var(--shadow); font-weight: 600; }
.swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.side-foot { margin-top: auto; padding: 16px 10px 0; font-size: 13px; color: var(--muted); }
.side-foot button { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; }
main { padding: 28px clamp(16px, 4vw, 48px) 80px; max-width: 1180px; width: 100%; }
.topbar { display: none; }

h1 { font-size: 28px; letter-spacing: -.02em; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: -.005em; }
.sub { color: var(--muted); margin: 0 0 24px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-h h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* lists */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); min-width: 0; }
.rows li:first-child { border-top: 0; }
.rows a.row-link { text-decoration: none; flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; }
.rows a.row-link:hover .t { text-decoration: underline; }
.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.when { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.pill { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); white-space: nowrap; }
.pill.late { background: var(--danger); color: #fff; }
.pill.soon { background: var(--accent); color: var(--accent-ink); }

/* due */
.due-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.due-row.done .t { text-decoration: line-through; color: var(--muted); }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.x:hover { background: var(--panel-2); color: var(--danger); }
form.inline { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
form.inline input, form.inline select { flex: 1 1 140px; min-width: 0; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 9px; padding: 8px 14px;
  font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn.ghost { background: var(--panel-2); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }

/* links */
.link-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--bg); text-decoration: none; font-size: 14px;
}
.chip:hover { border-color: var(--accent); }

/* course header */
.course-h { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.course-badge { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }

/* lecture */
.lecture-h { margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 20px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.prose { max-width: 760px; overflow-wrap: anywhere; }
.prose h2 { font-size: 19px; margin: 26px 0 8px; }
.prose h3 { font-size: 16px; margin: 20px 0 6px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 3px 0; }
.prose p { margin: 0 0 12px; }
.transcript p { margin: 0 0 14px; }
.transcript strong { color: var(--accent); font-weight: 600; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.find { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; max-width: 760px; }
.find input { flex: 1; }

/* search */
.search-big { width: 100%; font-size: 17px; padding: 12px 14px; margin-bottom: 20px; }
.hit { padding: 14px 0; border-top: 1px solid var(--line); }
.hit:first-child { border-top: 0; }
.hit a { text-decoration: none; font-weight: 600; }
.hit a:hover { text-decoration: underline; }
.hit .snip { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* drop */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 18px; text-align: center; color: var(--muted);
  background: var(--panel); cursor: pointer; transition: border-color .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--ink); }
.dropzone strong { color: var(--ink); display: block; font-size: 16px; margin-bottom: 4px; }
.drop-text { display: flex; gap: 8px; margin: 14px 0 26px; }
.drop-text textarea { flex: 1; min-height: 44px; height: 44px; resize: vertical; }
.drops { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.drop {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; min-width: 0;
}
.drop-thumb { aspect-ratio: 4 / 3; background: var(--panel-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-size: 13px; text-decoration: none; }
.drop-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drop-text-body { padding: 12px; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 150px; overflow: hidden; }
.drop-meta { padding: 9px 12px; font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; border-top: 1px solid var(--line); margin-top: auto; }
.drop-meta .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); flex: 1; min-width: 0; }
.drop-actions { display: flex; gap: 2px; }
.drop-actions a, .drop-actions button { background: none; border: 0; color: var(--muted); padding: 4px 6px; border-radius: 6px; cursor: pointer; text-decoration: none; font-size: 12.5px; }
.drop-actions a:hover, .drop-actions button:hover { background: var(--panel-2); color: var(--ink); }
.recent-drops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.recent-drops a { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px; text-align: center; overflow-wrap: anywhere; }
.recent-drops img { width: 100%; height: 100%; object-fit: cover; }
#drop-overlay {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--accent) 25%, transparent); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 50; font-size: 22px; font-weight: 700; pointer-events: none;
}
#drop-overlay[hidden] { display: none; }
#drop-overlay div { background: var(--panel); padding: 22px 30px; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.progress { height: 4px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.login h1 { font-size: 22px; margin-bottom: 6px; }
.login form { display: grid; gap: 10px; margin-top: 18px; }
.login .error { color: var(--danger); font-size: 14px; min-height: 1.2em; }

#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* phones */
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .side.open {
    display: flex; position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); z-index: 40; background: var(--bg);
    padding-top: max(20px, env(safe-area-inset-top)); box-shadow: 0 0 40px rgba(0,0,0,.25);
  }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: var(--bg);
    padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
  }
  .topbar .menu { background: none; border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; cursor: pointer; }
  .topbar .brand { padding: 0; font-size: 16px; }
  .topbar .quick { margin-left: auto; }
  main { padding: 20px max(16px, env(safe-area-inset-right)) 80px max(16px, env(safe-area-inset-left)); }
  h1 { font-size: 24px; }
  .recent-drops { grid-template-columns: repeat(4, 1fr); }
}
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
