/* Design tokens ----------------------------------------------------------- */
:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg: #f4f5fa;
  --bg-glow-1: #e6eaff;
  --bg-glow-2: #fdeee6;
  --surface: #ffffff;
  --surface-2: #f3f5fa;
  --surface-3: #e9ecf4;
  --ink: #151b2e;
  --ink-soft: #2b3349;
  --muted: #5d667b;
  --outline: #e3e7f0;
  --outline-strong: #cdd4e3;
  --shadow-sm: 0 1px 2px #1a23400d, 0 1px 1px #1a234008;
  --shadow-md: 0 1px 2px #1a23400f, 0 8px 24px -6px #1a234024;
  --shadow-lg: 0 24px 64px -12px #0d143066;

  --accent: #4257e0;
  --accent-strong: #3445c4;
  --accent-ink: #2f40b6;
  --accent-wash: #eceffe;
  --accent-contrast: #ffffff;

  --late: #c42b4c;
  --late-wash: #fdeaee;
  --today: #b15700;
  --today-wash: #fff0dc;
  --soon: #3349c6;
  --soon-wash: #e8ecff;
  --ok: #1d8656;
  --ok-wash: #e2f5ea;
  --neutral-wash: #edf0f6;

  --subject-l: .56;
  --subject-c: .16;
  --subject-wash-l: .965;
  --subject-wash-c: .03;
  --subject-ink-l: .42;

  --radius-sm: .6rem;
  --radius: .9rem;
  --radius-lg: 1.25rem;
  --tap: 2.75rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1119;
    --bg-glow-1: #1b2142;
    --bg-glow-2: #2a1b1d;
    --surface: #171a25;
    --surface-2: #1d2130;
    --surface-3: #262b3d;
    --ink: #eef0f7;
    --ink-soft: #d3d7e4;
    --muted: #9aa2b8;
    --outline: #282d3e;
    --outline-strong: #3a4157;
    --shadow-sm: 0 1px 2px #00000040;
    --shadow-md: 0 1px 2px #00000040, 0 10px 28px -8px #00000080;
    --shadow-lg: 0 24px 64px -12px #000000b3;

    --accent: #7086ff;
    --accent-strong: #8597ff;
    --accent-ink: #a9b6ff;
    --accent-wash: #232a4d;
    --accent-contrast: #0c1030;

    --late: #ff7a93;
    --late-wash: #3a1823;
    --today: #ffb35c;
    --today-wash: #3a2812;
    --soon: #9fb0ff;
    --soon-wash: #222a4f;
    --ok: #5fd39a;
    --ok-wash: #15322a;
    --neutral-wash: #232838;

    --subject-l: .74;
    --subject-c: .13;
    --subject-wash-l: .27;
    --subject-wash-c: .045;
    --subject-ink-l: .84;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1119;
  --bg-glow-1: #1b2142;
  --bg-glow-2: #2a1b1d;
  --surface: #171a25;
  --surface-2: #1d2130;
  --surface-3: #262b3d;
  --ink: #eef0f7;
  --ink-soft: #d3d7e4;
  --muted: #9aa2b8;
  --outline: #282d3e;
  --outline-strong: #3a4157;
  --shadow-sm: 0 1px 2px #00000040;
  --shadow-md: 0 1px 2px #00000040, 0 10px 28px -8px #00000080;
  --shadow-lg: 0 24px 64px -12px #000000b3;

  --accent: #7086ff;
  --accent-strong: #8597ff;
  --accent-ink: #a9b6ff;
  --accent-wash: #232a4d;
  --accent-contrast: #0c1030;

  --late: #ff7a93;
  --late-wash: #3a1823;
  --today: #ffb35c;
  --today-wash: #3a2812;
  --soon: #9fb0ff;
  --soon-wash: #222a4f;
  --ok: #5fd39a;
  --ok-wash: #15322a;
  --neutral-wash: #232838;

  --subject-l: .74;
  --subject-c: .13;
  --subject-wash-l: .27;
  --subject-wash-c: .045;
  --subject-ink-l: .84;
}

