:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --sidebar: #1f2433;
  --sidebar-text: #c9cede;
  --sidebar-active: #2e3549;
  --text: #1c2030;
  --muted: #6b7185;
  --border: #e3e6ef;
  --primary: #036efc;
  --primary-text: #ffffff;
  --danger: #d6455d;
  --overdue: #d6455d;
  --today: #e08a1e;
  --done: #1f9d55;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.06), 0 2px 8px rgba(20, 24, 40, 0.04);
  color-scheme: light;
}

/* Theme (Settings → Appearance): data-theme="light" | "dark" on <html>; none = Auto (follow the device). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141c;
    --surface: #1b1e29;
    --sidebar: #0d0f15;
    --sidebar-text: #aab0c2;
    --sidebar-active: #1f2332;
    --text: #e7e9f0;
    --muted: #8d93a7; --done: #3cc177;
    --border: #2a2e3d;
    --primary: #3d8bff;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12141c;
  --surface: #1b1e29;
  --sidebar: #0d0f15;
  --sidebar-text: #aab0c2;
  --sidebar-active: #1f2332;
  --text: #e7e9f0;
  --muted: #8d93a7; --done: #3cc177;
  --border: #2a2e3d;
  --primary: #3d8bff;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }

/* Phones/tablets: keep zoom fixed at 100%. iOS zooms into any field with text under 16px,
   so fields get 16px; touch-action stops double-tap zoom. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (pointer: coarse) {
  html, body { touch-action: pan-x pan-y; }
  input, select, textarea { font-size: 16px; }
}

/* ---------- layout ---------- */

/* App shell: the page itself never scrolls. The sidebar and the main area each scroll on
   their own, and overscroll-behavior stops a scroll (or bounce) in one from moving the other. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.layout { display: flex; height: 100vh; height: 100dvh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: #fff;
  padding: 4px 10px 18px;
}
.brand-logo { width: 26px; height: auto; display: block; }
.brand-add { position: relative; margin-left: auto; }
.brand-add-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.1); color: var(--sidebar-text);
  transition: background 0.15s, color 0.15s;
}
.brand-add-btn svg { width: 14px; height: 14px; }
.brand-add-btn:hover, .brand-add-btn.open { background: rgba(255, 255, 255, 0.18); color: #fff; }
.brand-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column; gap: 2px;
}
.brand-menu[hidden] { display: none; }
.brand-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: none; padding: 8px 10px; border-radius: 7px; cursor: pointer;
  font-size: 14px; font-weight: 500; letter-spacing: normal; color: var(--text);
}
.brand-menu button:hover, .brand-menu button:focus-visible { background: var(--bg); outline: none; }
.brand-menu-icon { width: 18px; text-align: center; }

nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: var(--sidebar-active); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item.add { color: var(--muted); margin-top: 4px; }

/* Drag to reorder classes / organizations */
#class-nav .nav-item, #org-nav .nav-item { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.reordering { cursor: grabbing; }
.reordering .nav-item { cursor: grabbing; }
.nav-item.dragging {
  background: var(--sidebar-active); color: #fff; position: relative; z-index: 1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transform: scale(1.02);
}

/* Compact sidebar (Settings → Appearance): classes and organizations sit closer together. */
:root[data-sidebar="compact"] #class-nav,
:root[data-sidebar="compact"] #org-nav { display: flex; flex-direction: column; gap: 0; }
:root[data-sidebar="compact"] #class-nav .nav-item,
:root[data-sidebar="compact"] #org-nav .nav-item { padding-top: 4px; padding-bottom: 4px; font-size: 14px; }
:root[data-sidebar="compact"] #class-nav .count,
:root[data-sidebar="compact"] #org-nav .count { font-size: 11px; }
.nav-item.add:hover { color: #fff; }

.nav-icon { width: 18px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.nav-item .dot { margin: 0 4px; }

.count {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0 8px;
  min-width: 22px;
  text-align: center;
}
.count:empty { display: none; }

.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 18px 10px 6px;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 10px;
  text-align: left;
}
.link-btn:hover { color: #fff; }

.main { flex: 1; min-width: 0; height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 24px 32px 48px; }
/* Content width limits live on the children so the scrollbar stays at the window edge. */
.main > * { max-width: 900px; }
.main.wide > * { max-width: 1280px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.title-wrap { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.title-wrap h1 { margin: 0; font-size: 26px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-text { min-width: 0; display: flex; flex-direction: column; }
.page-eyebrow { margin: 0 0 2px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary); }
.page-subtitle { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.title-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.title-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.title-tools { display: flex; gap: 2px; align-items: center; flex-shrink: 0; }
.title-tools:empty { display: none; }
.title-tools .info-btn.danger:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }

.menu-btn {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  font-size: 18px;
}

.scrim { display: none; }

/* ---------- controls ---------- */

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
label .muted { font-weight: 400; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; font-size: 14px; }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* ---------- cards & lists ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}


.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.toggle { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.toggle input { width: auto; }

.group { margin-bottom: 22px; }
.group h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 8px 2px;
}
.group-toggle {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 2px 4px 2px 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; cursor: pointer; border-radius: 6px;
}
.group-toggle:hover { color: var(--text); }
.group.overdue .group-toggle:hover, .group.today .group-toggle:hover { filter: brightness(0.85); }
.chev { width: 12px; height: 12px; flex-shrink: 0; transition: transform 0.15s ease; }
.group.collapsed .chev { transform: rotate(-90deg); }
/* Sections fold smoothly: the body's single grid row animates between full height and 0. */
.group { transition: margin-bottom 0.22s ease; }
.group-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease; }
.group-body > .list { min-height: 0; overflow: hidden; }
.group.collapsed .group-body { grid-template-rows: 0fr; opacity: 0; }
.group.collapsed { margin-bottom: 12px; }
.group.overdue h3 { color: var(--overdue); }
.group.today h3 { color: var(--today); }

.list { list-style: none; margin: 0; padding: 0; }

.item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.item:last-child { border-bottom: 0; }
.item .check { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; cursor: pointer; accent-color: var(--primary); }
/* Events (calendar day view): no checkbox, so the name starts where checkboxes do. */
/* Calendar day view mixes to-dos and events: each row's details line starts at the left edge
   (where checkboxes are), under the checkbox, so to-do and event details line up. The 4px
   matches the checkbox's built-in left margin. */
.day-list .item { display: grid; grid-template-columns: auto 1fr auto; column-gap: 12px; row-gap: 0; align-items: start; }
.day-list .item .body { display: contents; }
.day-list .item .check { grid-column: 1; grid-row: 1; }
.day-list .item .title { grid-column: 2; grid-row: 1; }
.day-list .item.event .title { grid-column: 1 / 3; margin-left: 4px; }
.day-list .item .meta, .day-list .item .notes { grid-column: 1 / 3; margin-left: 4px; }
.day-list .item .actions { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; word-break: break-word; }
.item.done .title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.item .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--muted); margin-top: 2px; align-items: center; }
.item .notes { font-size: 13px; color: var(--muted); margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.item .due.overdue { color: var(--overdue); font-weight: 600; }
.item .due.today { color: var(--today); font-weight: 600; }
.item .actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.item:hover .actions, .item:focus-within .actions { opacity: 1; }

.icon-btn {
  background: none;
  border: 0;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--muted);
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.chip:hover { text-decoration: underline; }

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty .big { font-size: 40px; margin-bottom: 8px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.kind-tag { font-size: 12px; color: var(--muted); }

/* ---------- dialogs ---------- */

dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(10, 12, 20, 0.45); }
.dialog-form { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.dialog-form h2 { margin: 0 0 4px; font-size: 19px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Controls ease between states instead of snapping. */
.btn, .nav-item, .icon-btn, .link-btn, .tab, .choice, .swatch, .segmented button, .account-link, .group-toggle,
input, select, textarea, .cal-chip, .cal-cell, .item {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.12s ease;
}
.btn:active, .icon-btn:active { transform: scale(0.97); }
.brand-menu:not([hidden]) { animation: pop-in 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.2); transform-origin: top right; }
@keyframes pop-in { from { opacity: 0; transform: scale(0.94) translateY(-4px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

.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; }

/* Pop-ups ease in. */
dialog[open] { animation: dialog-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.15); }
dialog[open]::backdrop { animation: backdrop-in 0.18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } }
@keyframes backdrop-in { from { opacity: 0; } }
dialog.closing { animation: dialog-out 0.14s ease-in forwards; }
dialog.closing::backdrop { animation: backdrop-out 0.14s ease-in forwards; }
@keyframes dialog-out { to { opacity: 0; transform: translateY(4px) scale(0.98); } }
@keyframes backdrop-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog[open], dialog[open]::backdrop { animation: none; } }

/* ---------- to-do / event pop-up ---------- */
.item-dialog { width: min(460px, calc(100vw - 32px)); }
.item-form { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px 18px; }
.item-head { display: flex; align-items: center; gap: 10px; }
.item-head h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--muted); flex: 1; }
.item-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.item-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.item-icon.is-todo { background: color-mix(in srgb, var(--primary) 14%, var(--surface)); color: var(--primary); }
.item-icon.is-event { background: color-mix(in srgb, var(--primary) 14%, var(--surface)); color: var(--primary); }

