/* IB Mark Tracker — app styles.
   Kept out of index.html so the Content-Security-Policy can forbid inline
   styles (style-src 'self'). Per-element values from the app (course colours,
   bar widths…) are applied through element.style — see applyCss in app.js. */
/* Self-hosted fonts (latin subset). Both are variable fonts, so one file
   covers every weight. Served from this origin — no third-party font CDN, no
   SRI gap, and one fewer external origin in the CSP. */
@font-face{
  font-family:'Fraunces'; font-style:normal; font-weight:100 900;
  font-display:swap; src:url('vendor/fonts/fraunces-latin.woff2') format('woff2');
}
@font-face{
  font-family:'Inter'; font-style:normal; font-weight:100 900;
  font-display:swap; src:url('vendor/fonts/inter-latin.woff2') format('woff2');
}
:root{
  --spine:#202B33;
  --spine-text:#EDEDE6;
  --spine-text-dim:#9BA6AC;
  --page:#FCFBF7;
  --card:#FFFFFF;
  --ink:#23282B;
  --ink-soft:#5C6368;
  --rule:#DFDACB;
  --focus:#20262B;

  --business:#B9862E;
  --mathAA:#1F6F6B;
  --chemistry:#3F7D4C;
  --physics:#35507A;
  --english:#7A3B4A;
  --spanishB:#A6512E;
  --french:#6B4C7A;
  --history:#6B4A32;
  --geography:#2E6E8E;
  --biology:#6B7F3A;

  --done:#3F7D4C;
  --progress:#B9862E;
  --notstarted:#8A8378;
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  font-family:'Inter',system-ui,sans-serif;
  color:var(--ink);
  background:var(--page);
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3{font-family:'Fraunces',Georgia,serif;margin:0;}
button{font-family:inherit;}
::selection{background:#20262B; color:#fff;}

.app{
  display:flex;
  min-height:100vh;
}

/* ---------- Spine (nav) ---------- */
.spine{
  width:236px;
  flex-shrink:0;
  background:var(--spine);
  color:var(--spine-text);
  display:flex;
  flex-direction:column;
  padding:22px 0 16px;
  position:sticky;
  top:0;
  height:100vh;
}
.spine-brand{
  padding:0 20px 18px;
  border-bottom:1px solid rgba(255,255,255,0.12);
  margin-bottom:6px;
}
.spine-brand h1{
  font-size:22px;
  font-weight:600;
  letter-spacing:0.2px;
  color:#fff;
}
.spine-brand p{
  margin:4px 0 0;
  font-size:12.5px;
  color:var(--spine-text-dim);
}
.spine-nav{
  list-style:none;
  margin:0;
  padding:8px 10px;
  flex:1;
  overflow-y:auto;
}
.spine-nav li{margin-bottom:2px;}
.tab{
  width:100%;
  display:flex;
  align-items:center;
  gap:10px;
  background:transparent;
  border:none;
  color:var(--spine-text);
  padding:9px 10px;
  border-radius:6px;
  cursor:pointer;
  font-size:14.5px;
  text-align:left;
  opacity:0;
  transform:translateX(-14px);
  animation:tabIn .38s ease forwards;
  animation-delay:calc(var(--i) * 55ms);
}
@keyframes tabIn{ to{ opacity:1; transform:translateX(0); } }
.tab:hover{background:rgba(255,255,255,0.08);}
.tab.active{background:rgba(255,255,255,0.14);}
.flag{
  width:9px;height:9px;border-radius:2px;flex-shrink:0;
  background:var(--flag-color, #8A8378);
}
.tab-name{flex:1; line-height:1.25;}
.tab-sub{display:block; font-size:11px; color:var(--spine-text-dim);}
.manage-tab{border-top:1px solid rgba(255,255,255,0.14); margin-top:6px; padding-top:12px;}

.spine-foot{
  padding:14px 20px 4px;
  border-top:1px solid rgba(255,255,255,0.12);
  font-size:12px;
  color:var(--spine-text-dim);
  line-height:1.5;
}
.spine-foot .who{
  display:block;
  color:var(--spine-text);
  font-size:12.5px;
  margin-bottom:2px;
  word-break:break-all;
}
.spine-foot .sync-note{display:block; margin-bottom:8px;}
.spine-foot .sync-note.sync-error{color:#F2B24C; font-weight:600;}
.spine-foot button{
  margin-top:8px;
  width:100%;
  background:rgba(255,255,255,0.1);
  color:#fff;
  border:1px solid rgba(255,255,255,0.18);
  padding:7px 8px;
  border-radius:6px;
  font-size:12.5px;
  cursor:pointer;
}
.spine-foot button:hover{background:rgba(255,255,255,0.18);}
.spine-foot button.ghost{background:transparent;}

/* ---------- Page (main content) ---------- */
.page-wrap{
  flex:1;
  min-width:0;
  background-image: radial-gradient(circle at 22px 0, var(--page) 6px, var(--rule) 7px, transparent 7.5px);
  background-size:100% 88px;
  background-repeat:repeat-y;
  background-position: 0 20px;
}
.page{
  max-width:1080px;
  margin:0 auto;
  padding:38px 40px 60px 64px;
}

.page-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  flex-wrap:wrap;
  gap:14px;
  margin-bottom:22px;
  padding-bottom:16px;
  border-bottom:2px solid var(--accent, var(--ink));
}
.page-header h2{
  font-size:30px;
  font-weight:600;
  color:var(--ink);
}
.page-header .kicker{
  color:var(--ink-soft);
  font-size:13.5px;
  margin-top:4px;
}
.level-chips{display:flex; gap:6px;}
.chip{
  border:1px solid var(--rule);
  background:#fff;
  padding:6px 13px;
  border-radius:20px;
  font-size:13px;
  cursor:pointer;
  color:var(--ink-soft);
}
.chip.active{
  background:var(--accent, var(--ink));
  border-color:var(--accent, var(--ink));
  color:#fff;
}

.add-toggle{
  background:var(--accent, var(--ink));
  color:#fff;
  border:none;
  padding:9px 16px;
  border-radius:7px;
  font-size:13.5px;
  font-weight:500;
  cursor:pointer;
}
.add-toggle:hover{opacity:0.92;}

.quick-add{
  background:var(--card);
  border:1px solid var(--rule);
  border-radius:10px;
  padding:18px;
  margin-bottom:26px;
  display:none;
}
.quick-add.open{display:block;}
.qa-row{display:flex; gap:10px; flex-wrap:wrap; margin-bottom:10px;}
.qa-row label{
  display:flex; flex-direction:column; gap:4px;
  font-size:12px; color:var(--ink-soft); flex:1; min-width:140px;
}
.qa-row input, .qa-row select, .qa-row textarea{
  font-family:inherit;
  font-size:14px;
  padding:8px 9px;
  border:1px solid var(--rule);
  border-radius:6px;
  color:var(--ink);
  background:#fffefb;
}
.qa-row textarea{resize:vertical; min-height:60px;}
.qa-actions{display:flex; justify-content:flex-end; gap:8px;}
.qa-actions button{
  padding:8px 15px;
  border-radius:6px;
  font-size:13.5px;
  cursor:pointer;
  border:1px solid var(--rule);
  background:#fff;
  color:var(--ink);
}
.qa-actions .primary{
  background:var(--accent, var(--ink));
  border-color:var(--accent, var(--ink));
  color:#fff;
}

/* Overview */
.tiles{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px,1fr));
  gap:16px;
  margin-bottom:30px;
}
.tile{
  background:var(--card);
  border:1px solid var(--rule);
  border-top:4px solid var(--tile-color, #999);
  border-radius:9px;
  padding:16px 16px 14px;
  cursor:pointer;
}
.tile:hover{box-shadow:0 3px 10px rgba(0,0,0,0.06);}
.tile h3{font-size:16.5px; font-weight:600; margin-bottom:2px;}
.tile .lv{font-size:11.5px; color:var(--ink-soft); margin-bottom:10px; display:block;}
.tile .stats{display:flex; gap:14px; font-size:12.5px; color:var(--ink-soft);}
.tile .stats b{color:var(--ink); font-size:14px; display:block; font-weight:600;}
.tile .deadline{margin-top:10px; font-size:12px; color:var(--tile-color,#999); font-weight:500;}

.section-title{
  font-size:15px;
  font-weight:600;
  margin-bottom:12px;
  color:var(--ink);
}
.deadline-list{list-style:none; margin:0 0 10px; padding:0;}
.deadline-list li{
  display:flex; justify-content:space-between; gap:10px;
  padding:10px 0;
  border-bottom:1px solid var(--rule);
  font-size:14px;
}
.deadline-list .d-when{font-size:12.5px; color:var(--ink-soft);}

.empty{
  color:var(--ink-soft);
  font-size:13.5px;
  padding:16px 0;
  line-height:1.6;
}

/* Subject columns */
.columns{
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:20px;
}
.columns.four{grid-template-columns:repeat(4, 1fr);}
.col-head{
  display:flex; justify-content:space-between; align-items:baseline;
  margin-bottom:12px;
}
.col-head h4{font-size:14px; font-weight:600; text-transform:none;}
.col-head span{font-size:12px; color:var(--ink-soft);}
.col-files-label{
  font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.04em;
  color:var(--ink-soft); margin:6px 0 8px;
}
.col-upload{
  display:block; text-align:center; cursor:pointer;
  border:1px dashed var(--rule); color:var(--ink-soft); background:transparent;
  border-radius:7px; padding:8px; font-size:12.5px; margin-top:6px;
}
.col-upload:hover{border-color:var(--accent, var(--ink-soft)); color:var(--accent, var(--ink));}
.col-upstatus{font-size:11px; color:var(--ink-soft); margin-top:6px; line-height:1.4; min-height:1px;}

.card{
  background:var(--card);
  border:1px solid var(--rule);
  border-left:3px solid var(--accent, #999);
  border-radius:7px;
  padding:12px 12px 10px;
  margin-bottom:10px;
  position:relative;
}
.card .card-top{display:flex; justify-content:space-between; gap:8px; align-items:flex-start;}
.card h5{font-size:14px; font-weight:600; margin:0 0 4px;}
.card p{font-size:13px; color:var(--ink-soft); line-height:1.55; margin:0; white-space:pre-wrap;}
.card .meta{font-size:11px; color:#9a9488; margin-top:8px;}
.del{
  background:none; border:none; color:#b3ab9c; cursor:pointer; font-size:15px;
  line-height:1; padding:2px 4px;
}
.del:hover{color:#a6512e;}
.card-btns{display:inline-flex; gap:1px; align-items:flex-start; flex-shrink:0;}
.edit-btn{
  background:none; border:none; color:#b3ab9c; cursor:pointer; font-size:13px;
  line-height:1; padding:2px 4px;
}
.edit-btn:hover{color:var(--accent, var(--ink));}

/* Inline entry-edit form */
.card.editing{padding:12px;}
.card .edit-title, .card .edit-body{
  width:100%; font-family:inherit; padding:8px 9px; border:1px solid var(--rule);
  border-radius:6px; background:#fffefb; color:var(--ink); margin-bottom:8px;
}
.card .edit-title{font-size:14px; font-weight:600;}
.card .edit-body{font-size:13px; resize:vertical; min-height:58px;}
html.theme-dark .card .edit-title, html.theme-dark .card .edit-body{background:var(--field, #171C21);}
.card .edit-actions{display:flex; justify-content:flex-end; gap:8px;}
.card .edit-actions button{
  padding:7px 14px; border-radius:6px; font-size:13px; cursor:pointer;
  border:1px solid var(--rule); background:transparent; color:var(--ink);
}
.card .edit-actions .edit-save{background:var(--accent, var(--ink)); border-color:var(--accent, var(--ink)); color:#fff;}

.task-row{display:flex; align-items:flex-start; gap:9px;}
.task-row input[type=checkbox]{margin-top:3px; width:15px; height:15px; accent-color:var(--accent,#333); cursor:pointer;}
.task-row.done h5{text-decoration:line-through; color:#9a9488;}
.task-row.done p{text-decoration:line-through;}

.status-pill{
  display:inline-block;
  font-size:11px;
  padding:3px 9px;
  border-radius:20px;
  color:#fff;
  cursor:pointer;
  margin-top:6px;
  font-weight:500;
}
.due{font-size:11.5px; color:var(--ink-soft); margin-top:6px;}
.due.overdue{color:#a6512e; font-weight:600;}

/* Editable deadline on task/project cards */
.deadline-edit{display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-top:8px;}
.deadline-edit .cal{font-size:12px; line-height:1;}
.deadline-edit .due-input{
  font-family:inherit; font-size:11.5px; padding:3px 6px;
  border:1px solid var(--rule); border-radius:5px; color:var(--ink); background:#fffefb;
  max-width:150px;
}
html.theme-dark .deadline-edit .due-input{background:var(--field, #171C21);}
.deadline-edit .due-text{font-size:11.5px; color:var(--ink-soft);}
.deadline-edit .due-text.none{font-style:italic;}
.deadline-edit .due-text.overdue{color:#a6512e; font-weight:600;}
.deadline-edit .due-clear{
  background:none; border:none; color:#b3ab9c; cursor:pointer; font-size:14px;
  line-height:1; padding:0 2px;
}
.deadline-edit .due-clear:hover{color:#a6512e;}

/* Course setup / picker */
.setup-intro{max-width:560px; color:var(--ink-soft); font-size:14px; line-height:1.6; margin-bottom:22px;}
.course-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(360px,1fr));
  gap:12px;
  margin-bottom:24px;
  align-items:start;   /* each card is its own height — don't stretch empty
                          cards to match a tall one with day/time rows */
}
/* On phones a 360px min column would overflow the viewport — go single-column. */
@media (max-width: 760px){ .course-grid{grid-template-columns:1fr;} }
.course-card{
  border:1px solid var(--rule);
  background:var(--card);
  border-radius:9px;
  padding:13px 14px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.course-card.selected{border-color:var(--cc-color,#999); box-shadow:0 0 0 1px var(--cc-color,#999) inset;}
.course-check{display:flex; align-items:center; gap:9px; cursor:pointer; font-size:14px; font-weight:500;}
.course-check input{width:16px; height:16px; accent-color:var(--cc-color,#333); cursor:pointer;}
.course-flag{width:9px; height:9px; border-radius:2px; background:var(--cc-color,#999); flex-shrink:0;}
.course-level{display:flex; gap:6px; padding-left:25px;}
.course-level button{
  flex:1; padding:5px 0; font-size:12px; border-radius:5px; cursor:pointer;
  border:1px solid var(--rule); background:#fff; color:var(--ink-soft);
}
.course-level button.active{background:var(--cc-color,#333); border-color:var(--cc-color,#333); color:#fff;}
.course-level{display:none;}
.course-card.selected .course-level{display:flex;}
.setup-actions{display:flex; gap:10px; align-items:center;}
.setup-save{
  background:#20262B; color:#fff; border:none; padding:11px 22px; border-radius:7px;
  font-size:14px; font-weight:500; cursor:pointer;
}
.setup-save:hover{opacity:0.92;}
.setup-note{font-size:12.5px; color:var(--ink-soft);}

/* Buttons that must read on every theme: ink-coloured fill, page-coloured text. */
.ink-btn{background:var(--ink) !important; color:var(--page) !important;}

/* ---------- Course picker (Change courses) ---------- */
.pick-search{
  width:100%; max-width:560px; font:inherit; font-size:15px; padding:11px 14px;
  border:1px solid var(--rule); border-radius:10px; background:var(--card); color:var(--ink); margin-bottom:6px;
}
.pick-empty{color:var(--ink-soft); font-size:14px; margin:12px 0;}
/* Each subject group is its own tinted panel with a coloured edge and badge. */
.pick-group{
  margin:22px 0; border:1px solid var(--rule); border-left:5px solid var(--g-color, var(--rule));
  border-radius:14px; background:var(--page);
  background:color-mix(in srgb, var(--g-color, transparent) 6%, var(--page));
  scroll-margin-top:16px; overflow:hidden;
}
.pick-group[hidden], .pick-lang[hidden], .pick-row[hidden]{display:none !important;}
.pick-group-head{
  display:flex; align-items:center; gap:12px; padding:14px 16px;
  border-bottom:1px solid var(--rule);
  background:rgba(127,127,127,.06);
  background:color-mix(in srgb, var(--g-color, transparent) 12%, var(--card));
}
.pick-gbadge{
  width:34px; height:34px; border-radius:50%; flex-shrink:0;
  display:inline-flex; align-items:center; justify-content:center;
  background:var(--g-color, var(--ink)); color:#fff; font-weight:700; font-size:15px;
}
.pick-group-title{font-size:16px; font-weight:600; margin:0; color:var(--ink); flex:1; min-width:0; line-height:1.25;}
.pick-gnum{display:block; font-size:11px; text-transform:uppercase; letter-spacing:.07em; color:var(--ink-soft); font-weight:700; margin-bottom:2px;}
.pick-gcount{
  flex-shrink:0; font-size:12px; font-weight:600; color:#fff; background:var(--g-color, var(--ink));
  border-radius:20px; padding:3px 10px;
}
.pick-gcount[hidden]{display:none;}
.pick-group-body{padding:14px 16px 16px;}
.pick-group-body > .pick-lang:last-child{margin-bottom:0;}
/* Jump bar: one button per group. */
.pick-jump{display:flex; flex-wrap:wrap; gap:6px; margin:10px 0 4px;}
.pick-jumpbtn{
  display:inline-flex; align-items:center; gap:7px; min-height:36px; padding:5px 12px 5px 6px;
  border:1px solid var(--rule); border-radius:20px; background:var(--card); color:var(--ink);
  font:inherit; font-size:13px; font-weight:500; cursor:pointer;
}
.pick-jumpbtn:hover{border-color:var(--g-color, var(--ink-soft));}
.pick-jumpdot{
  width:22px; height:22px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center;
  background:var(--g-color, var(--ink)); color:#fff; font-size:11.5px; font-weight:700;
}
@media (max-width: 760px){
  .pick-group-head{padding:12px 12px;}
  .pick-group-body{padding:12px;}
}
.pick-rows{display:grid; grid-template-columns:repeat(auto-fill, minmax(300px,1fr)); gap:8px; align-items:start;}
@media (max-width: 760px){ .pick-rows{grid-template-columns:1fr;} }
.pick-row{
  display:flex; align-items:center; gap:8px; min-height:50px;
  border:1px solid var(--rule); background:var(--card); border-radius:9px; padding:4px 8px 4px 4px;
}
.pick-row.on{border-color:var(--cc-color); box-shadow:0 0 0 1px var(--cc-color) inset;}
.pick-toggle{
  flex:1; min-width:0; display:flex; align-items:center; gap:6px 10px; flex-wrap:wrap;
  background:none; border:none; color:var(--ink); font:inherit; font-size:14px; text-align:left;
  padding:9px 6px; cursor:pointer; border-radius:7px;
}
.pick-box{width:18px; height:18px; border-radius:5px; border:1.5px solid var(--ink-soft); flex-shrink:0; position:relative;}
.pick-row.on .pick-box{background:var(--cc-color); border-color:var(--cc-color);}
.pick-row.on .pick-box::after{
  content:''; position:absolute; left:5px; top:1.5px; width:5px; height:10px;
  border:solid #fff; border-width:0 2px 2px 0; transform:rotate(45deg);
}
.pick-name{font-weight:500;}
.pick-tag{font-size:11px; color:var(--ink-soft); border:1px solid var(--rule); border-radius:20px; padding:1px 8px; white-space:nowrap;}
.pick-level{display:none; gap:4px; flex-shrink:0;}
.pick-row.on .pick-level{display:inline-flex;}
.pick-lvl{
  min-width:46px; min-height:38px; border:1px solid var(--rule); background:var(--card); color:var(--ink-soft);
  border-radius:7px; font:inherit; font-size:13px; font-weight:600; cursor:pointer;
}
.pick-lvl.active{background:var(--cc-color); border-color:var(--cc-color); color:#fff;}
.pick-lang{border:1px solid var(--rule); border-radius:10px; padding:12px; margin-bottom:10px; background:var(--card);}
.pick-lang-head{display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:10px;}
.pick-lang-name{font-weight:600; font-size:14px; color:var(--ink);}
.pick-lang-rows{display:grid; gap:6px;}
.pick-lang-rows .pick-row{display:none;}
.pick-lang-rows .pick-row.on{display:flex;}
.pick-lang-rows .pick-row.on:last-of-type{margin-bottom:10px;}
.pick-chips{display:flex; flex-wrap:wrap; gap:6px;}
.pick-chip, .pick-more{
  border:1px solid var(--rule); background:transparent; color:var(--ink); border-radius:20px;
  padding:7px 13px; min-height:36px; font:inherit; font-size:13px; cursor:pointer;
}
.pick-chip.on{background:var(--cc-color); border-color:var(--cc-color); color:#fff;}
.pick-chip.extra{display:none;}
.pick-lang.all .pick-chip.extra, .pick-lang.searching .pick-chip.extra{display:inline-block;}
.pick-chip.filtered-out{display:none !important;}
.pick-more{border-style:dashed; color:var(--ink-soft);}
.pick-lang.searching .pick-more{display:none;}
.pick-bar{
  position:sticky; bottom:var(--notice-h, 0px); z-index:5; margin-top:24px;
  display:flex; align-items:center; gap:10px 14px; flex-wrap:wrap;
  padding:12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background:var(--card); border:1px solid var(--rule); border-radius:12px;
  box-shadow:0 -6px 24px rgba(0,0,0,.10);
}
.pick-count{font-size:13.5px; color:var(--ink); font-weight:500; flex:1; min-width:180px;}
.pick-actions{display:flex; gap:8px; margin-left:auto;}
.pick-cancel{
  background:transparent; border:1px solid var(--rule); color:var(--ink);
  padding:11px 18px; border-radius:7px; font:inherit; font-size:14px; cursor:pointer;
}
.pick-bar .setup-save{background:var(--ink); color:var(--page);}

/* ---------- Schedule: your courses ---------- */
.sched-courses-head{display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-top:26px; margin-bottom:10px;}
.sched-courses-head .section-title{margin:0 !important;}
.course-title{display:flex; align-items:center; gap:9px; font-size:14px; font-weight:500; color:var(--ink);}
.course-name{flex:1; min-width:0;}
.course-lvl{font-size:11.5px; font-weight:600; color:var(--ink-soft); border:1px solid var(--rule); border-radius:20px; padding:1px 8px; flex-shrink:0;}

/* ---------- Courses: outlines & rubrics ---------- */
.co-list{display:grid; gap:10px;}
.co-card{border:1px solid var(--rule); border-left:4px solid var(--cc-color); background:var(--card); border-radius:10px; color:var(--ink);}
.co-card > summary{list-style:none; display:flex; align-items:center; gap:10px; padding:14px 16px; cursor:pointer; min-height:56px;}
.co-card > summary::-webkit-details-marker{display:none;}
.co-title{flex:1; min-width:0; font-weight:600; font-size:15px;}
.co-title small{display:block; font-weight:400; font-size:12px; color:var(--ink-soft); margin-top:2px;}
.co-chev{width:9px; height:9px; border-right:2px solid var(--ink-soft); border-bottom:2px solid var(--ink-soft); transform:rotate(45deg); margin:0 4px 4px; transition:transform .15s; flex-shrink:0;}
.co-card[open] .co-chev{transform:rotate(225deg); margin-top:6px; margin-bottom:0;}
.co-body{padding:2px 16px 16px; border-top:1px solid var(--rule);}
.co-src, .co-meta, .co-foot, .co-disclaim{font-size:12.5px; color:var(--ink-soft); line-height:1.5; margin:6px 0;}
.co-src{margin-top:12px;}
.co-disclaim{font-style:italic; margin-top:14px;}
.co-none{font-size:13.5px; color:var(--ink-soft); line-height:1.55; margin:14px 0;}
.co-h{font-size:13.5px; font-weight:600; margin:16px 0 8px; color:var(--ink);}
.co-comps, .co-crit, .co-filelist{list-style:none; padding:0; margin:0; display:grid; gap:6px;}
.co-comps li{display:grid; grid-template-columns:1fr auto; gap:2px 12px; padding:9px 12px; border:1px solid var(--rule); border-radius:8px;}
.co-cname{font-weight:600; font-size:13.5px;}
.co-w{font-weight:700; font-size:13.5px; text-align:right; white-space:nowrap;}
.co-cdesc{grid-column:1 / -1; font-size:12.5px; color:var(--ink-soft); line-height:1.45;}
.co-crit li{padding:9px 12px; border-radius:8px; background:rgba(127,127,127,.08);}
.co-crit-top{display:flex; justify-content:space-between; align-items:baseline; gap:10px; font-size:13.5px;}
.co-marks{font-size:12px; font-weight:600; color:var(--ink-soft); white-space:nowrap;}
.co-crit p{margin:3px 0 0; font-size:12.5px; color:var(--ink-soft); line-height:1.45;}
.co-files{margin-top:18px; border-top:1px dashed var(--rule);}
.co-filelist{margin-bottom:10px;}
.co-file{display:flex; align-items:center; gap:10px; border:1px solid var(--rule); border-radius:8px; padding:8px 10px;}
.co-file .fi{font-size:18px; flex-shrink:0;}
.co-fname{flex:1; min-width:0; font-size:13.5px; font-weight:500; overflow-wrap:anywhere;}
.co-fname small{display:block; font-weight:400; font-size:11.5px; color:var(--ink-soft);}
.co-file .del{font-size:20px; padding:6px 8px; min-width:36px; min-height:36px;}
.co-upstatus{font-size:12px; color:var(--ink-soft); margin-top:8px; line-height:1.4;}
.upload-btn:focus-within{outline:2.5px solid var(--ink); outline-offset:2px;}
.vh-input{position:absolute; width:1px; height:1px; opacity:0; overflow:hidden; clip:rect(0 0 0 0);}
.pdf-img{display:block; max-width:100%; height:auto; margin:0 auto; border-radius:6px; background:#fff;}

/* ---------- Rubrics: view + editor ---------- */
.co-rubrics{margin-top:18px; border-top:1px dashed var(--rule);}
.co-rub-head{display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-top:14px;}
.co-rub-head .co-h{margin:0;}
.co-rub-src{font-size:11.5px; color:var(--ink-soft); border:1px solid var(--rule); border-radius:20px; padding:1px 9px;}
.co-rub-src.mine{color:var(--ink); border-color:var(--ink-soft); font-weight:600;}
.co-edit{
  margin-left:auto; border:1px solid var(--rule); background:transparent; color:var(--ink);
  border-radius:8px; padding:8px 14px; min-height:38px; font:inherit; font-size:13px; font-weight:600; cursor:pointer;
}
.co-edit:hover{border-color:var(--ink-soft);}
.co-linkbtn{background:none; border:none; padding:4px 2px; color:var(--ink); text-decoration:underline; font:inherit; font-size:inherit; cursor:pointer;}
.co-rubrics.editing .co-h{margin-top:16px;}
.rub-ed{border:1px solid var(--rule); border-radius:10px; padding:12px; margin:0 0 10px; display:grid; gap:8px; min-width:0;}
.rub-ed-top{display:flex; gap:8px;}
.rub-ed input, .rub-ed textarea{
  font:inherit; font-size:14px; color:var(--ink); background:var(--card);
  border:1px solid var(--rule); border-radius:7px; padding:8px 10px; min-width:0; width:100%;
}
.rub-ed textarea{resize:vertical; font-size:13px; line-height:1.4;}
.rub-name{font-weight:600;}
.rub-crits{display:grid; gap:8px;}
.rub-crit{display:grid; grid-template-columns:56px 1fr 118px 38px; gap:6px; align-items:center; padding:8px; border-radius:8px; background:rgba(127,127,127,.07);}
.rc-mwrap{display:flex; align-items:center; gap:6px; font-size:12.5px; color:var(--ink-soft); min-width:0;}
.rc-mwrap .rc-marks{width:64px; flex:none;}
.rub-crit .rc-desc{grid-column:1 / -1;}
.rc-k{text-align:center;}
.rc-del, .rub-del{
  border:1px solid var(--rule); background:transparent; color:var(--ink-soft); border-radius:7px;
  min-height:38px; min-width:38px; font:inherit; font-size:14px; cursor:pointer; padding:0 10px; flex-shrink:0; width:auto !important;
}
.rc-del{font-size:20px; line-height:1;}
.rc-del:hover, .rub-del:hover{color:#a6512e; border-color:#a6512e;}
.rub-ed-foot{display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap;}
.rc-add, .rub-add{
  border:1px dashed var(--rule); background:transparent; color:var(--ink); border-radius:8px;
  padding:8px 14px; min-height:38px; font:inherit; font-size:13px; cursor:pointer;
}
.rub-total{font-size:13px; font-weight:600; color:var(--ink);}
.rub-actions{display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-top:12px;}
.co-rubrics.editing .setup-save{background:var(--ink); color:var(--page);}
/* Phones: letter, marks and remove on one row; the name and description
   each get the full width so nothing is cut off. */
@media (max-width: 560px){
  .rub-crit{grid-template-columns:52px 1fr 38px; grid-template-areas:"k marks del" "name name name" "desc desc desc";}
  .rub-crit .rc-k{grid-area:k;} .rub-crit .rc-mwrap{grid-area:marks;} .rub-crit .rc-del{grid-area:del;}
  .rub-crit .rc-name{grid-area:name;} .rub-crit .rc-desc{grid-area:desc;}
}

/* ---------- Auth gate (sign in / sign up) ---------- */
.gate{
  position:fixed; inset:0;
  background:var(--spine);
  color:var(--spine-text);
  display:flex; align-items:center; justify-content:center;
  padding:24px;
  z-index:50;
}
.gate[hidden]{display:none;}
.gate-card{
  width:100%; max-width:380px;
  background:#fff; color:var(--ink);
  border-radius:14px;
  padding:30px 28px 26px;
  box-shadow:0 20px 60px rgba(0,0,0,0.35);
}
.gate-card h1{font-size:26px; font-weight:600; margin-bottom:4px;}
.gate-card .sub{color:var(--ink-soft); font-size:13.5px; margin-bottom:20px; line-height:1.5;}
.gate-field{display:flex; flex-direction:column; gap:5px; margin-bottom:12px;}
.gate-field label{font-size:12px; color:var(--ink-soft);}
.gate-field input{
  font-family:inherit; font-size:15px; padding:11px 12px;
  border:1px solid var(--rule); border-radius:8px; color:var(--ink); background:#fffefb;
}
.gate-primary{
  width:100%; background:#20262B; color:#fff; border:none;
  padding:12px; border-radius:8px; font-size:15px; font-weight:500; cursor:pointer; margin-top:4px;
}
.gate-primary:hover{opacity:0.92;}
.gate-primary:disabled{opacity:0.55; cursor:default;}
.gate-google{
  width:100%; background:#fff; color:var(--ink); border:1px solid var(--rule);
  padding:11px; border-radius:8px; font-size:14.5px; font-weight:500; cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:9px; margin-top:10px;
}
.gate-google:hover{background:#f7f5ef;}
.gate-google svg{width:17px; height:17px;}
.gate-or{display:flex; align-items:center; gap:10px; color:var(--ink-soft); font-size:12px; margin:16px 0;}
.gate-or::before,.gate-or::after{content:""; flex:1; height:1px; background:var(--rule);}
.gate-toggle{margin-top:16px; font-size:13px; color:var(--ink-soft); text-align:center;}
.gate-toggle button{background:none; border:none; color:#35507A; cursor:pointer; font-size:13px; font-weight:600; padding:0;}
.gate-msg{margin-top:14px; font-size:13px; min-height:18px; line-height:1.4;}
.gate-msg.err{color:#a6512e;}
.gate-msg.ok{color:var(--done);}
.gate-legal{margin:10px 0 0; font-size:12px; color:var(--ink-soft); text-align:center; line-height:1.45;}
.gate-legal a{color:inherit; text-decoration:underline; text-underline-offset:2px;}
.gate-setup{
  margin-top:18px; font-size:12px; color:var(--ink-soft);
  background:#f7f5ef; border:1px solid var(--rule); border-radius:8px; padding:12px 13px; line-height:1.55;
}
.gate-setup code{font-family:ui-monospace,Menlo,monospace; font-size:11.5px;}

.boot{
  position:fixed; inset:0; display:flex; align-items:center; justify-content:center;
  background:var(--page); color:var(--ink-soft); font-size:14px; z-index:60;
}
.boot[hidden]{display:none;}

/* ---------- Crash screen (global error boundary) ---------- */
.crash{
  position:fixed; inset:0; z-index:100; display:flex; align-items:center; justify-content:center;
  background:var(--page); padding:24px;
}
.crash[hidden]{display:none;}
.crash-card{
  max-width:440px; width:100%; background:var(--card); border:1px solid var(--rule);
  border-radius:16px; padding:32px 28px; text-align:center;
  box-shadow:0 12px 40px rgba(0,0,0,.10);
}
.crash-mark{
  font-family:'Fraunces',Georgia,serif; font-weight:700; font-size:40px; color:var(--chemistry);
  line-height:1; margin-bottom:14px;
}
.crash-card h1{font-size:22px; margin-bottom:10px; color:var(--ink);}
.crash-card p{color:var(--ink-soft); font-size:14.5px; line-height:1.5; margin:0 0 20px;}
.crash-actions{display:flex; justify-content:center; gap:10px;}
.crash-primary{
  border:none; background:var(--spine); color:var(--spine-text); font-weight:600;
  padding:11px 22px; border-radius:10px; cursor:pointer; font-size:14.5px;
}
.crash-primary:hover{opacity:.92;}
.crash-details{margin-top:20px; text-align:left;}
.crash-details summary{cursor:pointer; color:var(--ink-soft); font-size:12.5px;}
.crash-details pre{
  white-space:pre-wrap; word-break:break-word; font-size:11px; color:var(--ink-soft);
  background:var(--page); border:1px solid var(--rule); border-radius:8px;
  padding:10px; margin-top:8px; max-height:180px; overflow:auto;
}

/* ---------- Storage notice (we use no cookies) ---------- */
.storenote{
  position:fixed; left:12px; right:12px; bottom:12px; z-index:70;
  max-width:560px; margin:0 auto; display:flex; align-items:center; gap:14px;
  background:var(--spine); color:var(--spine-text); border-radius:12px;
  padding:12px 14px; box-shadow:0 8px 30px rgba(0,0,0,.18); font-size:13px; line-height:1.4;
}
.storenote[hidden]{display:none;}
body{padding-bottom:var(--notice-h, 0px);}
.storenote-text{flex:1;}
.storenote-text strong{color:#fff;}
.storenote-ok{
  flex:none; border:1px solid rgba(255,255,255,.35); background:transparent;
  color:var(--spine-text); font-weight:600; padding:8px 14px; border-radius:8px;
  cursor:pointer; font-size:13px;
}
.storenote-ok:hover{background:rgba(255,255,255,.10);}
.storenote-link{color:var(--spine-text); font-weight:600; text-decoration:underline; text-underline-offset:2px; white-space:nowrap;}

/* ---------- Themes (default :root above is "Paper") ---------- */
/* Light palettes */
html[data-theme="light"]{
  --page:#EEF1F4; --card:#FFFFFF; --ink:#1E2427; --ink-soft:#586067;
  --rule:#D8DDE3; --spine:#242B32;
}
html[data-theme="ocean"]{
  --page:#EAF2F7; --card:#FFFFFF; --ink:#16303B; --ink-soft:#557080;
  --rule:#CBDDE7; --spine:#123A4A;
}
html[data-theme="rose"]{
  --page:#FBEFF1; --card:#FFFFFF; --ink:#3A2830; --ink-soft:#7C5B65;
  --rule:#EED3D9; --spine:#5A2A3A;
}
/* Dark palettes */
html[data-theme="dark"]{
  --page:#15181B; --card:#1E2429; --ink:#E9E9E3; --ink-soft:#9AA2A8;
  --rule:#2F363C; --spine:#10151A; --spine-text:#EDEDE6; --spine-text-dim:#8C959C;
}
html[data-theme="forest"]{
  --page:#0F140F; --card:#18201A; --ink:#E6ECE3; --ink-soft:#9DAE9C;
  --rule:#293528; --spine:#0B120D; --spine-text:#EAEFE6; --spine-text-dim:#8DA08C;
}
html[data-theme="grape"]{
  --page:#15111C; --card:#1E1827; --ink:#EAE5F1; --ink-soft:#A99FB6;
  --rule:#312A3D; --spine:#100C17; --spine-text:#EBE7F2; --spine-text-dim:#A096AE;
}
/* Pastels — soft page tints, a deeper matching sidebar. Every text colour is
   at least 4.5:1 against its background (WCAG AA). */
html[data-theme="blush"]{
  --page:#FDF0F4; --card:#FFFFFF; --ink:#3B2530; --ink-soft:#7A5566;
  --rule:#F3D3DF; --spine:#8E3F63; --spine-text:#FFFFFF; --spine-text-dim:#F6DCE7;
}
html[data-theme="lavender"]{
  --page:#F4F1FB; --card:#FFFFFF; --ink:#2E2640; --ink-soft:#675C82;
  --rule:#E0D8F2; --spine:#5A4A8A; --spine-text:#FFFFFF; --spine-text-dim:#E3DCF5;
}
html[data-theme="mint"]{
  --page:#EEF8F3; --card:#FFFFFF; --ink:#1F3A30; --ink-soft:#4E6B5B;
  --rule:#D2EADF; --spine:#2E6A54; --spine-text:#FFFFFF; --spine-text-dim:#D6EFE4;
}
html[data-theme="peach"]{
  --page:#FFF3EB; --card:#FFFFFF; --ink:#3D2A20; --ink-soft:#7A5A49;
  --rule:#F5DCCB; --spine:#9A5237; --spine-text:#FFFFFF; --spine-text-dim:#FBE3D6;
}
html[data-theme="sky"]{
  --page:#EEF5FC; --card:#FFFFFF; --ink:#1E3047; --ink-soft:#526B88;
  --rule:#D3E3F3; --spine:#3A6394; --spine-text:#FFFFFF; --spine-text-dim:#DCE8F6;
}
html[data-theme="butter"]{
  --page:#FFFBEA; --card:#FFFFFF; --ink:#3A3218; --ink-soft:#6E6134;
  --rule:#F1E7BF; --spine:#6F5E1C; --spine-text:#FFFFFF; --spine-text-dim:#F4ECCB;
}
/* Black — simple, high-contrast. Mono is black-on-white; Midnight is true
   black (easy on OLED phones); Graphite is a softer charcoal. */
html[data-theme="mono"]{
  --page:#FFFFFF; --card:#FFFFFF; --ink:#111111; --ink-soft:#555555;
  --rule:#E3E3E3; --spine:#111111; --spine-text:#FFFFFF; --spine-text-dim:#B0B0B0; --focus:#111111;
}
html[data-theme="midnight"]{
  --page:#000000; --card:#0E0E0E; --ink:#F2F2F2; --ink-soft:#A6A6A6;
  --rule:#262626; --spine:#000000; --spine-text:#F5F5F5; --spine-text-dim:#9C9C9C; --field:#151515;
}
/* Sidebar and page are both black: a hairline keeps them apart. */
html[data-theme="midnight"] .spine{ box-shadow:inset -1px 0 0 #262626; }
@media (max-width: 760px){ html[data-theme="midnight"] .spine{ box-shadow:inset 0 -1px 0 #262626; } }
html[data-theme="graphite"]{
  --page:#1B1B1B; --card:#252525; --ink:#EDEDED; --ink-soft:#ABABAB;
  --rule:#343434; --spine:#121212; --spine-text:#F0F0F0; --spine-text-dim:#9E9E9E; --field:#1E1E1E;
}
/* Theme groups in Settings */
.theme-group{margin-top:10px;}
.theme-group:first-of-type{margin-top:0;}
.theme-group-label{display:block; font-size:11px; font-weight:700; letter-spacing:.07em; text-transform:uppercase; color:var(--ink-soft); margin-bottom:6px;}
/* Component tweaks shared by every dark palette (applyTheme adds .theme-dark). */
html.theme-dark .qa-row input,
html.theme-dark .qa-row select,
html.theme-dark .qa-row textarea{ background:var(--field, #171C21); color:var(--ink); }
/* Only recolor the *inactive* toggle buttons, so active states keep their fill. */
html.theme-dark .qa-actions button,
html.theme-dark .course-level button:not(.active),
html.theme-dark .opt-btn:not(.active),
html.theme-dark .lvl-set:not(.active){ background:var(--field, #171C21); color:var(--ink-soft); }
/* --focus is a dark ink; on dark palettes swap filled controls to light-on-dark. */
html.theme-dark .rot-daychip.active, html.theme-dark .cm-chip.active,
html.theme-dark .rot-skip-add{ background:var(--ink); color:var(--page); border-color:var(--ink); }
html.theme-dark .sw-row.today{ border-color:var(--ink); box-shadow:inset 0 0 0 1px var(--ink); }
html.theme-dark .setup-save{ background:var(--ink); color:var(--page); }

/* ---------- Class colour swatch + picker ---------- */
.class-color{
  width:28px; height:28px; border-radius:50%; padding:0; cursor:pointer;
  border:2px solid var(--card); box-shadow:0 0 0 1px var(--rule); flex-shrink:0;
}
.class-color:hover{box-shadow:0 0 0 2px var(--ink-soft);}
.color-pop{
  position:fixed; z-index:70; background:var(--card); color:var(--ink);
  border:1px solid var(--rule); border-radius:12px; padding:12px;
  box-shadow:0 14px 44px rgba(0,0,0,0.28);
}
.color-pop .cp-grid{display:grid; grid-template-columns:repeat(6, 1fr); gap:9px;}
.color-pop .cp-sw{
  width:28px; height:28px; border-radius:50%; border:none; cursor:pointer; padding:0;
  box-shadow:0 0 0 1px rgba(0,0,0,0.18) inset;
}
.color-pop .cp-sw.active{outline:2px solid var(--ink); outline-offset:2px;}
.color-pop .cp-default{
  margin-top:11px; width:100%; font-size:12.5px; padding:8px; border-radius:8px;
  border:1px solid var(--rule); background:transparent; color:var(--ink-soft); cursor:pointer;
}
.color-pop .cp-default:hover{border-color:var(--ink-soft); color:var(--ink);}

/* ---------- Class level toggle ---------- */
.class-level{display:inline-flex; gap:5px;}
.lvl-set{
  border:1px solid var(--rule); background:#fff; color:var(--ink-soft);
  padding:6px 16px; border-radius:20px; font-size:13px; cursor:pointer; font-weight:500;
}
.lvl-set.active{ background:var(--accent, var(--ink)); border-color:var(--accent, var(--ink)); color:#fff; }

/* ---------- Files ---------- */
.files-section{margin-bottom:28px;}
.files-head{display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:12px;}
.files-head h3{font-size:16px; font-weight:600;}
.upload-btn{
  display:inline-block; background:var(--accent,#333); color:#fff;
  padding:8px 15px; border-radius:7px; font-size:13px; font-weight:500; cursor:pointer;
}
.upload-btn:hover{opacity:0.92;}
.files-grid{display:grid; grid-template-columns:repeat(auto-fill, minmax(250px,1fr)); gap:10px;}
.file-card{
  background:var(--card); border:1px solid var(--rule);
  border-left:3px solid var(--accent,#999); border-radius:7px;
  padding:10px 12px; display:flex; align-items:center; gap:10px;
}
.file-card .fi{font-size:20px; line-height:1; flex-shrink:0;}
.file-card .fmeta{flex:1; min-width:0;}
.file-card .fmeta h5{font-size:13.5px; font-weight:600; margin:0 0 2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.file-card .fmeta span{font-size:11px; color:var(--ink-soft);}
.file-open{
  background:var(--accent,#333); color:#fff; border:none;
  padding:6px 12px; border-radius:6px; font-size:12.5px; cursor:pointer; flex-shrink:0;
}
.file-open:hover{opacity:0.9;}
.upload-hint{font-size:11.5px; color:var(--ink-soft); margin-top:10px; line-height:1.5;}

/* ---------- Search ---------- */
.search-box{
  width:100%; font-family:inherit; font-size:15px; padding:12px 14px;
  border:1px solid var(--rule); border-radius:10px; background:var(--card); color:var(--ink);
  margin-bottom:18px;
}
.search-box:focus{ outline:2px solid var(--ink-soft); outline-offset:1px; }

/* ---------- Accessibility (WCAG 2.1 AA) ---------- */
/* Visible keyboard focus on every interactive element (2.4.7). Uses the ink
   colour on light surfaces and the light spine text on the dark sidebar so
   the ring always has contrast. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible,
summary:focus-visible, [role="button"]:focus-visible{
  outline:2.5px solid var(--ink); outline-offset:2px; border-radius:5px;
}
.spine a:focus-visible, .spine button:focus-visible{ outline-color:var(--spine-text); }
/* Respect a request for reduced motion (2.3.3 / 2.2.2): drop the tab slide-in
   and any transitions/animations rather than force movement. */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration:.001ms !important; animation-iteration-count:1 !important;
    transition-duration:.001ms !important; scroll-behavior:auto !important;
  }
  .tab{ opacity:1 !important; transform:none !important; }
}
/* Visually-hidden helper for screen-reader-only text. */
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden;
  clip:rect(0,0,0,0); white-space:nowrap; border:0;
}
.search-list{list-style:none; margin:0; padding:0;}
.search-item{
  display:flex; align-items:center; gap:11px; padding:11px 12px; cursor:pointer;
  border:1px solid var(--rule); border-radius:9px; margin-bottom:8px; background:var(--card);
}
.search-item:hover{border-color:var(--ink-soft);}
.search-item .si-ico{font-size:16px; flex-shrink:0;}
.search-item .si-flag{width:8px; height:8px; border-radius:2px; flex-shrink:0;}
.search-item .si-main{min-width:0; flex:1;}
.search-item .si-title{display:block; font-size:14px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.search-item .si-sub{display:block; font-size:12px; color:var(--ink-soft); margin-top:1px;}

/* ---------- Calendar ---------- */
.cal-nav{display:flex; align-items:center; gap:8px;}
.cal-nav .cal-month{font-size:14px; font-weight:600; min-width:150px; text-align:center;}
.cal-btn{
  border:1px solid var(--rule); background:var(--card); color:var(--ink);
  border-radius:7px; padding:6px 11px; font-size:13px; cursor:pointer; line-height:1;
}
.cal-btn:hover{border-color:var(--ink-soft);}
/* minmax(0,1fr) keeps all 7 columns equal even when a cell holds a no-wrap
   pill — without it, one long title stretches its column and squashes the rest. */
.cal-grid{display:grid; grid-template-columns:repeat(7, minmax(0, 1fr)); gap:6px;}
.cal-head{font-size:11px; font-weight:600; color:var(--ink-soft); text-align:center; padding:4px 0;}
.cal-cell{
  min-width:0;
  min-height:92px; border:1px solid var(--rule); border-radius:8px; background:var(--card);
  padding:6px; display:flex; flex-direction:column; gap:4px;
}
.cal-cell.empty{background:transparent; border:none;}
.cal-cell.today{outline:2px solid var(--ink); outline-offset:-1px;}
/* Day number and rotation badge share the top row via flex, so they can never
   overlap however narrow the cell gets. */
.cal-daytop{display:flex; align-items:center; justify-content:space-between; gap:3px; min-width:0;}
.cal-rot{
  flex:none; font-size:10px; font-weight:700; color:var(--ink);
  background:rgba(128,128,128,.14); border-radius:5px; padding:1px 5px;
  letter-spacing:.01em; line-height:1.4;
}
.cal-rot.off{color:var(--ink-soft); font-weight:600;}
.cal-cell .cal-day{font-size:12px; font-weight:600; color:var(--ink-soft);}
.cal-cell.today .cal-day{color:var(--ink);}
.cal-pill{
  display:flex; align-items:center; gap:5px; width:100%; min-width:0; max-width:100%; text-align:left; cursor:pointer;
  border:none; background:rgba(128,128,128,0.12);
  color:var(--ink); border-left:3px solid var(--accent);
  border-radius:5px; padding:3px 6px; font-size:11px; line-height:1.25;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-family:inherit;
}
/* A day with assessments is one button (the pills inside are labels): a big,
   easy target on phones, opening the day's list below the grid. */
button.cal-cell{
  font:inherit; color:var(--ink); text-align:left; cursor:pointer; width:100%;
  -webkit-appearance:none; appearance:none; align-items:stretch;
}
button.cal-cell:hover{border-color:var(--ink-soft);}
button.cal-cell:hover .cal-pill{background:rgba(128,128,128,0.22);}
/* Selected day: shaded fill (today keeps its outline), so the two never look alike. */
button.cal-cell.open{background:rgba(128,128,128,0.2); border-color:var(--ink-soft);}
.cal-dayview{
  background:var(--card); border:1px solid var(--rule); border-radius:10px;
  padding:12px 16px 14px; margin:16px 0 6px;
}
.cdv-head{display:flex; align-items:center; justify-content:space-between; gap:10px;}
.cdv-head h3{font-size:16px; font-weight:600; margin:0;}
.cdv-close{
  flex:none; border:1px solid var(--rule); background:transparent; color:var(--ink-soft);
  width:34px; height:34px; border-radius:8px; font-size:20px; line-height:1; cursor:pointer;
}
.cdv-close:hover{color:var(--ink); border-color:var(--ink-soft);}
.cdv-actions{display:flex; flex-wrap:wrap; gap:8px; margin-top:12px;}
.cdv-go{
  border:1px solid var(--ink); background:var(--ink); color:var(--page); font:inherit; font-size:13px; font-weight:600;
  padding:8px 14px; border-radius:8px; cursor:pointer;
}
.cdv-go:hover{opacity:.9;}
.cdv-add{
  border:1px solid var(--rule); background:transparent; color:var(--ink); font:inherit; font-size:13px;
  padding:8px 13px; border-radius:8px; cursor:pointer;
}
.cdv-add:hover{border-color:var(--ink-soft);}
.cal-pill .cal-dot{width:6px; height:6px; border-radius:50%; flex-shrink:0;}
.cal-pill.done{opacity:0.5; text-decoration:line-through;}
.cal-pill.overdue{border-left-color:#C0392B;}
@media (max-width: 760px){
  .cal-grid{gap:4px;}
  .cal-cell{min-height:60px; padding:4px;}
  .cal-cell .cal-day{font-size:11px;}
  .cal-rot{font-size:8.5px; padding:0 3px; letter-spacing:0;}
  .cal-pill{font-size:9.5px; padding:2px 4px; gap:3px;}
  .cal-head{font-size:10px;}
  .cal-nav .cal-month{min-width:110px; font-size:13px;}
}

/* ---------- Rotating day schedule ---------- */
.rot-today{margin:0 0 12px;}
.rot-chip{
  display:inline-flex; align-items:center; gap:10px; flex-wrap:wrap;
  background:var(--card); border:1px solid var(--rule); border-radius:10px;
  padding:8px 14px; font-size:13.5px; color:var(--ink);
}
.rot-chip b{font-size:14px;}
.rot-chip.off{color:var(--ink-soft);}
.rot-chip-classes{color:var(--ink-soft); font-size:12.5px;}
.rot-field{margin-top:14px;}
.rot-field > label{display:block; font-size:12.5px; font-weight:600; color:var(--ink); margin-bottom:6px;}
.rot-field .rot-sub{font-weight:400; color:var(--ink-soft);}
.rot-field input[type="number"]{
  width:80px; padding:7px 9px; border:1px solid var(--rule); border-radius:8px;
  background:var(--card); color:var(--ink); font-family:inherit; font-size:14px;
}
.rot-days{display:flex; flex-wrap:wrap; gap:6px;}
.rot-daychip, .cm-chip{
  border:1px solid var(--rule); background:var(--card); color:var(--ink-soft);
  border-radius:8px; padding:6px 10px; font-size:12.5px; font-weight:600; cursor:pointer; font-family:inherit;
}
.rot-daychip.active, .cm-chip.active{
  background:var(--focus); color:#fff; border-color:var(--focus);
}
.rot-anchor{display:flex; align-items:center; flex-wrap:wrap; gap:8px; font-size:13.5px; color:var(--ink);}
.rot-anchor input[type="date"], .rot-anchor select, .rot-skipadd input[type="date"]{
  padding:7px 9px; border:1px solid var(--rule); border-radius:8px;
  background:var(--card); color:var(--ink); font-family:inherit; font-size:13.5px;
}
.rot-warn{margin:8px 0 0; font-size:12.5px; color:#C0392B;}
.rot-skipadd{display:flex; gap:8px; align-items:center;}
.rot-skip-add{
  border:none; background:var(--focus); color:#fff; font-weight:600; font-family:inherit;
  padding:8px 14px; border-radius:8px; cursor:pointer; font-size:13px;
}
.rot-skiplist{display:flex; flex-wrap:wrap; gap:6px; margin-top:10px;}
.rot-skip{
  display:inline-flex; align-items:center; gap:6px; background:rgba(128,128,128,.12);
  border-radius:8px; padding:4px 6px 4px 10px; font-size:12.5px; color:var(--ink);
}
.rot-skip-del{
  border:none; background:transparent; color:var(--ink-soft); cursor:pointer;
  font-size:16px; line-height:1; padding:0 2px;
}
.rot-skip-del:hover{color:#C0392B;}
.rot-preview{margin-top:14px;}
.course-meets{margin-top:10px; padding-top:10px; border-top:1px solid var(--rule);}
.cm-label{display:block; font-size:11.5px; font-weight:600; color:var(--ink-soft); margin-bottom:8px;}
.cm-chip{padding:5px 9px; text-align:center;}
.cm-daygrid{display:flex; flex-direction:column; gap:5px;}
.cm-dayrow{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.cm-dayrow .cm-chip{min-width:56px; flex:none;}
.cm-dayrow:not(.on) .cm-chip{opacity:.6;}   /* dim the days not ticked */
/* Only a ticked day reveals its time inputs — keeps each course compact
   instead of listing an empty time row for all six rotation days. */
.cm-dayrow .cm-time-row{display:none;}
.cm-dayrow.on .cm-time-row{display:flex; align-items:center; gap:6px;}
.cm-start, .cm-end{
  width:120px; padding:6px 8px; border:1px solid var(--rule); border-radius:8px;
  background:var(--card); color:var(--ink); font-family:inherit; font-size:12.5px;
}
.cm-dash{color:var(--ink-soft);}
.rc-time{color:var(--ink-soft); font-weight:400;}

/* ---------- Weekly schedule (Schedule tab) ---------- */
.sched-empty{
  background:var(--card); border:1px dashed var(--rule); border-radius:12px;
  padding:18px; color:var(--ink-soft); font-size:14px; line-height:1.5; margin-bottom:8px;
}
.sched-weekhead{display:flex; align-items:center; gap:8px; margin-bottom:12px;}
.sched-range{font-weight:600; color:var(--ink); min-width:130px; text-align:center; font-size:14px;}
.sw-list{display:flex; flex-direction:column; gap:8px;}
.sw-row{
  display:flex; gap:14px; align-items:flex-start;
  background:var(--card); border:1px solid var(--rule); border-radius:10px; padding:12px 14px;
}
.sw-row.today{border-color:var(--focus); box-shadow:inset 0 0 0 1px var(--focus);}
.sw-row.muted{opacity:.6;}
.sw-date{flex:none; width:58px; display:flex; flex-direction:column; line-height:1.15;}
.sw-wd{font-weight:700; font-size:13px; color:var(--ink);}
.sw-dm{font-size:12px; color:var(--ink-soft);}
.sw-body{flex:1; display:flex; flex-direction:column; gap:8px; min-width:0;}
.sw-daytag{
  align-self:flex-start; font-size:11px; font-weight:700; letter-spacing:.02em;
  color:var(--ink); background:rgba(128,128,128,.14); border-radius:5px; padding:2px 7px;
}
.sw-classes{display:flex; flex-wrap:wrap; gap:6px;}
.sw-class{
  display:inline-flex; align-items:baseline; gap:6px; font-size:13px; color:var(--ink);
  background:rgba(128,128,128,.10); border-radius:7px; padding:4px 9px;
}
.sw-time{color:var(--ink-soft); font-size:12px;}
.sw-off, .sw-none{color:var(--ink-soft); font-size:13px; font-style:italic;}

/* ---------- Grades ---------- */
.grade-summary{display:flex; flex-wrap:wrap; gap:14px; margin-bottom:22px;}
.grade-summary .gs-stat{
  background:var(--card); border:1px solid var(--rule); border-radius:10px;
  padding:14px 18px; min-width:150px;
}
.gs-num{display:block; font-family:'Fraunces',Georgia,serif; font-size:30px; font-weight:600; color:var(--ink); line-height:1;}
.gs-den{font-size:16px; color:var(--ink-soft); font-weight:500;}
.gs-label{display:block; font-size:12px; color:var(--ink-soft); margin-top:7px;}
.gs-core{
  display:flex; flex-direction:column; gap:6px; justify-content:center; font-size:12px; color:var(--ink-soft);
  background:var(--card); border:1px solid var(--rule); border-radius:10px; padding:12px 16px;
}
.gs-core select, .grade-pred select{
  font-family:inherit; font-size:14px; padding:6px 8px; border:1px solid var(--rule);
  border-radius:6px; background:#fffefb; color:var(--ink);
}
.grade-bars{margin-bottom:26px;}
.gbar-row{display:flex; align-items:center; gap:12px; margin-bottom:8px;}
.gbar-name{width:96px; font-size:13px; color:var(--ink); flex-shrink:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.gbar-track{flex:1; height:10px; background:rgba(128,128,128,0.14); border-radius:6px; overflow:hidden;}
.gbar-fill{display:block; height:100%; border-radius:6px; min-width:2px; transition:width .3s ease;}
.gbar-val{width:46px; text-align:right; font-size:12.5px; color:var(--ink-soft); flex-shrink:0;}
.grade-subject{
  background:var(--card); border:1px solid var(--rule); border-left:3px solid var(--accent,#999);
  border-radius:9px; padding:14px 16px; margin-bottom:14px;
}
.grade-head{display:flex; align-items:center; gap:10px; flex-wrap:wrap;}
.grade-flag{width:9px; height:9px; border-radius:2px; flex-shrink:0;}
.grade-head h3{font-size:16px; font-weight:600; flex:1; min-width:120px;}
.grade-avg{font-size:13px; color:var(--ink-soft);}
.grade-pred{display:flex; align-items:center; gap:6px; font-size:12px; color:var(--ink-soft);}
.grade-spark{margin:10px 0 4px;}
.spark{display:block;}
.spark-base{stroke:var(--rule); stroke-width:1;}
.grade-rows{margin:6px 0;}
.grade-row{display:flex; align-items:center; gap:10px; padding:6px 0; border-bottom:1px solid var(--rule); font-size:13.5px;}
.grade-row:last-child{border-bottom:none;}
.grade-title{flex:1; min-width:0; overflow-wrap:anywhere;}
.grade-score{color:var(--ink-soft); font-size:12.5px; white-space:nowrap;}
.grade-date{color:var(--ink-soft); font-size:12px; width:60px; text-align:right; flex-shrink:0;}
.grade-add{display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-top:12px;}
.grade-add input{font-family:inherit; font-size:13px; padding:7px 8px; border:1px solid var(--rule); border-radius:6px; background:#fffefb; color:var(--ink);}
.grade-add .ga-title{flex:1; min-width:130px;}
.grade-add .ga-score, .grade-add .ga-outof{width:76px;}
.grade-add .ga-slash{color:var(--ink-soft);}
.grade-add .ga-add{
  background:var(--accent,var(--ink)); color:#fff; border:none; border-radius:6px;
  padding:8px 15px; font-size:13px; font-weight:500; cursor:pointer;
}
.grade-add .ga-weight{width:92px;}
.grade-add .ga-add:hover{opacity:.92;}
/* Headline computed grade */
.grade-mark{display:inline-flex; align-items:baseline; gap:5px; font-size:13px; color:var(--ink-soft);}
.grade-num{font-family:'Fraunces',Georgia,serif; font-size:22px; font-weight:600; color:var(--ink); line-height:1;}
.grade-of{font-size:12px; color:var(--ink-soft); margin-left:-3px;}
.grade-pct{font-size:11px; color:var(--ink-soft); background:rgba(128,128,128,0.12); padding:2px 6px; border-radius:20px;}
.grade-target{font-size:13px; color:var(--ink); margin:8px 0 2px; padding:8px 10px; background:rgba(192,57,43,0.07); border-radius:8px;}
.grade-target b{font-weight:700;}
/* What-if slider */
.whatif{margin:10px 0 2px; padding:9px 12px; background:rgba(63,125,76,0.08); border-radius:8px;}
.wi-label{display:block; font-size:13px; color:var(--ink); margin-bottom:6px;}
.wi-label b{font-weight:700;}
.wi-slider{-webkit-appearance:none; appearance:none; width:100%; height:5px; border-radius:3px; background:var(--rule); cursor:pointer;}
.wi-slider::-webkit-slider-thumb{-webkit-appearance:none; appearance:none; width:18px; height:18px; border-radius:50%; background:var(--accent,#3F7D4C); border:2px solid var(--card); box-shadow:0 0 0 1px var(--rule); cursor:pointer;}
.wi-slider::-moz-range-thumb{width:18px; height:18px; border-radius:50%; background:var(--accent,#3F7D4C); border:2px solid var(--card); cursor:pointer;}
/* Editable boundaries */
.grade-bounds{margin-top:12px; font-size:12.5px; color:var(--ink-soft);}
.grade-bounds summary{cursor:pointer; user-select:none;}
.gb-grid{display:flex; flex-wrap:wrap; gap:8px; margin-top:10px;}
.gb-cell{display:flex; flex-direction:column; align-items:center; gap:3px; font-size:11px; color:var(--ink-soft);}
.gb-cell input{width:56px; font:inherit; font-size:13px; text-align:center; padding:6px 4px; border:1px solid var(--rule); border-radius:6px; background:#fffefb; color:var(--ink);}
.gb-note{margin:8px 0 0; font-size:11.5px; color:var(--ink-soft);}
html.theme-dark .gs-core select, html.theme-dark .grade-pred select,
html.theme-dark .grade-add input, html.theme-dark .grade-add select, html.theme-dark .gb-cell input,
html.theme-dark .as-enter input{background:var(--field, #171C21);}
@media (max-width:760px){ .grade-add .ga-title, .grade-add .ca-title{min-width:100%;} }
/* Assessment add-row extras */
.grade-add select, .grade-add .ca-title{font-family:inherit; font-size:13px; padding:7px 8px; border:1px solid var(--rule); border-radius:6px; background:#fffefb; color:var(--ink);}
.grade-add .ca-title{flex:1; min-width:150px;}
.grade-add .ca-weight, .grade-add .ga-weight{width:92px;}
/* Upcoming (ungraded) assessment rows with inline result entry */
.grade-row.upcoming{flex-wrap:wrap; gap:8px;}
.up-tag{font-size:11px; color:var(--ink-soft); background:rgba(128,128,128,0.12); padding:1px 7px; border-radius:20px; margin-left:4px; white-space:nowrap;}
.as-enter{display:flex; align-items:center; gap:5px; margin-left:auto;}
.as-enter input{width:70px; font-family:inherit; font-size:13px; padding:6px 7px; border:1px solid var(--rule); border-radius:6px; background:#fffefb; color:var(--ink);}
.as-save{background:var(--accent,var(--ink)); color:#fff; border:none; border-radius:6px; padding:7px 12px; font-size:13px; cursor:pointer;}
/* Upcoming list on the calendar */
.up-list{list-style:none; margin:4px 0 0; padding:0;}
.up-item{display:flex; align-items:center; gap:10px; padding:9px 0; border-bottom:1px solid var(--rule);}
.up-item:last-child{border-bottom:none;}
.up-flag{width:9px; height:9px; border-radius:2px; flex-shrink:0;}
.up-main{flex:1; min-width:0;}
.up-title{display:block; font-size:14px; color:var(--ink); overflow-wrap:anywhere;}
.up-sub{display:block; font-size:12px; color:var(--ink-soft);}
.up-when{font-size:12px; color:var(--ink-soft); white-space:nowrap; flex-shrink:0;}
.up-item.overdue .up-when{color:#C0392B; font-weight:600;}
.up-done{background:none; border:1px solid var(--rule); color:var(--ink-soft); border-radius:6px; width:28px; height:28px; cursor:pointer; flex-shrink:0;}
.up-done:hover{border-color:#3F7D4C; color:#3F7D4C;}
.cal-add{margin:22px 0 8px;}
/* Spotify accent swatch (settings) */
.sp-sw{width:30px; height:30px; border-radius:8px; border:2px solid transparent; box-shadow:0 0 0 1px var(--rule); cursor:pointer;}
.sp-sw.active{border-color:var(--ink); box-shadow:0 0 0 1px var(--ink);}

/* ---------- Flashcards ---------- */
.deck-create{display:flex; gap:8px; flex-wrap:wrap; margin-bottom:18px;}
.deck-create .deck-name-input{flex:1; min-width:180px; font-family:inherit; font-size:14px; padding:9px 11px; border:1px solid var(--rule); border-radius:8px; background:var(--card); color:var(--ink);}
.deck-create select{font-family:inherit; font-size:14px; padding:9px 10px; border:1px solid var(--rule); border-radius:8px; background:var(--card); color:var(--ink);}
.deck-list{display:flex; flex-direction:column; gap:10px;}
.deck-card{display:flex; align-items:center; gap:11px; background:var(--card); border:1px solid var(--rule); border-left:3px solid var(--accent,#999); border-radius:9px; padding:12px 14px;}
.deck-flag{width:9px; height:9px; border-radius:2px; flex-shrink:0;}
.deck-main{flex:1; min-width:0;}
.deck-name{font-size:15px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.deck-sub{font-size:12px; color:var(--ink-soft); margin-top:1px;}
.deck-study{background:var(--accent,#333); color:#fff; border:none; border-radius:7px; padding:7px 14px; font-size:13px; font-weight:500; cursor:pointer;}
.deck-study:hover{opacity:.92;}
.deck-open{background:transparent; border:1px solid var(--rule); color:var(--ink); border-radius:7px; padding:7px 12px; font-size:13px; cursor:pointer;}
.deck-open:hover{border-color:var(--ink-soft);}
.fc-rows{display:flex; flex-direction:column; gap:8px; margin-bottom:16px;}
.fc-row{display:flex; align-items:stretch; gap:10px; background:var(--card); border:1px solid var(--rule); border-radius:8px; padding:10px 12px;}
.fc-cell{flex:1; min-width:0; font-size:13.5px; color:var(--ink); white-space:pre-wrap; word-break:break-word;}
.fc-side{display:block; font-size:10px; text-transform:uppercase; letter-spacing:0.05em; color:var(--ink-soft); margin-bottom:2px;}
.fc-add{display:flex; gap:8px; flex-wrap:wrap; align-items:flex-start;}
.fc-input{flex:1; min-width:160px; font-family:inherit; font-size:13.5px; padding:9px 11px; border:1px solid var(--rule); border-radius:8px; background:var(--card); color:var(--ink); resize:vertical; min-height:48px;}
.fc-progress{height:5px; background:rgba(128,128,128,0.16); border-radius:3px; overflow:hidden; margin-bottom:20px;}
.fc-progress-fill{height:100%; border-radius:3px; transition:width .3s ease;}
.fc-study{max-width:560px; margin:0 auto;}
.fc-card{
  width:100%; min-height:230px; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:14px; text-align:center; cursor:pointer; padding:28px 24px;
  background:var(--card); border:1px solid var(--rule); border-top:4px solid var(--accent,#999);
  border-radius:14px; box-shadow:0 4px 16px rgba(0,0,0,0.06); color:var(--ink); font-family:inherit;
}
.fc-card .fc-face{font-size:20px; font-weight:600; line-height:1.4; white-space:pre-wrap; word-break:break-word;}
.fc-card.flipped .fc-face{font-weight:500;}
.fc-card .fc-hint{font-size:12px; color:var(--ink-soft);}
.fc-actions{display:flex; gap:12px; margin-top:16px; justify-content:center;}
.fc-actions button{padding:12px 26px; border-radius:9px; font-size:15px; font-weight:600; cursor:pointer; border:1px solid var(--rule); font-family:inherit;}
.fc-again{background:transparent; color:var(--ink);}
.fc-again:hover{border-color:var(--ink-soft);}
.fc-got{background:var(--accent,var(--ink)); border-color:var(--accent,var(--ink)); color:#fff;}
.fc-done{max-width:460px; margin:40px auto 0; text-align:center;}
.fc-done-emoji{font-size:44px;}
.fc-done h3{font-size:22px; margin:8px 0 4px;}
.fc-done p{color:var(--ink-soft); font-size:14px;}
.fc-done-actions{display:flex; gap:12px; justify-content:center; margin-top:18px;}
html.theme-dark .fc-input, html.theme-dark .deck-create .deck-name-input, html.theme-dark .deck-create select{background:var(--field, #171C21);}

/* ---------- Study timer ---------- */
.timer-card{
  background:var(--card); border:1px solid var(--rule); border-radius:16px;
  padding:20px 18px 22px; margin-bottom:22px;
  display:flex; flex-direction:column; align-items:center; gap:6px;
}
.tm-controls-top{display:flex; flex-wrap:wrap; gap:14px; justify-content:center; align-items:flex-end; width:100%;}
.tm-subj{display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--ink-soft); font-weight:600;}
.tm-subj select{
  font:inherit; font-size:14px; color:var(--ink); background:transparent;
  border:1px solid var(--rule); border-radius:8px; padding:7px 10px; min-width:150px;
}
.tm-presets{display:flex; align-items:center; gap:6px;}
.tm-preset{
  font:inherit; font-size:13px; color:var(--ink); background:transparent;
  border:1px solid var(--rule); border-radius:8px; padding:7px 11px; cursor:pointer;
}
.tm-preset.active{background:var(--ink); color:var(--card); border-color:var(--ink);}
.tm-preset:disabled{opacity:.5; cursor:default;}
.tm-custom{
  font:inherit; font-size:13px; width:64px; color:var(--ink); background:transparent;
  border:1px solid var(--rule); border-radius:8px; padding:7px 8px;
}
.tm-ring{
  --frac:0; width:230px; height:230px; border-radius:50%; margin:12px auto 6px;
  background:conic-gradient(var(--ring) calc(var(--frac) * 360deg), rgba(128,128,128,0.16) 0);
  display:flex; align-items:center; justify-content:center; transition:background .35s linear;
}
.tm-ring-inner{
  width:182px; height:182px; border-radius:50%; background:var(--card);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
  box-shadow:inset 0 0 0 1px var(--rule);
}
.tm-display{font-family:'Fraunces',Georgia,serif; font-size:46px; font-weight:600; color:var(--ink); line-height:1; font-variant-numeric:tabular-nums;}
.tm-state{font-size:12px; color:var(--ink-soft); text-transform:uppercase; letter-spacing:.08em;}
.tm-logged{font-size:13px; color:var(--ink-soft); font-weight:600;}
.tm-buttons{display:flex; gap:10px; margin-top:8px;}
.tm-go{
  font:inherit; font-size:15px; font-weight:600; color:#fff; background:var(--accent);
  border:none; border-radius:10px; padding:11px 30px; cursor:pointer;
}
.tm-reset{
  font:inherit; font-size:15px; color:var(--ink); background:transparent;
  border:1px solid var(--rule); border-radius:10px; padding:11px 20px; cursor:pointer;
}
.tm-manual{margin-bottom:22px;}
.ml-subject{
  font:inherit; font-size:14px; color:var(--ink); background:transparent;
  border:1px solid var(--rule); border-radius:8px; padding:8px 10px;
}
.ml-min{
  font:inherit; font-size:14px; width:110px; color:var(--ink); background:transparent;
  border:1px solid var(--rule); border-radius:8px; padding:8px 10px;
}
.tm-days{display:flex; gap:6px; align-items:flex-end; padding-top:6px;}
.tm-day{flex:1; display:flex; flex-direction:column; align-items:center; gap:4px; min-width:0;}
.tm-day-track{width:100%; max-width:34px; height:92px; background:rgba(128,128,128,0.10); border-radius:6px; display:flex; align-items:flex-end; overflow:hidden;}
.tm-day-fill{width:100%; border-radius:6px 6px 0 0; background:var(--ink); opacity:.82; transition:height .3s ease;}
.tm-day.is-today .tm-day-label{color:var(--ink); font-weight:700;}
.tm-day-min{font-size:11px; color:var(--ink-soft); min-height:14px; font-variant-numeric:tabular-nums;}
.tm-day-label{font-size:11px; color:var(--ink-soft);}
html.theme-dark .tm-subj select, html.theme-dark .tm-custom,
html.theme-dark .ml-subject, html.theme-dark .ml-min{background:var(--field, #171C21);}
html.theme-dark .tm-preset.active{color:var(--card);}
.tm-streak .tm-flame{font-size:.72em; margin-right:4px; filter:grayscale(1); opacity:.55;}
.tm-streak.lit{border-color:#E8A13C;}
.tm-streak.lit .tm-flame{filter:none; opacity:1;}
.tm-streak.at-risk{border-style:dashed;}

/* ---------- Year race ---------- */
.race-scene{margin:8px 0 22px;}
.race-road{
  position:relative; height:100px; border-radius:14px; overflow:hidden;
  background:linear-gradient(#3b424a,#2b3138); box-shadow:inset 0 0 0 1px rgba(0,0,0,0.25);
}
html.theme-dark .race-road{background:linear-gradient(#232a30,#161b20);}
.race-covered{position:absolute; top:0; bottom:0; left:0; background:linear-gradient(90deg, rgba(192,57,43,0.10), rgba(192,57,43,0.28));}
.race-lane{position:absolute; left:8px; right:26px; top:50%; height:0; transform:translateY(-50%); border-top:3px dashed rgba(255,255,255,0.5);}
.race-finish{position:absolute; top:0; bottom:0; right:10px; width:14px; background-image:conic-gradient(#111 25%, #fff 0 50%, #111 0 75%, #fff 0); background-size:7px 7px; opacity:0.9; border-radius:2px;}
.race-carwrap{position:absolute; bottom:18px; width:64px; transform:translateX(-50%); transition:left .6s cubic-bezier(.4,.1,.3,1);}
.race-car-svg{width:100%; height:auto; display:block; filter:drop-shadow(0 3px 3px rgba(0,0,0,0.35));}
.race-carwrap.finished{animation:race-bounce .9s ease;}
@keyframes race-bounce{0%,100%{transform:translateX(-50%) translateY(0);}30%{transform:translateX(-50%) translateY(-9px);}60%{transform:translateX(-50%) translateY(-3px);}}
.race-scale{position:relative; height:20px; margin-top:8px;}
.race-tick{position:absolute; top:0; transform:translateX(-50%); text-align:center;}
.race-tick::before{content:''; display:block; width:1px; height:6px; margin:0 auto 2px; background:var(--rule);}
.race-tick-label{font-size:10px; color:var(--ink-soft);}
.race-ends{display:flex; flex-wrap:wrap; justify-content:space-between; gap:6px 14px; font-size:12px; color:var(--ink-soft); margin-bottom:8px;}
.race-cars{margin:18px 0;}
.race-carrow{display:flex; flex-wrap:wrap; gap:10px;}
.race-carbtn{
  display:inline-flex; flex-direction:column; align-items:center; gap:5px; cursor:pointer; font:inherit;
  font-size:12px; color:var(--ink-soft); background:var(--card); border:1px solid var(--rule); border-radius:12px; padding:10px 16px;
}
.race-carbtn.active{border-color:#C0392B; color:var(--ink);}
.race-carbtn .race-car-svg{width:76px; filter:none;}
.race-dates{margin-top:4px;}
.race-daterow{display:flex; flex-wrap:wrap; gap:14px;}
.race-dates label{display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--ink-soft);}
.race-dates input{font:inherit; font-size:14px; color:var(--ink); background:transparent; border:1px solid var(--rule); border-radius:8px; padding:8px 10px;}
html.theme-dark .race-dates input{background:var(--field, #171C21);}
/* Overview race band */
.ov-race{margin:4px 0 26px;}
.ov-race-head{display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin-bottom:10px;}
.ov-race-head .section-title{border:none;}
.linklike{background:none; border:none; padding:0; cursor:pointer; font:inherit; font-size:13px; color:var(--accent, #C0392B); font-weight:600;}
.linklike:hover{text-decoration:underline;}
/* Extra-info list */
.race-info{margin-top:20px;}
.info-list{margin:0; display:flex; flex-direction:column;}
.info-row{display:flex; justify-content:space-between; gap:16px; padding:9px 0; border-bottom:1px solid var(--rule);}
.info-row:last-child{border-bottom:none;}
.info-row dt{color:var(--ink-soft); font-size:14px;}
.info-row dd{margin:0; color:var(--ink); font-weight:600; font-size:14px; text-align:right;}

/* ---------- PDF viewer (full-screen, in-app) ---------- */
.pdf-modal{
  position:fixed; inset:0; background:rgba(0,0,0,0.9); z-index:80;
  display:flex; flex-direction:column;
}
.pdf-bar{
  display:flex; align-items:center; gap:10px;
  padding:calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  background:#15181B; color:#fff;
}
.pdf-bar .pdf-title{flex:1; font-size:14px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.pdf-bar a, .pdf-bar button{
  background:rgba(255,255,255,0.16); color:#fff; border:none; border-radius:7px;
  padding:8px 13px; font-size:13px; font-weight:500; cursor:pointer; text-decoration:none;
}
.pdf-bar a:hover, .pdf-bar button:hover{background:rgba(255,255,255,0.26);}
.pdf-scroll{
  flex:1; overflow:auto; -webkit-overflow-scrolling:touch;
  padding:14px 14px calc(env(safe-area-inset-bottom, 0px) + 14px);
  display:flex; flex-direction:column; align-items:center; gap:12px;
}
.pdf-scroll canvas{max-width:100%; height:auto; background:#fff; box-shadow:0 2px 12px rgba(0,0,0,0.5); border-radius:2px;}

/* ---------- Spotify now-playing overlay ---------- */
.sp-overlay{
  position:fixed; right:16px; top:calc(env(safe-area-inset-top, 0px) + 16px);
  z-index:40; display:flex; align-items:center; gap:14px;
  background:linear-gradient(155deg, #1c2a22 0%, #121417 60%);
  color:#fff; border-radius:18px; padding:14px 16px 14px 14px;
  border:1px solid rgba(255,255,255,0.09);
  box-shadow:0 20px 55px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,0,0,0.4);
  max-width:min(360px, calc(100vw - 32px));
  animation:spPop .28s cubic-bezier(.2,.8,.25,1);
  touch-action:none;   /* the card itself never scrolls the page */
}
.sp-overlay[hidden]{display:none;}   /* display:flex above would otherwise override the hidden attribute */
@keyframes spPop{ from{ opacity:0; transform:translateY(-8px) scale(.96); } to{ opacity:1; transform:none; } }
/* On phones the nav is a bar across the top, so drop the overlay to the bottom. */
@media (max-width: 760px){
  .sp-overlay{ top:auto; bottom:calc(env(safe-area-inset-bottom, 0px) + 16px); }
}
.sp-overlay .sp-art{width:84px; height:84px; border-radius:12px; object-fit:cover; background:#2a2d31; flex-shrink:0; box-shadow:0 4px 14px rgba(0,0,0,0.5);}
.sp-overlay .sp-info{min-width:0; flex:1;}
.sp-overlay .sp-track{font-size:15px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.sp-overlay .sp-artist{font-size:12.5px; color:#b7b7b7; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:1px;}
.sp-overlay .sp-bar{height:4px; background:rgba(255,255,255,0.18); border-radius:2px; margin-top:9px; overflow:hidden;}
.sp-overlay .sp-bar-fill{height:100%; width:0%; background:var(--sp-accent,#1DB954); transition:width .6s linear;}
.sp-overlay .sp-controls{display:flex; align-items:center; gap:10px; margin-top:11px;}
.sp-overlay .sp-btn{
  background:rgba(255,255,255,0.12); border:none; color:#fff; cursor:pointer;
  width:38px; height:38px; border-radius:50%;
  display:flex; align-items:center; justify-content:center; padding:0; flex-shrink:0;
  transition:transform .12s ease, background .15s ease;
}
.sp-overlay .sp-btn svg{width:20px; height:20px; display:block;}
.sp-overlay .sp-btn:hover{background:rgba(255,255,255,0.24); transform:scale(1.08);}
.sp-overlay .sp-btn:active{transform:scale(.94);}
.sp-overlay .sp-btn.sp-play{background:var(--sp-accent,#1DB954); color:#0b0d0f; width:48px; height:48px;}
.sp-overlay .sp-btn.sp-play svg{width:26px; height:26px;}
.sp-overlay .sp-btn.sp-play:hover{filter:brightness(1.12);}
.sp-overlay .sp-msg{font-size:11px; color:#f0b76b; line-height:1.2; margin-left:4px;}
.sp-overlay .sp-close{background:none; border:none; color:#9a9a9a; cursor:pointer; font-size:18px; line-height:1; align-self:flex-start; padding:0 2px;}
.sp-overlay .sp-close:hover{color:#fff;}
/* Controls and volume must keep their own touch behaviour (taps + thumb drag). */
.sp-overlay .sp-controls{touch-action:auto;}
/* Volume */
.sp-overlay .sp-volume{display:flex; align-items:center; gap:9px; margin-top:11px; touch-action:auto;}
.sp-overlay .sp-volico{width:17px; height:17px; color:#b7b7b7; flex-shrink:0;}
.sp-overlay .sp-vol{
  -webkit-appearance:none; appearance:none; width:100%; height:4px; border-radius:2px;
  background:rgba(255,255,255,0.22); cursor:pointer; touch-action:auto;
}
.sp-overlay .sp-vol::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none; width:14px; height:14px; border-radius:50%;
  background:#fff; cursor:pointer; box-shadow:0 1px 3px rgba(0,0,0,0.5);
}
.sp-overlay .sp-vol::-moz-range-thumb{width:14px; height:14px; border:none; border-radius:50%; background:#fff; cursor:pointer;}
/* Dragging: album art + track/artist are the grab handles */
.sp-overlay .sp-grab{
  cursor:grab; touch-action:none;
  user-select:none; -webkit-user-select:none;
  -webkit-user-drag:none; -webkit-touch-callout:none;  /* stop iOS image/text callout stealing the touch */
}
.sp-overlay.dragging, .sp-overlay.dragging .sp-grab{cursor:grabbing;}
.sp-overlay.dragging{animation:none;}
.pdf-msg{color:#dcdcdc; font-size:14px; padding:28px 20px; text-align:center; line-height:1.5;}

/* ---------- Settings ---------- */
.settings-group{
  background:var(--card); border:1px solid var(--rule); border-radius:10px;
  padding:18px 20px; margin-bottom:16px; max-width:660px;
}
.settings-group h3{font-size:16px; font-weight:600; margin-bottom:4px;}
.settings-group .sg-desc{font-size:12.5px; color:var(--ink-soft); margin:0 0 14px;}
.sg-select{
  padding:9px 12px; border:1px solid var(--rule); border-radius:9px;
  background:var(--card); color:var(--ink); font-family:inherit; font-size:14px; min-width:200px;
  max-width:100%;
}
.opt-row{display:flex; gap:8px; flex-wrap:wrap;}
.opt-btn{
  border:1px solid var(--rule); background:#fff; color:var(--ink-soft);
  padding:9px 15px; border-radius:8px; font-size:13px; cursor:pointer;
  display:inline-flex; align-items:center;
}
.opt-btn:hover{border-color:var(--ink-soft);}
.opt-btn.active{ background:var(--ink); border-color:var(--ink); color:var(--page); }
.theme-swatch{
  display:inline-block; width:16px; height:16px; border-radius:5px; flex-shrink:0;
  margin-right:8px; border:1px solid rgba(128,128,128,0.4);
}
.sg-h-sub{font-size:13px; font-weight:400; color:var(--ink-soft);}
.sg-link{color:var(--ink); font-weight:600; text-decoration:underline; text-underline-offset:2px;}
.settings-group .sg-status{margin:12px 0 0; min-height:0;}
.settings-group .sg-status:empty{display:none;}
.settings-group .sg-status.err{color:var(--danger);}
/* Restore: a visually-hidden file input inside a button-styled label. */
.file-btn{position:relative; cursor:pointer;}
.file-btn:focus-within{outline:2px solid var(--ink); outline-offset:2px;}
/* Delete account */
:root{--danger:#B3261E;}
html.theme-dark{--danger:#F28B82;}
.danger-zone{border-color:var(--danger);}
.danger-zone h3{color:var(--danger);}
.danger-btn{
  border:1px solid var(--danger); background:transparent; color:var(--danger);
  padding:9px 15px; border-radius:8px; font-size:13px; font-weight:600; cursor:pointer;
}
.danger-btn:hover:not(:disabled){background:var(--danger); color:var(--card);}
#delGo{background:var(--danger); color:var(--card);}
.danger-btn:disabled{opacity:.45; cursor:not-allowed;}
.del-panel{margin-top:4px;}
/* Reviews & suggestions */
.fb-kinds{margin-bottom:12px;}
.fb-stars{border:0; margin:0 0 10px; padding:0; display:flex; align-items:center; gap:2px; flex-wrap:wrap;}
.fb-stars[hidden]{display:none;}
.fb-stars legend{font-size:13px; color:var(--ink); padding:0; margin-bottom:4px; float:left; width:100%;}
.fb-star{font-size:26px; line-height:1; color:var(--ink-soft); opacity:.55; cursor:pointer; padding:4px 3px; border-radius:6px;}
.fb-star.on{color:#B7791F; opacity:1;}
html.theme-dark .fb-star.on{color:#F2C14E;}
.fb-stars input:focus-visible + .fb-star{outline:2.5px solid var(--ink); outline-offset:1px;}
.fb-field{margin-bottom:5px;}
.fb-msg{
  display:block; width:100%; max-width:560px; padding:10px 12px; border:1px solid var(--rule); border-radius:9px;
  font-family:inherit; font-size:14px; line-height:1.45; resize:vertical; min-height:110px;
  background:var(--field, var(--card)); color:var(--ink);
}
.fb-count{font-size:11.5px; color:var(--ink-soft); margin:4px 0 12px; max-width:560px; text-align:right;}
.fb-hp{position:absolute; left:-10000px; top:auto; width:1px; height:1px; overflow:hidden;}
.fb-send:disabled{opacity:.55; cursor:progress;}
.settings-group .fb-mail{margin:12px 0 0;}
.del-panel[hidden]{display:none;}
.del-field{display:block; font-size:13px; color:var(--ink); margin-bottom:12px;}
.del-field input{
  display:block; width:100%; max-width:320px; margin-top:5px; padding:9px 12px;
  border:1px solid var(--rule); border-radius:9px; font-family:inherit; font-size:14px;
  background:var(--field, var(--card)); color:var(--ink);
}

@media (max-width: 1120px){
  .columns.four{grid-template-columns:1fr 1fr;}
}
@media (max-width: 900px){
  .columns{grid-template-columns:1fr;}
}
@media (max-width: 640px){
  .columns.four{grid-template-columns:1fr;}
}
@media (max-width: 760px){
  .app{flex-direction:column;}
  .spine{
    width:100%; height:auto; position:relative;
    flex-direction:row; align-items:center; padding:14px 12px; gap:14px;
    overflow-x:auto;
  }
  /* A clean full-width 4-tab bar. The brand is hidden here (the page heading
     and the installed app name already say where you are), so every tab fits
     without clipping or horizontal scrolling. */
  /* Pad the top by the notch/status-bar inset so the tab bar sits below the
     iPhone status bar (time/battery) in the installed full-screen app. */
  .spine{padding:calc(env(safe-area-inset-top, 0px) + 8px) 8px 8px; overflow-x:visible;}
  .spine-brand{display:none;}
  .spine-nav{display:flex; padding:0; flex:1; width:100%; justify-content:space-between; gap:2px;}
  .spine-nav li{margin:0; flex:1; min-width:0;}
  .tab{white-space:nowrap; padding:9px 4px; gap:0; font-size:13px; justify-content:center; text-align:center;}
  .tab .flag{display:none;}
  .tab-name{flex:none;}
  .tab-sub{display:none;}
  .spine-foot{display:none;}
  .page{padding:24px 18px 40px 18px;}
  .page-header{align-items:flex-start;}
}
/* ---------- Phones: layout fixes found in device QA ---------- */
@media (max-width: 760px){
  /* The binder-hole decoration sits 22px in; phone padding is 18px, so it
     ran into cards and text. Hide it on narrow screens. */
  .page-wrap{background-image:none;}
  /* Summary stats in a tidy 2-up grid instead of a narrow stacked column. */
  .grade-summary{display:grid; grid-template-columns:1fr 1fr; gap:10px;}
  .grade-summary .gs-stat, .grade-summary .gs-core{min-width:0;}
}
@media (max-width: 560px){
  /* Assessment rows: title on its own line, details underneath. */
  .grade-row{flex-wrap:wrap; row-gap:4px;}
  .grade-row .grade-title{flex:1 1 100%;}
  .grade-row .grade-date{width:auto; margin-left:auto;}
  /* Upcoming rows: title and × share the first line; score entry below. */
  .grade-row.upcoming .grade-title{flex:1 1 0;}
  .grade-row.upcoming .del{order:1;}
  .grade-row.upcoming .as-enter{order:2; flex:1 1 100%; min-width:0; margin-left:0;}
  /* width:0 + flex:1 so the inputs share the row instead of sizing to their
     (16px-font) intrinsic width, which pushed the page wider than the phone. */
  .grade-row.upcoming .as-enter input{flex:1 1 0; width:0; min-width:0;}
  .up-tag{display:inline-block; margin:3px 0 0; white-space:normal;}
}
/* ---------- Touch screens: comfortable tap targets + no iOS zoom ---------- */
@media (pointer: coarse){
  /* iOS Safari zooms the page when a field under 16px is focused. */
  input, select, textarea{font-size:16px !important;}
  .del, .rot-skip-del{min-width:40px; min-height:40px; display:inline-flex; align-items:center; justify-content:center; font-size:20px;}
  .up-done{width:40px; height:40px;}
  .cal-btn{min-height:40px; min-width:40px;}
  .cdv-close{width:40px; height:40px;}
  .cdv-add, .cdv-go{min-height:40px;}
  .rot-daychip, .cm-chip{min-height:40px;}
  .grade-bounds summary{padding:10px 0;}
  .as-save, .grade-add .ga-add, .as-enter input, .gb-cell input, .grade-add input, .grade-add select,
  .gs-core select, .grade-pred select{min-height:40px;}
  .sp-sw{width:38px; height:38px;}
  .gate-toggle button{padding:10px 4px;}
  .opt-btn, .danger-btn{min-height:40px;}
  .fb-star{padding:8px 5px;}
  /* Inline links: taller hit area without changing the line layout. */
  .gate-legal a, .sg-link, .storenote-link{padding:12px 2px;}
  /* What-if slider: a 32px-tall touch area and a bigger handle; the visible
     track stays thin. */
  .wi-slider{height:32px; background:transparent;}
  .wi-slider::-webkit-slider-runnable-track{height:5px; border-radius:3px; background:var(--rule);}
  .wi-slider::-webkit-slider-thumb{width:26px; height:26px; margin-top:-10.5px;}
  .wi-slider::-moz-range-track{height:5px; border-radius:3px; background:var(--rule);}
  .wi-slider::-moz-range-thumb{width:24px; height:24px;}
}
/* Skip link (WCAG 2.4.1): off-screen until focused, then visible. */
.skip-link{
  position:fixed; left:8px; top:-60px; z-index:200;
  background:var(--card); color:var(--ink); padding:10px 14px;
  border:1px solid var(--rule); border-radius:8px; text-decoration:none; font-weight:600;
  transition:top .15s ease;
}
.skip-link:focus{ top:8px; }

/* Firebase's hidden sign-in helper frame. Firebase asks Google's loader to
   style it off-screen; this keeps it hidden even if those styles were ever
   dropped by the strict CSP. */
iframe[src*="/__/auth/iframe"]{
  position:absolute !important; top:-100px !important; left:0 !important;
  width:1px !important; height:1px !important; border:0 !important;
}