/* Base -------------------------------------------------------------------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(60rem 30rem at 0% -10%, var(--bg-glow-1), transparent 70%),
    radial-gradient(50rem 26rem at 110% 0%, var(--bg-glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.is-busy { cursor: progress; }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); }
button, a, input, textarea, summary, label { -webkit-tap-highlight-color: transparent; }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus, section[tabindex="-1"]:focus { outline: none; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 1.25em;
  height: 1.25em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.muted { color: var(--muted); }

.skip-link {
  position: fixed;
  top: .75rem;
  left: .75rem;
  z-index: 20;
  padding: .625rem .875rem;
  background: var(--surface);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* Top bar ----------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--outline) 70%, transparent);
}

.topbar-inner,
.dashboard,
.settings {
  width: min(100% - 3rem, 76rem);
  margin-inline: auto;
}

.topbar-inner {
  min-height: 3.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.brand {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 750;
  font-size: 1.05rem;
  letter-spacing: -.02em;
}
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.brand-mark,
.gate-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: .7rem;
  color: #fff;
  background: linear-gradient(140deg, #6a7dff, #3c4fd6 55%, #2f3db4);
  box-shadow: 0 4px 12px -4px #3445c480, inset 0 1px 0 #ffffff40;
}
.brand-mark .icon { width: 1.2rem; height: 1.2rem; stroke-width: 2.2; }

.topbar-end,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink-soft);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-button:disabled { cursor: default; opacity: .35; background: transparent; }
body.is-busy .icon-button:disabled { cursor: progress; }
.icon-button-small { width: 2.25rem; height: 2.25rem; }
.icon-button-small .icon { width: 1.1rem; height: 1.1rem; }
.is-spinning .icon { animation: spin .9s linear infinite; }
.is-spinning:disabled { opacity: 1; }

.schedule-jump { display: none; }

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 2.25rem;
  margin-right: .25rem;
  padding: .3rem .8rem .3rem .7rem;
  border-radius: 99rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--outline);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}

.sync-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--muted);
}
.sync-dot[data-tone="ok"] { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-wash); }
.sync-dot[data-tone="stale"] { background: var(--today); box-shadow: 0 0 0 3px var(--today-wash); }
.sync-dot[data-tone="demo"] { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.sync-dot[data-tone="off"] { background: var(--outline-strong); }

/* Buttons ----------------------------------------------------------------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: var(--tap);
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: 99rem;
  font-size: .95rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
.button:active:not(:disabled) { transform: scale(.97); }
.button .icon { width: 1.15rem; height: 1.15rem; }
.button-small { min-height: 2.5rem; padding: .4rem .8rem; font-size: .9rem; }
.button-block { width: 100%; }

.button-primary {
  color: var(--accent-contrast);
  background: var(--accent);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.button-secondary {
  color: var(--accent-ink);
  background: var(--surface);
  border-color: var(--outline-strong);
}
.button-quiet { color: var(--accent-ink); background: transparent; }
.button-danger { color: #fff; background: #c42b4c; }
.button-attention { color: var(--accent-ink); background: var(--accent-wash); }
.button:disabled { cursor: default; opacity: .55; box-shadow: none; }
body.is-busy .button:disabled { cursor: progress; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-block: .2rem .55rem;
}
.chip-row:empty { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 2.5rem;
  padding: .35rem .85rem;
  border: 1px solid var(--outline-strong);
  border-radius: 99rem;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip[aria-pressed="true"] {
  color: var(--accent-contrast);
  background: var(--accent);
  border-color: var(--accent);
}
.chip-subject::before {
  content: "";
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: oklch(var(--subject-l) var(--subject-c) var(--hue, 250));
}
.chip-subject[aria-pressed="true"] {
  color: oklch(var(--subject-ink-l) var(--subject-c) var(--hue, 250));
  background: oklch(var(--subject-wash-l) var(--subject-wash-c) var(--hue, 250));
  border-color: oklch(var(--subject-l) var(--subject-c) var(--hue, 250));
}

/* Page heading and summary ------------------------------------------------ */
.dashboard,
.settings { padding-block: clamp(1.25rem, 3.5vw, 2.5rem) 5rem; }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.today {
  color: var(--accent-ink);
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: .2rem;
}

.page-heading h1,
.gate h1 {
  font-size: clamp(2rem, 4.6vw, 3rem);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.headline {
  margin-top: .45rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  font-weight: 550;
}
.headline:empty { display: none; }
.headline[data-tone="late"] { color: var(--late); }
.headline[data-tone="done"] { color: var(--ok); }

.add-task { flex: 0 0 auto; padding-inline: 1.15rem 1.3rem; }

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: .6rem;
  margin-bottom: 1.5rem;
}