.title-input {
  border: 0; border-bottom: 1.5px solid var(--border); border-radius: 0; background: none;
  font-size: 21px; font-weight: 600; padding: 4px 2px 8px; color: var(--text);
}
.title-input:focus { outline: none; border-bottom-color: var(--primary); }
.title-input::placeholder { color: var(--muted); font-weight: 500; opacity: 0.7; }

/* Segmented pickers (category; and the small type switch when editing) */
fieldset.seg, fieldset.mini-seg { flex-direction: row; min-width: 0; }
.seg, .mini-seg { border: 0; margin: 0; padding: 3px; display: flex; gap: 3px; background: var(--bg); border-radius: 10px; }
.seg label, .mini-seg label { flex: 1; position: relative; cursor: pointer; }
.seg input, .mini-seg input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg span, .mini-seg span {
  display: block; text-align: center; padding: 7px 8px; border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--muted); transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg label:hover span, .mini-seg label:hover span { color: var(--text); }
.seg input:checked + span, .mini-seg input:checked + span { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg input:focus-visible + span, .mini-seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }
.seg input:disabled + span { opacity: 0.4; cursor: not-allowed; }
.mini-seg { flex: 0 0 auto; padding: 2px; border-radius: 8px; }
.mini-seg span { padding: 4px 10px; font-size: 12px; border-radius: 6px; white-space: nowrap; }
.mini-seg label { flex: 0 0 auto; }

/* Icon rows instead of labels */
.field-row { display: flex; align-items: center; gap: 10px; }
.field-icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.field-row input, .field-row select, .field-row textarea { flex: 1; min-width: 0; }
.notes-row { align-items: flex-start; }
.notes-row .field-icon { margin-top: 9px; }
.notes-row textarea { resize: vertical; min-height: 42px; }

/* Class / organization pop-up: header dot previews the chosen color. */
.group-icon { background: color-mix(in srgb, var(--group-color, var(--primary)) 16%, var(--surface)); transition: background 0.2s ease; }
.group-icon span { width: 12px; height: 12px; border-radius: 50%; background: var(--group-color, var(--primary)); transition: background 0.2s ease; }
.color-block { display: flex; flex-direction: column; gap: 8px; }
.color-label { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.color-block .swatches { margin-top: 0; }
.swatch { transition: transform 0.12s ease, border-color 0.15s ease; }
.swatch:hover { transform: scale(1.1); }

/* The class/organization picker slides open once a category needs it. */
.group-field { display: grid; grid-template-columns: 18px 1fr; overflow: hidden; max-height: 0; opacity: 0; margin-top: -14px; transition: max-height 0.2s ease, opacity 0.2s ease, margin-top 0.2s ease; }
.group-field.shown { max-height: 60px; opacity: 1; margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .group-field { transition: none; } }
.dialog-actions .delete-left { margin-right: auto; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: -8px; }
.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.selected { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--surface); }

