:root {
  font: 16px/1.5 system-ui, sans-serif;
  color-scheme: light;
  --accent: #6549a5;
  --paper: #f7f5fa;
  --surface: #fff;
  --text: #242036;
  --muted: #635c73;
  --line: #e4dfed;
  --tint: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --accent-text: color-mix(in srgb, var(--accent) 65%, #211735);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--text); }
body.dark {
  color-scheme: dark;
  --paper: #181622; --surface: #242132; --text: #f2edf8; --muted: #c3b9d3; --line: #3c354c;
  --accent-text: color-mix(in srgb, var(--accent) 40%, #fff);
}
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 3px; }
a { color: var(--accent-text); }
button {
  border: 1px solid transparent; border-radius: 10px; min-height: 44px; padding: 8px 13px;
  background: var(--tint); color: var(--accent-text); font-weight: 650; cursor: pointer;
}
button:hover { border-color: var(--accent-text); }
button.primary { background: var(--accent-text); color: var(--surface); }
button.quiet { background: var(--surface); color: var(--text); border-color: var(--line); }
button.icon { min-width: 44px; padding: 6px; }
button:disabled { opacity: .5; cursor: default; }
.shell { max-width: 1160px; margin: auto; padding: 0 26px; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 22px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand strong { font-size: 1.15rem; line-height: 1.2; display: block; overflow-wrap: anywhere; }
.brand-icon { display: grid; place-items: center; width: 44px; height: 44px; background: var(--tint); border-radius: 13px; }
small, .muted, .empty { color: var(--muted); }
.layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 28px; }
nav { display: flex; flex-direction: column; gap: 4px; padding: 24px 0; align-self: start; position: sticky; top: 0; }
nav a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; min-height: 44px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; }
nav a:hover, nav a[aria-current] { background: var(--tint); color: var(--accent-text); }
.nav-mobile { display: none; }
main { padding: 24px 0 48px; min-width: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); line-height: 1.12; letter-spacing: -.035em; overflow-wrap: anywhere; }
h2 { font-size: 1.13rem; line-height: 1.3; }
h3 { font-size: 1rem; }
.page-title { margin-bottom: 18px; }
.hero { background: var(--tint); padding: clamp(21px, 5vw, 40px); border-radius: 23px; margin-bottom: 18px; }
.hero p { margin-bottom: 7px; text-transform: capitalize; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 17px; min-width: 0; }
.stack { display: grid; gap: 14px; }
.columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; align-items: start; }
.toolbar, .actions, .chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar { justify-content: space-between; margin-bottom: 12px; }
.chips { margin-bottom: 10px; }
.chips button[aria-pressed="true"] { background: var(--accent-text); color: var(--surface); }
.entry { display: flex; align-items: start; gap: 9px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry .content { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.entry .content small { display: block; }
.entry .actions { flex-wrap: nowrap; }
.entry.complete strong { text-decoration: line-through; color: var(--muted); }
input[type="checkbox"] { width: 20px; height: 20px; margin: 10px 3px; accent-color: var(--accent-text); flex: 0 0 auto; }
.empty { padding: 8px 0; }
.metric { font-variant-numeric: tabular-nums; color: var(--accent-text); font-size: 1.35rem; font-weight: 700; }
.table-scroll { overflow-x: auto; }
.table-scroll + .table-scroll { margin-top: 14px; }
.grade-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.grade-table caption { text-align: left; font-weight: 700; padding-bottom: 6px; }
.grade-table th, .grade-table td { text-align: left; vertical-align: middle; padding: 8px; border-bottom: 1px solid var(--line); }
.grade-table thead { color: var(--muted); font-size: .88rem; }
.grade-table td small { display: block; }
.grade-table tbody tr:last-child > * { border-bottom: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr)); gap: 10px; }
.tile { display: flex; gap: 8px; align-items: center; text-decoration: none; min-height: 60px; font-weight: 650; }
.tile:hover { border-color: var(--accent-text); }
label { display: block; font-weight: 600; }
label.check { display: flex; align-items: center; gap: 8px; }
input:not([type="checkbox"]), select, textarea {
  width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); margin: 4px 0 0;
}
input[type="color"] { padding: 3px; }
textarea { resize: vertical; min-height: 110px; }
form, .fields { display: grid; gap: 12px; }
.attachment { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; overflow-wrap: anywhere; }
.attachment img { max-width: min(100%, 420px); max-height: 360px; object-fit: contain; }
.flashcard { width: 100%; min-height: 160px; font-size: 1.15rem; white-space: pre-wrap; overflow-wrap: anywhere; padding: 20px; }
.timer { text-align: center; }
.timer .actions { justify-content: center; }
.clock { font-size: clamp(3rem, 12vw, 6rem); line-height: 1.1; margin: 12px 0 17px; }
dialog { width: min(94vw, 530px); max-height: 90dvh; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); padding: 20px; }
dialog::backdrop { background: #161123a8; }
dialog h2 { margin-bottom: 14px; }
#status { position: fixed; z-index: 3; bottom: 16px; right: 16px; max-width: min(430px, 90vw); padding: 12px 16px; border-radius: 10px; color: var(--text); background: var(--surface); border: 1px solid var(--accent-text); box-shadow: 0 6px 22px #16112326; }
@media (max-width: 760px) {
  .shell { padding: 0 14px; }
  .top { padding: 12px 0; }
  .layout { display: block; }
  nav { position: fixed; z-index: 2; inset: auto 0 0; background: var(--surface); border-top: 1px solid var(--line); flex-direction: row; justify-content: space-around; gap: 0; padding: 5px 4px max(5px, env(safe-area-inset-bottom)); }
  nav a { flex: 1; flex-direction: column; gap: 1px; justify-content: center; font-size: .77rem; padding: 4px; }
  nav a.nav-desktop { display: none; }
  nav a.nav-mobile { display: flex; }
  nav a[data-more-active] { background: var(--tint); color: var(--accent-text); }
  main { padding: 16px 0 calc(78px + env(safe-area-inset-bottom)); }
  #status { bottom: 66px; }
}
@media (max-width: 550px) { .columns { grid-template-columns: minmax(0, 1fr); } }