.progress {
  --progress: 0;
  display: grid;
  gap: .45rem;
  flex: 1 1 15rem;
  max-width: 22rem;
  align-content: center;
  padding: .75rem 1rem .85rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--outline);
  box-shadow: var(--shadow-sm);
}
.progress-text {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0 .75rem;
  font-size: .85rem;
}
.progress-text strong { font-family: var(--font-display); font-size: 1rem; }
.progress-track {
  height: .5rem;
  border-radius: 99rem;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-bar {
  display: block;
  height: 100%;
  width: calc(var(--progress) * 100%);
  min-width: .5rem;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}
.progress.is-complete .progress-bar { background: linear-gradient(90deg, var(--ok), #34c38f); }

.stat-list {
  display: flex;
  flex: 999 1 20rem;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  align-content: stretch;
}
.stat-list li { display: flex; }
.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 5.5rem;
  min-height: 3.6rem;
  padding: .5rem .95rem;
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.stat:active { transform: scale(.97); }
.stat-count {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat[data-kind="late"] { background: var(--late-wash); border-color: transparent; }
.stat[data-kind="late"] .stat-count, .stat[data-kind="late"] .stat-label { color: var(--late); }
.stat[data-kind="today"] { background: var(--today-wash); border-color: transparent; }
.stat[data-kind="today"] .stat-count, .stat[data-kind="today"] .stat-label { color: var(--today); }
.stat[data-kind="tomorrow"] .stat-count { color: var(--soon); }
.stat[data-kind="unknown"] .stat-count { color: var(--muted); }
.stat[data-kind="done"] .stat-count { color: var(--ok); }

/* Columns ----------------------------------------------------------------- */
.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(18rem, 1fr);
  align-items: start;
  gap: clamp(1.25rem, 3vw, 2rem);
}

.task-column,
.side-column {
  min-width: 0;
  display: grid;
  gap: 1.5rem;
}

.side-column {
  position: sticky;
  top: 5rem;
}

.task-groups { display: grid; gap: 1.5rem; }
.task-groups:empty { display: none; }

.next-label,
.group-heading {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: 0 .2rem .65rem;
  font-size: .82rem;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.next-label { color: var(--accent-ink); }
.pulse {
  position: relative;
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--accent);
}
.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  animation: pulse 2s ease-out infinite;
}
.group-heading::before {
  content: "";
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--outline-strong);
}
.task-group[data-kind="late"] .group-heading { color: var(--late); }
.task-group[data-kind="late"] .group-heading::before { background: var(--late); }
.task-group[data-kind="today"] .group-heading { color: var(--today); }
.task-group[data-kind="today"] .group-heading::before { background: var(--today); }
.task-group[data-kind="tomorrow"] .group-heading { color: var(--soon); }
.task-group[data-kind="tomorrow"] .group-heading::before { background: var(--soon); }
.task-group[data-kind="unknown"] .group-heading::before { background: transparent; border: 2px dashed var(--muted); }
.group-count {
  min-width: 1.5rem;
  padding: .05rem .45rem;
  border-radius: 99rem;
  background: var(--surface-3);
  color: var(--ink-soft);
  font-size: .78rem;
  letter-spacing: 0;
  text-align: center;
}

/* Task cards -------------------------------------------------------------- */
.task-list { display: grid; gap: .75rem; }

.task-card {
  --subject: oklch(var(--subject-l) var(--subject-c) var(--hue, 250));
  --subject-wash: oklch(var(--subject-wash-l) var(--subject-wash-c) var(--hue, 250));
  --subject-ink: oklch(var(--subject-ink-l) var(--subject-c) var(--hue, 250));
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, border-color .2s, opacity .3s, transform .3s;
}
.task-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: .3rem;
  background: var(--subject);
}
.task-card.is-new { animation: arrive .6s cubic-bezier(.2, .8, .2, 1); }

.task-body { padding: 1rem 1.15rem .7rem 1.4rem; }

.task-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .4rem;
}