/* Eyedropper circle: rainbow ring around a plain center, or filled with the custom color once chosen. */
.swatch-custom {
  display: grid;
  place-items: center;
  background: conic-gradient(#f43f5e, #f5a524, #eab308, #2fa36b, #0ea5b7, #4f6bed, #a855f7, #f43f5e);
}
.swatch-custom span {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.swatch-custom svg { width: 9px; height: 9px; }
.swatch-custom:hover span { color: var(--text); }
.swatch-custom.has-color span { background: var(--custom); color: var(--custom-ink); }
.swatch-custom[aria-expanded="true"]:not(.selected) { border-color: var(--border); }

/* Hex box revealed by the eyedropper: color preview (doubles as a native picker) inside the input. */
.custom-color { margin-top: -4px; animation: reveal 0.15s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } }
.hex-field { position: relative; width: 160px; }
.hex-field input[name="hex"] {
  padding-left: 40px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hex-field input[name="hex"].invalid { border-color: var(--danger); outline-color: var(--danger); }
.hex-field input[type="color"] {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; padding: 0; border: 1px solid var(--border); border-radius: 6px;
  background: none; cursor: pointer; overflow: hidden;
}
.hex-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.hex-field input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.hex-field input[type="color"]::-moz-color-swatch { border: 0; border-radius: 5px; }

/* ---------- login ---------- */

.login { height: 100vh; height: 100dvh; overflow-y: auto; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; margin-bottom: 6px; }
.login-logo { width: 72px; height: auto; margin-bottom: 10px; filter: drop-shadow(0 4px 10px rgba(20, 24, 40, 0.12)); }
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.login-brand p { margin: 0; font-size: 14px; }
.empty-logo { width: 64px; height: auto; margin-bottom: 8px; }

/* Sign in / Create account: a white thumb slides under the active tab. */
.tabs { position: relative; display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 3px; }
.tab-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 4.5px); border-radius: 6px;
  background: var(--surface); box-shadow: var(--shadow); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.login-card[data-mode="signup"] .tab-thumb { transform: translateX(calc(100% + 3px)); }
.tab { position: relative; flex: 1; border: 0; background: none; padding: 7px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.hint { font-size: 13px; margin: 0; }

/* Create account fields fold away (0fr ⇄ 1fr) instead of popping; the negative margin hides the
   card's gap while folded. */
.signup-extra {
  display: grid; grid-template-rows: 0fr; opacity: 0; margin-top: -14px;
  transition: grid-template-rows 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease, margin-top 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.signup-extra.open { grid-template-rows: 1fr; opacity: 1; margin-top: 0; }
.signup-extra-inner { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 10px; padding: 2px; margin: -2px; }

/* Entrance: the card rises and fades in, the logo eases in just after. Leaving: fades out. */
.login:not([hidden]) .login-card { animation: login-in 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.login:not([hidden]) .login-logo { animation: logo-in 0.5s 0.08s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes login-in { from { opacity: 0; transform: translateY(12px) scale(0.985); } }
@keyframes logo-in { from { opacity: 0; transform: scale(0.85); } }
.login.leaving .login-card { transition: opacity 0.2s ease, transform 0.2s ease; opacity: 0; transform: scale(0.98); }
#login-error:not([hidden]) { animation: reveal 0.2s ease-out; }
/* Sign-in card folds: parts that slide away / in when switching to "Forgot password?". The
   negative margin hides the card's 14px gap while a fold is closed. */
.fold {
  display: grid; grid-template-rows: 1fr; opacity: 1;
  transition: grid-template-rows 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease, margin-top 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.fold-inner { min-height: 0; overflow: hidden; padding: 2px; margin: -2px; display: flex; flex-direction: column; }
.login-card:not([data-mode="forgot"]) .show-in-forgot,
.login-card[data-mode="forgot"] .hide-in-forgot { grid-template-rows: 0fr; opacity: 0; margin-top: -14px; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.forgot-link, .back-link {
  border: 0; background: none; padding: 0; cursor: pointer; font: inherit;
  font-size: 12.5px; font-weight: 600; color: var(--primary);
}
.forgot-link:hover, .back-link:hover { text-decoration: underline; }
.login-card[data-mode="signup"] .forgot-link { visibility: hidden; }
.back-link { align-self: center; font-size: 13.5px; padding: 2px 4px; }
.forgot-intro { margin: 0; font-size: 14px; line-height: 1.45; text-align: center; }
.forgot-sent {
  display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 10px 12px; border-radius: 10px;
  font-size: 13.5px; line-height: 1.45; color: var(--text); background: color-mix(in srgb, var(--done) 12%, var(--surface));
  animation: reveal 0.2s ease-out;
}
.forgot-sent svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; fill: none; stroke: var(--done); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.forgot-sent a { color: var(--primary); font-weight: 600; }
/* New-password page (forgot.finallyapp.us). */
.reset-fields { display: flex; flex-direction: column; gap: 14px; }
.reset-fields[hidden], .reset-action[hidden] { display: none; }
.reset-action { text-align: center; text-decoration: none; justify-content: center; }

/* Sign-in site, while a new user confirms their email / answers the profile questions: the
   pop-ups show over the plain background, without the sign-in card. */
.login.onboarding .login-card { display: none; }

/* Field messages under the sign-in inputs: slide open / closed (0fr ⇄ 1fr). The negative margin
   hides the label's gap while closed. */
.field-msg {
  display: grid; grid-template-rows: 0fr; opacity: 0; margin-top: -4px;
  transition: grid-template-rows 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.18s ease, margin-top 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.field-msg.show { grid-template-rows: 1fr; opacity: 1; margin-top: 0; }
.field-msg > div { min-height: 0; overflow: hidden; }
.field-msg span {
  display: flex; align-items: flex-start; gap: 6px; padding-top: 2px;
  font-size: 12.5px; font-weight: 500; line-height: 1.35; color: var(--danger);
}
.field-msg span::before {
  content: "!"; flex-shrink: 0; width: 14px; height: 14px; margin-top: 1px; border-radius: 50%;
  display: grid; place-items: center; font-size: 10px; font-weight: 800; line-height: 1;
  background: var(--danger); color: #fff;
}
.login-card input.invalid { border-color: var(--danger); }
.login-card input.invalid:focus { outline-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }

/* Checkboxes in toggles (Remember this device, Show completed): rounded square that fills blue
   with a white check. */
.toggle input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex-shrink: 0; width: 18px; height: 18px; margin: 0; padding: 0;
  border: 1.5px solid color-mix(in srgb, var(--muted) 55%, var(--border)); border-radius: 5px; background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
}
.toggle input[type="checkbox"]::after {
  content: ""; width: 4px; height: 8px; margin-top: -2px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0); transition: transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.toggle input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }
.toggle input[type="checkbox"]:checked::after { transform: rotate(45deg) scale(1); }
.toggle input[type="checkbox"]:hover { border-color: var(--primary); }
.toggle input[type="checkbox"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.toggle.remember { gap: 10px; font-size: 14px; font-weight: 500; color: var(--text); user-select: none; }

.account { display: flex; align-items: center; justify-content: space-between; gap: 4px; border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 12px; margin-top: 12px; }
.account-link { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; padding: 6px 8px; border-radius: 8px; color: inherit; text-decoration: none; }
.account-link:hover, .account-link.active { background: var(--sidebar-active); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.account-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.account-name { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-type { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; }
.gear { color: var(--muted); font-size: 14px; }
.account-link:hover .gear { color: #fff; }

/* profile form (first-time prompt + settings) */
.profile-form { display: flex; flex-direction: column; gap: 14px; }
.profile-form fieldset, .theme-field { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.profile-form legend, .theme-field legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 6px; }
.choices { display: flex; gap: 8px; }
.choice { flex: 1; flex-direction: row; justify-content: center; position: relative; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; cursor: pointer; color: var(--text); font-size: 15px; font-weight: 500; background: var(--surface); }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); color: var(--primary); font-weight: 600; }
.choice:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.choice:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.profile-intro { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; margin-bottom: 4px; }
.profile-intro img { width: 48px; height: auto; margin-bottom: 6px; }
.profile-intro p { margin: 0; font-size: 14px; }
.profile-dialog { width: min(480px, calc(100vw - 32px)); }

/* ---------- settings ---------- */
.settings { max-width: 680px; display: flex; flex-direction: column; gap: 22px; }
.settings-section h2 {
  margin: 0 0 8px 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.settings-card { padding: 4px 18px; }
.settings-card .btn { text-decoration: none; display: inline-flex; align-items: center; }

/* label | control rows, separated by hairlines */
.setting-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 1.5fr); align-items: center; gap: 16px; padding: 14px 0; }
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-row[hidden] { display: none; }
.setting-label { font-size: 14px; font-weight: 600; color: var(--text); }
.setting-hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.setting-control { display: flex; justify-content: flex-end; min-width: 0; }
.setting-control .seg { width: 100%; max-width: 320px; }
.setting-control select { max-width: 320px; }
.setting-value { color: var(--text); font-size: 14px; }
.mono-ish { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.name-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 320px; }
/* Email row (Settings → Account) and its slide-open steps. */
.email-ctl { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; flex-wrap: wrap; }
.email-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.verified-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; padding: 3px 9px 3px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--done) 15%, var(--surface)); color: var(--done); flex-shrink: 0;
}
.verified-badge svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.verified-badge.just-verified { animation: pop-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
.email-flow {
  display: grid; grid-template-rows: 0fr; opacity: 0;
  transition: grid-template-rows 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease;
}
.email-flow.open { grid-template-rows: 1fr; opacity: 1; }
.email-flow-inner { min-height: 0; overflow: hidden; }
.email-flow + .setting-row { border-top: 1px solid var(--border); }
.email-step { display: flex; flex-direction: column; gap: 10px; padding: 2px 2px 16px; }
.email-field { display: flex; flex-direction: column; gap: 4px; }
.email-field input { width: 100%; }
.email-flow input.invalid { border-color: var(--danger); }
.email-sent, .email-dev { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.email-sent strong { color: var(--text); }
.email-dev { padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--today) 12%, var(--surface)); color: var(--text); }
.code-input {
  max-width: 220px; font-size: 22px; font-weight: 700; letter-spacing: 0.4em; text-align: center;
  font-variant-numeric: tabular-nums; padding: 8px 10px 8px calc(10px + 0.4em);
}
.code-input::placeholder { color: color-mix(in srgb, var(--muted) 45%, transparent); }
.email-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.email-actions .spacer { flex: 1; }
.email-actions .link-btn { padding: 6px 2px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); }
.email-actions .link-btn:hover { color: var(--text); }
.email-actions .danger-link, .email-actions .danger-link:hover { color: var(--danger); }
/* The required pop-up: steps fill its width. */
.email-gate .email-step { padding: 8px 0 0; }
.email-gate .code-input { max-width: none; }
.type-badge { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; padding: 3px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.type-badge.type-admin { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); border-color: transparent; }
.type-badge.type-plus { background: color-mix(in srgb, #8b5cf6 14%, var(--surface)); color: #8b5cf6; border-color: transparent; }

/* The profile form inside the Settings card: Save sits at the bottom right. */
.settings-card.profile-form { gap: 0; }
.settings-card .form-actions { border-top: 1px solid var(--border); padding: 12px 0 10px; }
.saved { font-size: 13px; color: #2fa36b; font-weight: 600; animation: pop-in 0.18s ease; }

/* Welcome pop-up (and phones): label above control. */
.profile-dialog .setting-row, .profile-dialog .setting-row + .setting-row { grid-template-columns: 1fr; gap: 6px; padding: 8px 0; border-top: 0; }
.profile-dialog .setting-control { justify-content: stretch; }
.profile-dialog .setting-control .seg, .profile-dialog .name-inputs, .profile-dialog .setting-control select { max-width: none; }
.profile-dialog .setting-label { font-size: 13px; color: var(--muted); }
@media (max-width: 640px) {
  .setting-row { grid-template-columns: 1fr; gap: 8px; }
  .setting-control { justify-content: stretch; }
  .setting-control .seg, .name-inputs, .setting-control select { max-width: none; }
}

/* ---------- in-app dropdowns (ui.js) ---------- */
.dd { position: relative; width: 100%; min-width: 0; }
.dd-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.dd-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left;
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 10px;
  font: inherit; color: inherit; cursor: pointer; min-height: 38px;
}
.dd-trigger:hover { border-color: color-mix(in srgb, var(--muted) 60%, var(--border)); }
.dd-trigger:focus-visible, .dd.open .dd-trigger { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.dd-trigger:disabled { opacity: 0.6; cursor: not-allowed; }
.dd-trigger.placeholder .dd-label { color: var(--muted); }
.dd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-chevron { width: 12px; height: 12px; flex-shrink: 0; color: var(--muted); transition: transform 0.18s ease; }
.dd.open .dd-chevron { transform: rotate(180deg); }
.dd-menu {
  position: fixed; z-index: 60; overflow-y: auto; padding: 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  opacity: 0; transform: scale(0.97) translateY(-2px); transition: opacity 0.12s ease, transform 0.14s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.dd-menu.show { opacity: 1; transform: none; }
.dd-menu[hidden] { display: none; }
.dd-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; color: var(--text); user-select: none;
}
.dd-option.active { background: var(--bg); }
.dd-option.selected { font-weight: 600; }
.dd-option.disabled { opacity: 0.45; cursor: not-allowed; }
.dd-tick { width: 14px; height: 14px; color: var(--primary); visibility: hidden; flex-shrink: 0; }
.dd-option.selected .dd-tick { visibility: visible; }
.dd-empty { padding: 10px; font-size: 13px; color: var(--muted); }
.setting-control .dd { max-width: 320px; }
.profile-dialog .setting-control .dd { max-width: none; }
@media (max-width: 640px) { .setting-control .dd { max-width: none; } }
@media (pointer: coarse) { .dd-option { padding: 11px 12px; font-size: 16px; } }

/* ---------- in-app date / time pickers (ui.js) ---------- */
.pk { position: relative; min-width: 0; }
.pk-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.pk-trigger { justify-content: flex-start; gap: 8px; }
.pk-icon { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.when-row .pk-date { flex: 1 1 0; min-width: 0; }
.when-row .pk-time { flex: 0 0 124px; }
.field-icon-spacer { width: 18px; flex-shrink: 0; }
/* Events: [date] [start] to [end] on one line. The date narrows to about half; the two times
   share the rest and drop their clock icons. To-dos keep [date] [due time]. */
.when-row .pk-end, .when-row .time-to { display: none; }
.when-row.is-event { gap: 8px; }
.when-row.is-event .field-icon-spacer { margin-right: 2px; }
.when-row.is-event .pk-date { flex: 0 0 150px; }
.when-row.is-event .pk-time { flex: 1 1 0; min-width: 0; }
.when-row.is-event .pk-time .pk-icon { display: none; }
.when-row.is-event .pk-end { display: block; }
.when-row.is-event .time-to { display: inline; flex-shrink: 0; font-size: 13px; color: var(--muted); }
/* Phones: no room for four boxes, so the times sit on a line just under the date. */
@media (max-width: 520px) {
  .when-row.is-event { flex-wrap: wrap; row-gap: 8px; }
  .when-row.is-event .pk-date { flex: 1 1 calc(100% - 28px); }
  .when-row.is-event .pk-time:not(.pk-end) { margin-left: 28px; }
}

.pk-pop { padding: 10px; }
.pk-pop-date { width: 272px; }
.pk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.pk-title { font-size: 14px; font-weight: 700; color: var(--text); }
.pk-nav { width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 18px; cursor: pointer; }
.pk-nav:hover { background: var(--bg); }
.pk-dow, .pk-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.pk-dow span { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; letter-spacing: 0.03em; }
.pk-day {
  height: 34px; border: 0; background: none; border-radius: 50%; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums;
  transition: background 0.12s ease, color 0.12s ease;
}
.pk-day:hover { background: var(--bg); }
.pk-day.out { color: var(--muted); opacity: 0.55; }
.pk-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary); font-weight: 700; }
.pk-day.selected { background: var(--primary); color: #fff; box-shadow: none; font-weight: 700; }
.pk-day:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.pk-foot { display: flex; gap: 4px; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.pk-link { border: 0; background: none; color: var(--primary); font-size: 13px; font-weight: 600; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.pk-link:hover { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); }

.pk-pop-time { width: 210px; display: flex; flex-direction: column; gap: 6px; }
.pk-time-input { font-size: 14px; }
.pk-time-hint { margin: 0; font-size: 12px; color: var(--danger); }
.pk-times { max-height: 220px; overflow-y: auto; }
.pk-none { color: var(--muted); }
@media (pointer: coarse) { .pk-day { height: 40px; font-size: 15px; } .pk-pop-date { width: 300px; } .pk-time-input { font-size: 16px; } }

/* ---------- in-app confirm / notice pop-ups (ui.js) ---------- */
.ask-dialog { width: min(400px, calc(100vw - 32px)); }
.ask-body { padding: 22px 22px 6px; }
.ask-body h2 { margin: 0 0 6px; font-size: 17px; line-height: 1.35; word-break: break-word; }
.ask-body p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.45; }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 18px; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-solid:hover { filter: brightness(1.08); }

/* ---------- calendar ---------- */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 6px; min-width: 0; }
.btn.icon { width: 32px; padding: 4px 0; font-size: 17px; line-height: 1; }
.cal-actions { display: flex; align-items: center; gap: 10px; }

/* "+ New" splits into [To-do] [Event]: the New button folds away while the two options widen in. */
/* Header "+ New" (calendar, Home, Homework): a quiet white button that splits evenly into
   To-do and Event halves. Only the "+" and the icons are blue. */
.new-split, .new-single { position: relative; width: 220px; height: 42px; flex-shrink: 0; }
.new-main, .new-opt {
  position: absolute; top: 0; bottom: 0; border: 1px solid var(--border); border-radius: 11px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap;
  background: var(--surface); box-shadow: var(--shadow);
}
.new-plus { color: var(--primary); font-size: 18px; font-weight: 500; line-height: 1; margin-top: -1px; }
.new-main {
  left: 0; right: 0;
  transition: opacity 0.16s ease, transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1), border-color 0.15s;
}
.new-main:focus-visible, .new-opt:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.new-options { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity 0.16s ease; }
/* Each half is just under 50% wide, leaving a small gap down the middle where the button splits. */
.new-main:hover { border-color: color-mix(in srgb, var(--muted) 55%, var(--border)); }
.new-opt { width: calc(50% - 3px); transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1), background 0.15s, border-color 0.15s, color 0.15s; }
.new-opt svg { width: 17px; height: 17px; fill: none; stroke: var(--primary); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.new-opt[data-new-type="todo"] { left: 0; transform: translateX(6px) scale(0.97); }
.new-opt[data-new-type="event"] { right: 0; transform: translateX(-6px) scale(0.97); }
.new-opt:hover {
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); color: var(--primary);
}
.new-split.open .new-main { opacity: 0; transform: scale(0.97); pointer-events: none; }
.new-split.open .new-options { opacity: 1; pointer-events: auto; }
.new-split.open .new-opt { transform: none; }
@media (hover: hover) and (pointer: fine) {
  .new-split:hover .new-main { opacity: 0; transform: scale(0.97); pointer-events: none; }
  .new-split:hover .new-options { opacity: 1; pointer-events: auto; }
  .new-split:hover .new-opt { transform: none; }
}

/* Day menu: grows from where the day was clicked. */
.day-pop {
  position: fixed; z-index: 40; min-width: 170px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  display: flex; flex-direction: column; gap: 2px;
  opacity: 0; transform: scale(0.92); transition: opacity 0.14s ease, transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.day-pop[hidden] { display: none; }
.day-pop.show { opacity: 1; transform: none; }
.day-pop-date { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 6px 10px 4px; }
.day-pop button {
  display: flex; align-items: center; gap: 10px; border: 0; background: none; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text);
}
.day-pop button:hover, .day-pop button:focus-visible { background: var(--bg); outline: none; }
.pop-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; }
.pop-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pop-icon.is-todo { background: color-mix(in srgb, var(--primary) 14%, var(--surface)); color: var(--primary); }
.pop-icon.is-event { background: color-mix(in srgb, var(--primary) 14%, var(--surface)); color: var(--primary); }
@media (prefers-reduced-motion: reduce) { .new-main, .new-options, .new-opt, .day-pop { transition: none; } }
.cal-cell { cursor: pointer; }
.cal-cell:hover:not(:has(.cal-chip:hover, .cal-date:hover, .cal-more:hover)) { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.cal-cell.outside:hover:not(:has(.cal-chip:hover, .cal-date:hover, .cal-more:hover)) { background: color-mix(in srgb, var(--primary) 5%, var(--bg)); }
.segmented { display: inline-flex; background: var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; padding: 5px 14px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
/* Calendar To-dos / Both / Events slider: same track as .segmented, with a thumb that glides. */
.show-filter { --opt: 34px; position: relative; display: inline-flex; align-self: stretch; background: var(--border); border-radius: 9px; padding: 3px; gap: 2px; flex-shrink: 0; }
.show-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: var(--opt); border-radius: 7px;
  background: var(--surface); box-shadow: var(--shadow);
  transform: translateX(calc(var(--at, 1) * (var(--opt) + 2px))); transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.show-opt {
  position: relative; width: var(--opt); min-height: 26px; border: 0; background: none; padding: 0; border-radius: 7px;
  display: grid; place-items: center; color: var(--muted); cursor: pointer; transition: color 0.18s ease;
}
.show-opt svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.show-opt:hover { color: var(--text); }
.show-opt:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.show-filter[data-show="todo"] .show-todo { color: var(--primary); }
.show-filter[data-show="both"] .show-both { color: var(--text); }
.show-filter[data-show="event"] .show-event { color: var(--primary); }
@media (prefers-reduced-motion: reduce) { .show-thumb, .show-opt { transition: none; } }
/* While the filter eases the calendar to a new size, cells clip anything that doesn't fit yet. */
.cal-body.resizing .cal-cell, .cal-body.resizing .cal-day-col { overflow: hidden; }
/* Day view Time ⇄ Group: rows glide between cards, so cards don't clip them meanwhile. */
.cal-body.regrouping .day-card, .home.regrouping .day-card { overflow: visible; }
.cal-body.regrouping .day-row, .home.regrouping .day-row { z-index: 1; }

.cal-month { overflow: hidden; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekdays div { padding: 8px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 108px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-grid > .cal-cell:nth-last-child(-n + 7) { border-bottom: 0; }
.cal-cell.outside { background: var(--bg); }
.cal-cell.outside .cal-date { color: var(--muted); opacity: 0.6; }
.cal-date { align-self: flex-start; border: 0; background: none; width: 26px; height: 26px; border-radius: 50%; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text); padding: 0; }
.cal-date:hover { background: var(--bg); }
.cal-cell.today .cal-date { background: var(--primary); color: #fff; }
.cal-chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-dots { display: none; }

.cal-chip {
  display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0; text-align: left;
  border: 0; border-radius: 5px; padding: 3px 6px 3px 8px; cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--text); background: color-mix(in srgb, var(--chip) 14%, var(--surface));
  box-shadow: inset 3px 0 0 var(--chip);
}
.cal-chip:hover { background: color-mix(in srgb, var(--chip) 24%, var(--surface)); }
/* To-dos: a small circle (checks it off). Events: no circle, time first. */
.cal-chip-text { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.cal-check {
  flex-shrink: 0; width: 12px; height: 12px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1.5px solid var(--chip); background: var(--surface); position: relative;
  transition: background 0.12s;
}
.cal-check:hover { background: color-mix(in srgb, var(--chip) 30%, var(--surface)); }
.cal-check.checked { background: var(--chip); }
.cal-check.checked::after {
  content: ""; position: absolute; left: 3px; top: 0.5px; width: 3px; height: 6px;
  border: solid #fff; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
@media (pointer: coarse) {
  /* Bigger target for fingers. */
  .cal-check { width: 17px; height: 17px; }
  .cal-check.checked::after { left: 5px; top: 1.5px; width: 4px; height: 8px; border-width: 0 2px 2px 0; }
}
.cal-chip.event.done .cal-chip-title { text-decoration: none; }
.cal-chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip.done { opacity: 0.55; }
.cal-chip.done .cal-chip-title { text-decoration: line-through; }
.cal-chip.overdue { color: var(--overdue); }
.cal-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.cal-more { border: 0; background: none; text-align: left; font-size: 12px; color: var(--muted); cursor: pointer; padding: 1px 6px; }
.cal-more:hover { color: var(--text); }
.cal-chips .cut { display: none; }
/* Month view fills the window instead of scrolling: the page becomes a column and the grid's
   week rows share whatever height is left (never shorter than 48px). */
.main.fit { display: flex; flex-direction: column; padding-bottom: 24px; }
.main.fit > #view, .main.fit .cal-body, .main.fit .cal-month, .main.fit .day-canvas.timeline-mode { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.main.fit .cal-grid { flex: 1; min-height: 0; grid-template-rows: repeat(var(--weeks), minmax(48px, 1fr)); }
.main.fit .cal-cell { min-height: 0; overflow: hidden; padding: 5px; gap: 3px; }
.main.fit .cal-date { width: 24px; height: 24px; }
.main.fit .cal-chips { flex: 1; min-height: 0; position: relative; overflow: hidden; }

.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); overflow: hidden; }
.cal-day-col { border-right: 1px solid var(--border); min-height: 320px; display: flex; flex-direction: column; min-width: 0; }
.cal-day-col:last-child { border-right: 0; }
.cal-day-head { border: 0; border-bottom: 1px solid var(--border); background: none; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.cal-day-head:hover { background: var(--bg); }
.cal-dow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.cal-dnum { font-size: 18px; font-weight: 700; color: var(--text); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.cal-day-col.today .cal-dnum { background: var(--primary); color: #fff; }
.cal-day-items { padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal-day-items .cal-chip { align-items: flex-start; gap: 6px; padding: 5px 6px 5px 9px; }
.cal-day-items .cal-chip-text { flex-direction: column; align-items: flex-start; gap: 1px; }
.cal-day-items .cal-check { margin-top: 2px; }
.cal-day-items .cal-chip-title { white-space: normal; word-break: break-word; }
.cal-none { color: var(--muted); font-size: 13px; text-align: center; padding-top: 8px; opacity: 0.6; }
/* Week columns and the day view: empty space is clickable to add (like month cells). */
.cal-day-col { cursor: pointer; }
.cal-day-col:hover:not(:has(.cal-chip:hover, .cal-day-head:hover)) .cal-day-items { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.cal-day-items { flex: 1; }
/* ---------- calendar day view ---------- */
.day-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; cursor: default; }
.day-count { font-size: 13px; color: var(--muted); }
/* Home / Homework: what the page is, with an encouragement under it. */
/* Home / Homework encouragement next to the switch: a touch larger, in the main text color. */
.home-cheer { min-width: 0; font-size: 15px; font-weight: 500; line-height: 1.4; color: var(--text); }
.home .day-tools .segmented { flex-shrink: 0; }
/* Home: To-dos / Both / Events slider beside the Chronological / Group switch. */
.home-switches { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.home-switches .show-filter { --opt: 30px; }
.home-switches .show-opt { min-height: 22px; }
.home-switches .show-opt svg { width: 15px; height: 15px; }
@media (max-width: 760px) {
  .home .day-tools { flex-direction: column; align-items: stretch; gap: 10px; }
  .home-switches .segmented { flex: 1; }
}
.small-seg button { padding: 4px 12px; font-size: 12px; }
.day-card { overflow: hidden; cursor: default; }
.day-row {
  display: grid; grid-template-columns: 72px 22px minmax(0, 1fr); align-items: start; column-gap: 10px;
  padding: 12px 16px; cursor: pointer; position: relative;
}
.day-section .day-row { grid-template-columns: 22px minmax(0, 1fr); }
.day-row + .day-row { border-top: 1px solid var(--border); }
.day-row:hover { background: var(--bg); }
.day-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.day-time { font-size: 12.5px; font-weight: 600; color: var(--text); padding-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-time.anytime { color: var(--muted); font-weight: 500; }
.day-mark { display: flex; justify-content: center; padding-top: 3px; }
.day-mark .cal-check { width: 16px; height: 16px; border-width: 2px; }
.day-mark .cal-check.checked::after { left: 4px; top: 1px; width: 4px; height: 8px; border-width: 0 2px 2px 0; }
.day-title { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.35; word-break: break-word; }
.day-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 3px; font-size: 13px; color: var(--muted); }
.day-sub .sep { opacity: 0.5; }
.day-group { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 500; }
.day-group .dot { width: 8px; height: 8px; }
.day-notes { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.day-overdue { color: var(--overdue); font-weight: 600; }
/* Events: a solid bar in their color on a faint tint — no checkbox. */
.day-row.event { background: color-mix(in srgb, var(--chip) 7%, var(--surface)); }
.day-row.event:hover { background: color-mix(in srgb, var(--chip) 12%, var(--surface)); }
.event-bar { width: 4px; align-self: stretch; min-height: 20px; height: 100%; border-radius: 3px; background: var(--chip); }
.day-row.event .day-mark { align-self: stretch; padding: 2px 0; }
/* Done to-dos and past events quiet down. */
.day-row.done .day-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.day-row.done .day-sub { opacity: 0.7; }
.day-section { margin-bottom: 16px; cursor: default; }
.day-section-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px 4px; font-size: 13px; font-weight: 700; color: var(--text); }
.day-section-head .muted { font-weight: 500; font-size: 12px; }
@media (max-width: 760px) {
  .day-row { grid-template-columns: 58px 20px minmax(0, 1fr); padding: 12px; column-gap: 8px; }
  .day-time { font-size: 12px; }
}

.day-canvas { min-height: calc(100vh - 200px); min-height: calc(100dvh - 200px); display: flex; flex-direction: column; cursor: pointer; border-radius: var(--radius); }
.day-canvas .day-list { cursor: default; }
.day-filler { flex: 1; min-height: 120px; border-radius: var(--radius); transition: background 0.15s; }
.day-filler:hover { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.day-empty:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.day-hint { font-size: 13px; margin-top: 6px; opacity: 0.8; }

/* Day view Chronological: a box that fills the window under the switch. Hours down the left,
   a 24-hour track that scrolls inside the box, untimed items in an "Any time" strip on top. */
.main.fit .day-canvas.timeline-mode { flex: 1; min-height: 0; cursor: default; }
.tl { --hour: 60px; --gutter: 64px; flex: 1; min-height: 260px; display: flex; flex-direction: column; overflow: hidden; }
.tl-allday {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--border); cursor: pointer; max-height: 30%; overflow-y: auto; flex-shrink: 0;
}
.tl-allday-label {
  width: calc(var(--gutter) - 10px); flex-shrink: 0; text-align: right; padding-top: 6px;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.tl-allday-items { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.tl-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 0 14px; cursor: pointer; }
.tl-day { position: relative; height: calc(24 * var(--hour)); }
/* Hour lines run across the track; the label sits on its line in the left column. */
.tl-hour { position: absolute; left: 0; right: 0; top: var(--top); height: 0; border-top: 1px solid var(--border); margin-left: var(--gutter); pointer-events: none; }
.tl-hour::after { content: ""; position: absolute; left: 0; right: 0; top: calc(var(--hour) / 2); border-top: 1px dashed color-mix(in srgb, var(--border) 60%, transparent); }
.tl-hour span {
  position: absolute; right: calc(100% + 10px); top: 0; transform: translateY(-50%);
  font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.tl-track { position: absolute; inset: 0 10px 0 calc(var(--gutter) + 4px); }
.tl-scroll:hover .tl-day:not(:has(.tl-item:hover)) { background: color-mix(in srgb, var(--primary) 2.5%, transparent); }

/* Items: to-dos are outlined in their color with the round check; events a solid bar on a tint. */
.tl-item {
  display: flex; align-items: flex-start; gap: 7px; min-width: 0; overflow: hidden;
  padding: 5px 8px 5px 10px; border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--text);
  background: color-mix(in srgb, var(--chip) 14%, var(--surface));
  box-shadow: inset 3px 0 0 var(--chip), 0 0 0 1px color-mix(in srgb, var(--chip) 22%, transparent);
  transition: background 0.15s, box-shadow 0.15s;
}
.tl-track > .tl-item {
  position: absolute; top: var(--top); height: var(--h);
  left: calc(var(--col) * 100% / var(--cols)); width: calc(100% / var(--cols) - 3px);
}
.tl-track > .tl-item:hover, .tl-track > .tl-item:focus-visible { z-index: 2; }
.tl-item:hover { background: color-mix(in srgb, var(--chip) 22%, var(--surface)); }
.tl-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.tl-item.todo { background: var(--surface); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--chip) 55%, transparent); padding-left: 8px; }
.tl-item.todo:hover { background: color-mix(in srgb, var(--chip) 8%, var(--surface)); }
.tl-item .cal-check { width: 15px; height: 15px; border-width: 2px; margin-top: 1px; }
.tl-item .cal-check.checked::after { left: 3.5px; top: 0.5px; width: 4px; height: 7px; border-width: 0 2px 2px 0; }
.tl-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tl-title { font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-time { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-group { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-group .dot { width: 7px; height: 7px; flex-shrink: 0; }
/* Half-hour blocks: title and time on one line, no group line. */
.tl-item.short { align-items: center; padding-top: 2px; padding-bottom: 2px; }
.tl-item.short .cal-check { margin-top: 0; }
.tl-item.short .tl-text { flex-direction: row; align-items: baseline; gap: 6px; }
/* On one line the title keeps its room and the time gives way first. */
.tl-item.short .tl-title, .tl-allday .tl-title { flex-shrink: 0; max-width: 100%; }
.tl-item.short .tl-time { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* The hour label next to the now line steps aside. */
.tl-hour.near-now span { opacity: 0; }
.tl-item.short .tl-group { display: none; }
/* Any time strip: compact chips. */
.tl-allday .tl-item { padding: 4px 10px 4px 8px; align-items: center; max-width: 100%; }
.tl-allday .tl-item.event { padding-left: 10px; }
.tl-allday .tl-item .cal-check { margin-top: 0; }
.tl-allday .tl-text { flex-direction: row; align-items: baseline; gap: 6px; }
.tl-allday .tl-group { display: none; }
/* Done to-dos and past events quiet down; overdue to-dos turn red. */
.tl-item.done .tl-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.tl-item.done, .tl-item.past { opacity: 0.6; }
.tl-item.overdue .tl-title { color: var(--overdue); }
/* Now: a line across the day with a dot on the hour column's edge. */
.tl-now { position: absolute; top: var(--top); left: calc(var(--gutter) - 4px); right: 0; height: 0; border-top: 2px solid var(--overdue); z-index: 3; pointer-events: none; transition: top 0.6s ease; }
.tl-now::before { content: ""; position: absolute; left: -4px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--overdue); }
/* Chronological ⇄ Group: blocks glide in and out of the box, so let them show over its edges. */
.cal-body.regrouping .tl-item { z-index: 2; }
@media (max-width: 760px) {
  .tl { --hour: 52px; --gutter: 50px; }
  .tl-hour span { right: calc(100% + 7px); font-size: 10.5px; }
  .tl-track { right: 6px; }
}
@media (prefers-reduced-motion: reduce) { .tl-item, .tl-now { transition: none; } }

/* Home: the calendar's day-view rows, in foldable sections with day-view style headings. */
/* Section headings (Overdue, Today, …): large titles with a count pill; Overdue and Today
   tint their pill instead of coloring the whole title. */
.home .group { margin-bottom: 26px; }
.home .group.collapsed { margin-bottom: 14px; }
.home .group h3 {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; text-transform: none; letter-spacing: -0.01em; color: var(--text); margin: 0 0 10px;
  transition: font-size 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), margin 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
/* Folded sections step back: smaller titles, easing to and from the open size. */
.home .group.collapsed h3 { font-size: 15px; margin-bottom: 6px; }
@media (prefers-reduced-motion: reduce) { .home .group h3 { transition: none; } }
.home .group-toggle { gap: 9px; font-weight: 700; padding: 2px 6px 2px 0; }
.home .group-toggle .chev { width: 14px; height: 14px; color: var(--muted); }
/* Hovering a heading only darkens its arrow (no dimming of the title or counts). */
.home .home-group .group-toggle:hover { filter: none; color: inherit; }
.home .group-toggle:hover .chev { color: var(--text); }
/* Count pills: folded, one total; open, it splits into a to-do pill and an event pill (both
   blue, told apart by icon). Both states stay in the page and ease between widths. */
.sec-count { display: inline-flex; align-items: center; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.sec-total, .sec-part {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; line-height: 1;
  padding: 4px 8px; border-radius: 999px; white-space: nowrap; overflow: hidden;
}
.sec-total { background: color-mix(in srgb, var(--muted) 14%, var(--surface)); color: var(--muted); }
.home-group.overdue .sec-total { background: color-mix(in srgb, var(--overdue) 14%, var(--surface)); color: var(--overdue); }
.home-group.today .sec-total { background: color-mix(in srgb, var(--today) 16%, var(--surface)); color: var(--today); }
.sec-part svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sec-part.todo { background: color-mix(in srgb, var(--primary) 13%, var(--surface)); color: var(--primary); }
.sec-part.event { background: color-mix(in srgb, var(--primary) 13%, var(--surface)); color: var(--primary); }
.sec-part + .sec-part { margin-left: 4px; }
.sec-part.zero { opacity: 0.5; }
/* Completed - Past Week counts are green. */
.home-group.completed .sec-total, .home-group.completed .sec-part {
  background: color-mix(in srgb, var(--done) 15%, var(--surface)); color: var(--done);
}
/* Small Hide button that follows the completed section's counts. */
.hide-done {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0; padding: 3px 10px; border-radius: 999px;
  transition: color 0.15s, border-color 0.15s;
}
.hide-done:hover { color: var(--text); border-color: color-mix(in srgb, var(--muted) 60%, var(--border)); }
.hide-done:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.home-group.overdue .sec-part.todo { background: color-mix(in srgb, var(--overdue) 14%, var(--surface)); color: var(--overdue); }
.sec-split { display: inline-flex; }
.sec-total, .sec-split {
  max-width: 140px;
  transition: max-width 0.26s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease, padding 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
/* Open: the total folds away, the split shows. Folded: the reverse. */
.home .group:not(.collapsed) .sec-total { max-width: 0; opacity: 0; padding-left: 0; padding-right: 0; }
.home .group.collapsed .sec-split { max-width: 0; opacity: 0; }
@media (prefers-reduced-motion: reduce) { .sec-total, .sec-split { transition: none; } }
.group-body > .home-subs { min-height: 0; overflow: hidden; }
/* Group mode: small group headings inside each time section, like the day view's. */
.home-sub + .home-sub { margin-top: 12px; }
.home-sub-head { display: flex; align-items: center; gap: 7px; margin: 0 0 6px 4px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.home-sub-head .dot { width: 8px; height: 8px; }
.home-sub-head .muted { font-weight: 500; font-size: 12px; }
.day-end { display: block; font-weight: 500; color: var(--muted); }
.day-date { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 1px; }
.day-row.past { opacity: 0.6; }
.home-foot { display: flex; justify-content: center; margin: 6px 0 8px; }
.show-done {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 7px 16px; border-radius: 999px; transition: color 0.15s, border-color 0.15s;
}
.show-done:hover { color: var(--text); border-color: color-mix(in srgb, var(--muted) 60%, var(--border)); }
.show-done:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- mobile ---------- */

@media (max-width: 760px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .sidebar.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 10; opacity: 0; pointer-events: none; transition: opacity 0.22s ease; }
  .scrim.open { opacity: 1; pointer-events: auto; }
  .menu-btn { display: block; }
  .main { padding: 16px 16px 40px; }
  .title-wrap h1 { font-size: 21px; }
  .menu-btn { align-self: flex-start; }
  /* calendar on phones: month shows dots (tap a day for details); week stacks by day */
  .cal-actions { width: 100%; gap: 8px; }
  .cal-toolbar .segmented { flex: 1; min-width: 0; }
  .segmented button { flex: 1; }
  .cal-toolbar .segmented button { padding-left: 6px; padding-right: 6px; }
  .show-filter { --opt: 30px; }
  .cal-cell { min-height: 54px; padding: 4px 2px; align-items: center; cursor: pointer; }
  .cal-weekdays div { padding: 6px 0; text-align: center; font-size: 10px; }
  .cal-date { align-self: center; width: 26px; height: 26px; }
  .cal-chips { display: none; }
  .cal-dots { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; max-width: 100%; }
  .cal-dots span { width: 6px; height: 6px; border-radius: 50%; }
  .cal-week { grid-template-columns: 1fr; }
  .cal-day-col { min-height: 0; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--border); }
  .cal-day-col:last-child { border-bottom: 0; }
  .cal-day-head { border-bottom: 0; border-right: 1px solid var(--border); width: 64px; flex-shrink: 0; }
  .cal-day-items { flex: 1; min-width: 0; }
  .cal-none { text-align: left; padding: 6px 4px; }
  .topbar { flex-wrap: wrap; }
  .title-actions { width: 100%; justify-content: flex-start; }
  .title-actions:empty { display: none; }
  #add-assignment { flex: 1; }
  .new-split, .new-single { width: 100%; }
        .item .actions { opacity: 1; }
  .row { flex-direction: column; }
}

/* ---------- info pop-up (click a to-do or event) ---------- */
.info-pop {
  position: fixed; z-index: 45; width: 320px; max-width: calc(100vw - 16px); padding: 14px 14px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 16px 40px rgba(10, 14, 30, 0.22), 0 2px 6px rgba(10, 14, 30, 0.08);
  opacity: 0; transform: scale(0.94); transition: opacity 0.14s ease, transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.15);
  outline: none;
}
.info-pop[hidden] { display: none; }
.info-pop.show { opacity: 1; transform: none; }
.info-head { display: flex; align-items: flex-start; gap: 10px; }
.info-type {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 14%, var(--surface)); color: var(--primary);
}
.info-type svg, .info-row svg, .info-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.info-type svg { width: 17px; height: 17px; }
.info-titles { flex: 1; min-width: 0; }
.info-kind { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.info-title { margin: 1px 0 0; font-size: 17px; font-weight: 700; line-height: 1.3; color: var(--text); word-break: break-word; }
.info-status { font-size: 11px; letter-spacing: 0; text-transform: none; font-weight: 650; padding: 2px 7px; border-radius: 999px; }
.info-status.done { background: color-mix(in srgb, var(--done) 15%, var(--surface)); color: var(--done); }
.info-status.overdue { background: color-mix(in srgb, var(--overdue) 14%, var(--surface)); color: var(--overdue); }
.info-btn {
  width: 30px; height: 30px; flex-shrink: 0; border: 0; border-radius: 8px; background: none; color: var(--muted);
  display: grid; place-items: center; cursor: pointer; transition: background 0.12s, color 0.12s;
}
.info-btn svg { width: 17px; height: 17px; }
.info-btn:hover { background: var(--bg); color: var(--text); }
.info-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.info-rows { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.info-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text); line-height: 1.4; }
.info-row svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--muted); margin-top: 1px; }
.info-dot-wrap { width: 17px; height: 20px; flex-shrink: 0; display: grid; place-items: center; }
.info-dot { width: 10px; height: 10px; border-radius: 50%; }
.info-notes span { white-space: pre-wrap; word-break: break-word; color: var(--muted); }
.item { cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .info-pop { transition: none; } }

/* ---------- Home progress ring (right column, computers only) ---------- */
.ring-card { display: none; }
/* Only when there's room for the list (~620px+) beside it: laptop and desktop screens. */
@media (min-width: 1180px) {
  /* The list keeps its usual width on the left; everything from its edge to the window edge is
     one column, with the ring card and + New centered in it (same columns for both rows). */
  .main.with-ring { padding-right: 0; }
  .main.with-ring > * { max-width: none; }
  .main.with-ring .topbar, .home-layout { display: grid; grid-template-columns: minmax(0, 900px) minmax(284px, 1fr); align-items: start; }
  .main.with-ring .topbar { align-items: center; column-gap: 0; }
  .main.with-ring .title-actions { justify-self: center; }
  .ring-card { justify-self: center; width: 220px; }
  .ring-card {
    display: flex; flex-direction: column; align-items: center; gap: 12px; position: sticky; top: 0;
    padding: 14px 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  }
}
.ring-head { position: relative; align-self: stretch; display: flex; justify-content: center; }
.ring-period {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; cursor: pointer; padding: 4px 8px; border-radius: 8px;
  font: inherit; font-size: 14px; font-weight: 700; color: var(--text);
}
.ring-period .chev { width: 12px; height: 12px; color: var(--muted); transition: transform 0.15s ease; }
.ring-period[aria-expanded="true"] .chev { transform: rotate(180deg); }
.ring-period:hover { background: var(--bg); }
.ring-period:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.ring-menu {
  position: absolute; top: calc(100% + 4px); left: 50%; transform: translateX(-50%); z-index: 5; min-width: 150px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  display: flex; flex-direction: column; gap: 2px;
}
.ring-menu[hidden] { display: none; }
.ring-menu button {
  border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 7px; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--text);
}
.ring-menu button:hover, .ring-menu button:focus-visible { background: var(--bg); outline: none; }
.ring-menu button[aria-checked="true"] { color: var(--primary); font-weight: 600; }
.ring { position: relative; width: 180px; height: 180px; }
.ring > svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--border); stroke-width: 9; }
.ring-fill {
  fill: none; stroke: var(--primary); stroke-width: 9; stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), stroke 0.3s ease;
}
.ring.complete .ring-fill { stroke: var(--done); }
.ring-center { position: absolute; inset: 0; display: grid; place-items: center; }
.ring-num { font-size: 38px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.ring-of { font-size: 20px; font-weight: 600; color: var(--muted); }
.ring-check svg { width: 58px; height: 58px; fill: none; stroke: var(--done); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.ring-caption { font-size: 13px; color: var(--muted); text-align: center; }
@media (prefers-reduced-motion: reduce) { .ring-fill { transition: none; } }