.subject-tag {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}
.subject-dot {
  flex: 0 0 auto;
  width: .7rem;
  height: .7rem;
  border-radius: .25rem;
  background: var(--subject);
}
.task-subject {
  min-width: 0;
  color: var(--subject-ink);
  font-size: 1.12rem;
  font-weight: 750;
  line-height: 1.3;
  letter-spacing: -.015em;
  overflow-wrap: anywhere;
}

.due-label {
  flex: 0 0 auto;
  padding: .22rem .65rem;
  border-radius: 99rem;
  color: var(--ink-soft);
  background: var(--neutral-wash);
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}
.due-label[data-kind="late"] { color: var(--late); background: var(--late-wash); }
.due-label[data-kind="today"] { color: var(--today); background: var(--today-wash); }
.due-label[data-kind="soon"] { color: var(--soon); background: var(--soon-wash); }
.due-label[data-kind="unknown"] {
  color: var(--muted);
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--outline-strong);
}

.task-text,
.task-materials-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.task-text {
  color: var(--ink);
  font-size: 1.02rem;
  margin-bottom: .75rem;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.25rem;
  color: var(--muted);
  font-size: .88rem;
}
.task-due,
.task-origin {
  display: flex;
  align-items: flex-start;
  gap: .45rem;
}
.task-meta .icon { width: 1.05rem; height: 1.05rem; margin-top: .12rem; }
.task-due-text { display: flex; flex-wrap: wrap; column-gap: .4rem; }
.due-date { color: var(--ink); font-weight: 700; }
.due-source::before { content: "· "; }
.task-unknown .due-date { color: var(--muted); }

.task-materials {
  display: flex;
  gap: .65rem;
  margin-top: .75rem;
  padding: .65rem .8rem;
  border-radius: var(--radius-sm);
  background: var(--subject-wash);
  font-size: .92rem;
}
.task-materials .icon { margin-top: .1rem; color: var(--subject-ink); }
.task-materials strong {
  display: block;
  color: var(--subject-ink);
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .35rem;
  padding: .45rem .7rem .55rem 1.1rem;
  border-top: 1px solid var(--outline);
}
.task-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .15rem;
}

.done-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  min-height: var(--tap);
  padding: .3rem 1rem .3rem .35rem;
  border-radius: 99rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s, color .15s;
}
.done-control input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.done-box {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  border: 2px solid var(--outline-strong);
  border-radius: 50%;
  background: var(--surface);
  color: transparent;
  transition: background-color .2s, border-color .2s, color .2s, transform .2s;
}
.done-box .icon { width: 1.1rem; height: 1.1rem; stroke-width: 3; }
.done-control input:checked + .done-box {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
  animation: pop .35s cubic-bezier(.2, 1.6, .4, 1);
}
.done-control input:focus-visible + .done-box { outline: 3px solid var(--accent); outline-offset: 2px; }
.done-control:has(input:checked) { color: var(--ok); }
.done-control input:disabled { cursor: progress; }

.task-featured {
  border-color: color-mix(in srgb, var(--subject) 35%, var(--outline));
  background:
    linear-gradient(160deg, var(--subject-wash), var(--surface) 55%);
  box-shadow: var(--shadow-md);
}
.task-featured::before { width: .4rem; }
.task-featured .task-body { padding: 1.3rem 1.4rem .9rem 1.7rem; }
.task-featured .task-subject { font-size: 1.5rem; }
.task-featured .subject-dot { width: .85rem; height: .85rem; }
.task-featured .task-text { font-size: 1.12rem; }
.task-featured .due-label { font-size: .9rem; padding: .3rem .8rem; }
.task-featured .task-actions { padding-left: 1.35rem; border-top-color: color-mix(in srgb, var(--subject) 15%, var(--outline)); }
.task-featured .task-materials { background: var(--surface); border: 1px solid color-mix(in srgb, var(--subject) 20%, var(--outline)); }

.task-done { background: var(--surface-2); box-shadow: none; }
.task-done::before { background: var(--outline-strong); }
.task-done .task-subject { color: var(--muted); }
.task-done .subject-dot { background: var(--outline-strong); }
.task-done .task-text { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); }
.task-done .task-materials { display: none !important; }
.task-done .task-buttons { display: none; }
.task-card.is-completing { opacity: .55; }

/* Completed list ---------------------------------------------------------- */
.completed {
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.completed > summary {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 3.5rem;
  padding: .5rem 1rem;
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
  border-radius: inherit;
}
.completed-check {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  color: #fff;
  background: var(--ok);
}
.completed-check .icon { width: 1rem; height: 1rem; stroke-width: 3; }
.summary-chevron { margin-left: auto; color: var(--muted); transition: transform .2s; }
details[open] > summary .summary-chevron { transform: rotate(180deg); }
.completed .task-list { padding: 0 .75rem .75rem; }

/* Empty state ------------------------------------------------------------- */
.empty-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--outline);
  box-shadow: var(--shadow-sm);
}
.empty-card h2 { font-size: 1.3rem; }
.empty-card p { margin-top: .2rem; }
.empty-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-3);
}
.empty-mark .icon { width: 1.6rem; height: 1.6rem; stroke-width: 2.6; }
.empty-done {
  padding-block: 2rem;
  background: linear-gradient(140deg, var(--ok-wash), var(--surface) 70%);
  border-color: color-mix(in srgb, var(--ok) 25%, var(--outline));
}
.empty-done .empty-mark {
  width: 4rem;
  height: 4rem;
  color: #fff;
  background: var(--ok);
  box-shadow: 0 0 0 .5rem color-mix(in srgb, var(--ok) 18%, transparent);
  animation: pop .5s cubic-bezier(.2, 1.6, .4, 1);
}
.empty-done h2 { color: var(--ok); font-size: 1.5rem; }

/* Side cards -------------------------------------------------------------- */
.side-card {
  padding: 1.1rem 1.15rem 1.15rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--outline);
  box-shadow: var(--shadow-sm);
}
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: 2.25rem;
}
.side-card h2 { font-size: 1.15rem; letter-spacing: -.015em; }

.schedule-heading {
  display: flex;
  align-items: center;
}

.day-switcher { display: flex; gap: .15rem; margin-right: -.4rem; }

.schedule-day {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .1rem .5rem;
  margin-top: .35rem;
  font-size: .92rem;
}
.schedule-day strong { font-family: var(--font-display); font-size: 1.05rem; }
.schedule-day span { color: var(--muted); }
.schedule-day .schedule-day-note {
  padding: .05rem .5rem;
  border-radius: 99rem;
  color: var(--late);
  background: var(--late-wash);
  font-size: .78rem;
  font-weight: 700;
}

.lesson-list { list-style: none; margin: .65rem 0 0; padding: 0; display: grid; gap: .35rem; }
.lesson {
  --subject: oklch(var(--subject-l) var(--subject-c) var(--hue, 250));
  --subject-wash: oklch(var(--subject-wash-l) var(--subject-wash-c) var(--hue, 250));
  display: grid;
  grid-template-columns: 3.1rem .25rem minmax(0, 1fr);
  align-items: stretch;
  gap: .7rem;
  padding: .45rem .55rem .45rem .2rem;
  border-radius: var(--radius-sm);
  font-size: .92rem;
}
.lesson-time {
  display: grid;
  align-content: center;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1.25;
}
.lesson-start { font-weight: 650; }
.lesson-end, .lesson-date { color: var(--muted); font-size: .78rem; }
.lesson-date { font-weight: 650; }
.lesson-bar { border-radius: 99rem; background: var(--subject); }
.lesson-info { display: grid; align-content: center; gap: .2rem; min-width: 0; overflow-wrap: anywhere; }
.lesson-subject { font-weight: 650; }
.lesson-tags { display: flex; flex-wrap: wrap; gap: .25rem; }
.lesson-tag {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .05rem .5rem;
  border-radius: 99rem;
  font-size: .75rem;
  font-weight: 700;
}
.lesson-tag .icon { width: .85rem; height: .85rem; stroke-width: 3; }
.tag-cancelled { color: var(--late); background: var(--late-wash); }
.tag-change { color: var(--today); background: var(--today-wash); }
.tag-homework { color: var(--ok); background: var(--ok-wash); }
.lesson-changed { background: color-mix(in srgb, var(--today-wash) 55%, transparent); }
.lesson-cancelled { background: color-mix(in srgb, var(--late-wash) 45%, transparent); }
.lesson-cancelled .lesson-bar { background: repeating-linear-gradient(var(--late) 0 4px, transparent 4px 7px); }
.lesson-cancelled .lesson-subject { color: var(--muted); text-decoration: line-through; }
.lesson-past { opacity: .45; }

.schedule-changes {
  margin-top: .85rem;
  border-top: 1px solid var(--outline);
}
.schedule-changes > summary {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--tap);
  padding-top: .5rem;
  color: var(--today);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
}
.schedule-changes > summary .icon:last-child { margin-left: auto; color: var(--muted); transition: transform .2s; }
.schedule-changes[open] > summary .icon:last-child { transform: rotate(180deg); }
.schedule-changes .lesson-list { margin-top: .2rem; }
.schedule-changes .lesson { grid-template-columns: 3.9rem .25rem minmax(0, 1fr); }
.side-empty { margin-top: .5rem; }

.source-status {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-top: .35rem;
  font-size: .92rem;
  font-weight: 600;
}
.source-note { margin-top: .4rem; font-size: .82rem; }
.source-links {
  margin-top: 1rem;
  padding: .9rem 1rem;
  border: 2px dotted var(--outline-strong);
  border-radius: .8rem;
}
.source-links-label { font-size: .82rem; font-weight: 600; }
.source-links-label .muted { font-weight: 400; }
.source-links .source-actions { margin-top: .45rem; }
.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .8rem;
}
.source-actions:not(:has(.button:not([hidden]))) { display: none; }
.demo-badge {
  border-radius: 99rem;
  padding: .15rem .6rem;
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-size: .8rem;
  font-weight: 700;
}

.empty-action { margin-top: .8rem; }

/* Settings ---------------------------------------------------------------- */
.icon-button[aria-current="page"] { color: var(--accent-ink); background: var(--accent-wash); }
.sync-pill[aria-current="page"] { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 40%, var(--outline)); }
.back-button { margin: 0 0 .4rem -.6rem; padding-left: .45rem; color: var(--accent-ink); }
.settings .page-heading { margin-bottom: 1.5rem; }
.settings-lead { margin-top: .45rem; font-size: 1rem; }
.settings-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  align-items: start;
  gap: clamp(1rem, 2.5vw, 1.5rem);
}
.settings-card { padding: 1.25rem 1.35rem 1.35rem; }
.settings-intro { margin-top: .3rem; font-size: .92rem; }
.settings-note {
  margin-top: .75rem;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: .88rem;
}
.settings-form .editor-field { margin-top: 1rem; }
.settings-form .source-actions { margin-top: 1.1rem; }
.button-quiet-danger { color: var(--late); }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .25rem;
  margin: 1rem 0 0;
  padding: .25rem;
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.segmented legend {
  float: left;
  grid-column: 1 / -1;
  width: 100%;
  margin-bottom: .35rem;
  padding: .2rem .3rem 0;
  font-size: .92rem;
  font-weight: 650;
}
.segmented label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 2.6rem;
  padding: .4rem .5rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: .9rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.segmented input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.segmented .icon { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; }
.segmented label:has(input:checked) { color: var(--accent-ink); background: var(--surface); box-shadow: var(--shadow-sm); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 1px; }

/* Gate -------------------------------------------------------------------- */
.gate {
  width: min(100% - 2rem, 27rem);
  margin: clamp(2.5rem, 10vh, 7rem) auto 2rem;
}
.gate-card {
  padding: clamp(1.5rem, 5vw, 2.25rem);
  border-radius: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--outline);
  box-shadow: var(--shadow-lg);
}
.gate-mark { width: 3.25rem; height: 3.25rem; border-radius: 1rem; margin-bottom: 1.1rem; }
.gate-mark .icon { width: 1.75rem; height: 1.75rem; }
.gate h1 { font-size: clamp(1.6rem, 6vw, 2.1rem); margin-bottom: .5rem; }
.gate-text { margin-bottom: 1.1rem; }
.gate button { margin-top: 1rem; }
.gate-actions { display: grid; gap: .1rem; }
.gate-actions .button-quiet { margin-top: .25rem; }
.gate-loading { display: flex; align-items: center; gap: .65rem; color: var(--muted); }
.form-field + .form-field { margin-top: .9rem; }
.field-hint { font-size: .85rem; margin-top: .3rem; }

.gate label,
.editor-field label {
  display: block;
  margin-bottom: .35rem;
  font-size: .92rem;
  font-weight: 650;
}
.label-hint { color: var(--muted); font-weight: 500; }

input[type="password"],
input[type="date"],
input[type="text"],
textarea {
  display: block;
  width: 100%;
  min-height: 3rem;
  padding: .65rem .85rem;
  border: 1.5px solid var(--outline-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
input[type="date"] { -webkit-appearance: none; appearance: none; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
textarea { resize: vertical; line-height: 1.45; }

.form-error {
  margin-top: .75rem;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--late);
  background: var(--late-wash);
  font-size: .92rem;
  font-weight: 550;
}
.form-error:empty { display: none; }
.form-progress {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .85rem;
  color: var(--muted);
  font-size: .92rem;
}

.spinner {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  border: 2.5px solid var(--outline-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* Dialogs ----------------------------------------------------------------- */
dialog {
  width: min(100% - 2rem, 32rem);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: clamp(1.25rem, 4vw, 1.75rem);
  border: 1px solid var(--outline);
  border-radius: 1.5rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
}
dialog[open] { animation: dialog-in .22s cubic-bezier(.2, .8, .2, 1); }
dialog::backdrop {
  background: #0b1026a3;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
dialog[open]::backdrop { animation: fade-in .2s ease-out; }
.dialog-header { margin-bottom: .25rem; }
dialog h2 { font-size: 1.4rem; font-weight: 750; letter-spacing: -.02em; }
.dialog-description { margin-top: .4rem; font-size: .95rem; }
.dialog-subject {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin-top: .3rem;
  color: oklch(var(--subject-ink-l) var(--subject-c) var(--hue, 250));
  font-weight: 700;
}
.dialog-subject::before {
  content: "";
  width: .65rem;
  height: .65rem;
  border-radius: .22rem;
  background: oklch(var(--subject-l) var(--subject-c) var(--hue, 250));
}
.dialog-subject:empty { display: none; }
.editor-current { margin-bottom: .6rem; font-size: .9rem; }
dialog .editor-field { margin-top: 1.1rem; }
.source-options { margin-top: .9rem; }
.source-options summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--accent-ink);
  font-size: .92rem;
  font-weight: 650;
  cursor: pointer;
}
.source-options summary::after { content: "›"; margin-left: .4rem; font-size: 1.2rem; transition: transform .2s; }
.source-options[open] summary::after { transform: rotate(90deg); }
.source-options .editor-field:first-of-type { margin-top: .3rem; }
.editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1.5rem;
}
.reset-button { margin-right: auto; }

/* Notices ----------------------------------------------------------------- */
.notices {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  display: grid;
  gap: .5rem;
  width: max-content;
  max-width: calc(100% - 2rem);
  transform: translateX(-50%);
  pointer-events: none;
}
.notice {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 3rem;
  padding: .55rem .6rem .55rem 1.1rem;
  border-radius: 99rem;
  color: #fff;
  background: #1b2238;
  box-shadow: 0 12px 32px -8px #0b102680;
  font-weight: 600;
  pointer-events: auto;
  animation: toast-in .25s cubic-bezier(.2, .8, .2, 1);
}
.notice-text { padding-right: .5rem; }
.notice-error { padding-right: 1.1rem; border-radius: 1.1rem; background: #b3223f; }
.notice-action {
  min-height: 2.25rem;
  padding: .3rem .9rem;
  border: 0;
  border-radius: 99rem;
  color: #c8d1ff;
  background: #ffffff1a;
  font-weight: 700;
  cursor: pointer;
}

/* Hover only where a real pointer can hover (no sticky hover on tablets). */
@media (hover: hover) {
  .icon-button:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
  .sync-pill:hover { color: var(--ink); border-color: var(--outline-strong); }
  .button-primary:hover:not(:disabled) { background: var(--accent-strong); }
  .button-secondary:hover:not(:disabled) { background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 35%, var(--outline-strong)); }
  .button-quiet:hover:not(:disabled) { background: var(--accent-wash); }
  .button-danger:hover:not(:disabled) { background: #a8213f; }
  .button-attention:hover:not(:disabled) { background: color-mix(in srgb, var(--accent-wash) 80%, var(--accent)); }
  .chip:hover:not([aria-pressed="true"]) { border-color: var(--accent); color: var(--accent-ink); }
  .stat:hover { border-color: var(--outline-strong); }
  .task-card:hover { box-shadow: var(--shadow-md); }
  .done-control:hover { background: var(--ok-wash); }
  .done-control:hover .done-box { border-color: var(--ok); color: color-mix(in srgb, var(--ok) 45%, transparent); }
  input:hover:not(:focus), textarea:hover:not(:focus) { border-color: color-mix(in srgb, var(--accent) 40%, var(--outline-strong)); }
  .button-quiet-danger:hover:not(:disabled) { background: var(--late-wash); }
  .segmented label:hover:not(:has(input:checked)) { color: var(--ink); }
  .notice-action:hover { background: #ffffff2e; color: #fff; }
}

/* Animations -------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0% { transform: scale(1); opacity: .6; }
  80%, 100% { transform: scale(2.8); opacity: 0; }
}
@keyframes pop {
  0% { transform: scale(.7); }
  100% { transform: scale(1); }
}
@keyframes arrive {
  0% { transform: translateY(8px); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  60% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 15%, transparent); }
  100% { transform: none; }
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
}
@keyframes sheet-in {
  from { transform: translateY(100%); }
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Responsive -------------------------------------------------------------- */
@media (max-width: 60rem) {
  .dashboard-columns { grid-template-columns: minmax(0, 1fr); }
  .side-column { position: static; }
  .schedule-jump { display: inline-grid; }
}

@media (min-width: 44.01rem) and (max-width: 60rem) {
  .side-column { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

@media (max-width: 44rem) {
  .topbar-inner,
  .dashboard,
  .settings { width: calc(100% - 2rem); }
  /* The settings page offers sign-out, which keeps the phone topbar at four icons. */
  .topbar-logout { display: none; }
  .brand-suffix { display: none; }
  .sync-pill { display: none; }
  /* Rarely used: a quiet icon button beside the title instead of a FAB. */
  .page-heading { align-items: flex-start; }
  .add-task {
    width: var(--tap);
    min-height: var(--tap);
    padding: 0;
    color: var(--accent-ink);
    background: var(--surface);
    border-color: var(--outline-strong);
    box-shadow: none;
  }
  .add-task span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  @media (hover: hover) {
    .add-task:hover:not(:disabled) { background: var(--accent-wash); }
  }
  .summary { gap: .75rem; }
  .progress { max-width: none; }
  .stat-list { flex-basis: 100%; gap: .4rem; }
  /* Inline text instead of flex: count and label share one baseline and the
     fixed line height keeps them vertically centred in the pill. */
  .stat {
    display: block;
    min-width: 0;
    min-height: 0;
    padding: .5rem 1rem;
    border-radius: 99rem;
    white-space: nowrap;
  }
  .stat-count,
  .stat-label { line-height: 1.5rem; vertical-align: baseline; }
  .stat-count { margin-right: .3rem; font-size: 1.1rem; }
  .stat-label { font-size: .85rem; }

  dialog {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 2.5rem);
    margin: auto 0 0;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
    border-radius: 1.5rem 1.5rem 0 0;
    border-bottom: 0;
  }
  dialog[open] { animation: sheet-in .28s cubic-bezier(.2, .8, .2, 1); }
  dialog::before {
    content: "";
    display: block;
    width: 2.5rem;
    height: .3rem;
    margin: -.5rem auto .9rem;
    border-radius: 99rem;
    background: var(--outline-strong);
  }
  .editor-actions .button { flex: 1 1 8rem; }
  .reset-button { flex-basis: 100% !important; order: 3; margin-right: 0; }
}

@media (max-width: 30rem) {
  .task-due-text { display: grid; }
  .due-source::before { content: none; }
  .task-body { padding: .9rem 1rem .6rem 1.2rem; }
  .task-featured .task-body { padding: 1.1rem 1.1rem .75rem 1.35rem; }
  .task-featured .task-subject { font-size: 1.3rem; }
  .task-actions { padding: .4rem .5rem .5rem .8rem; }
  .task-featured .task-actions { padding-left: .95rem; }
  .task-buttons .button { padding-inline: .6rem; }
  .task-heading { flex-wrap: wrap; }
  .side-card { padding: 1rem; }
}

@media (max-width: 23rem) {
  .task-actions { flex-direction: column; align-items: stretch; }
  .task-buttons { justify-content: flex-start; }
}
