/* The app. Quiet, like the UX plan page: thin ink rules, small mono labels, a colour bar per
   class, soft rounded controls, Neue Haas Grotesk throughout. Icons are inline SVG (ui.js's
   icon()), never text symbols, which NHG doesn't have.

   Layout: under 1000px, a phone: the list scrolls the page, tabs along the bottom, an item in a
   sheet over the list. From 1000px, a laptop: sidebar, list and item side by side, each column
   scrolling on its own. */

@font-face { font-family: "NHG Display"; src: url("/assets/fonts/NHaasGroteskDSPro-55Rg.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "NHG Display"; src: url("/assets/fonts/NHaasGroteskDSPro-65Md.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "NHG Display"; src: url("/assets/fonts/NHaasGroteskDSPro-75Bd.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "NHG Display"; src: url("/assets/fonts/NHaasGroteskDSPro-95Blk.woff2") format("woff2"); font-weight: 900; font-display: swap; }
@font-face { font-family: "NHG Text"; src: url("/assets/fonts/NHaasGroteskTXPro-55Rg.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "NHG Text"; src: url("/assets/fonts/NHaasGroteskTXPro-56It.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "NHG Text"; src: url("/assets/fonts/NHaasGroteskTXPro-65Md.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "NHG Text"; src: url("/assets/fonts/NHaasGroteskTXPro-75Bd.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --paper: #ffffff;
  --ink: #0d0d0f;
  --muted: #5b5e66;
  --line: #dcdde2;
  --soft: #f2f3f5;
  --ok: #1d7a3e;
  --warn: #a86400;
  --bad: #c42419;
  --accent: #da291c;
  --scrim: rgb(0 0 0 / 0.38);
  /* class colours, by /classes' `color` index */
  --k0: #2457c5; --k1: #c86f00; --k2: #2f8a52; --k3: #c0357c; --k4: #7546c2;
  --k5: #0f7f86; --k6: #8b6630; --k7: #69707d; --k8: #6f8019; --k9: #a8432a;
  --k-none: #9a9ca3;

  /* Not the installed "Neue Haas Grotesk" names: a locally installed copy can map arrows and
     check marks to its empty box, which stops the browser falling back for them. */
  --display: "NHG Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --text: "NHG Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --gutter: 16px;
  --tabs: 60px;
  --radius: 10px;
  --btn-radius: 8px;
  --rule: 1.5px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1012; --ink: #f1f1f3; --muted: #a3a6ae; --line: #2e3036; --soft: #1a1b1f;
    --ok: #4cc276; --warn: #f0a43a; --bad: #ff6a5e; --accent: #e8382b; --scrim: rgb(0 0 0 / 0.6);
    --k0: #6b96f2; --k1: #f29a2e; --k2: #4fb877; --k3: #e866a6; --k4: #a07ce8;
    --k5: #39b4bc; --k6: #c49b5f; --k7: #9aa1ad; --k8: #aec24a; --k9: #e0785c;
    --k-none: #6c6f77;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01" 0;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; } /* not red: that means late */
kbd { font: 500 12px/1.6 var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
code { font: 13px/1.5 var(--mono); }
small { font-size: 13px; }
.booting, .loading { padding: 32px var(--gutter); color: var(--muted); }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 14px;
  border: var(--rule) solid var(--ink); border-radius: var(--btn-radius);
  background: transparent; color: var(--ink);
  font: 500 15px/1.2 var(--text); text-decoration: none; text-align: center;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary, .btn-strong { background: var(--ink); color: var(--paper); }
.btn-quiet { border-color: transparent; color: var(--muted); }
.btn-wide { width: 100%; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btns-even { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.btns-even .btn { padding-inline: 6px; }
.btns-even .btn-strong { background: transparent; color: var(--ink); border-width: 2px; font-weight: 700; }
.btn[aria-expanded="true"] { background: var(--soft); }
.link-btn {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: 500 14px var(--text); text-decoration: underline; text-underline-offset: 3px;
}
.close, .tool {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; background: none; cursor: pointer; color: var(--muted);
}
.close { margin: -8px -10px 0 0; }
.close:hover, .tool:hover { color: var(--ink); }
.close .icon { width: 22px; height: 22px; }
.tool .icon { width: 20px; height: 20px; }
.tool.is-busy { color: var(--ink); cursor: default; }
.tool.is-busy .icon { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Icons (ui.js's icon()): 1em, so they size with the text beside them. A 2/24 stroke is about
   NHG Text's stem at 16px. */
.icon {
  width: 1em; height: 1em; flex: none; vertical-align: -0.14em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter;
}
.icon .fill { stroke: none; }
.field {
  display: block; width: 100%;
  padding: 10px 12px;
  border: var(--rule) solid var(--line); border-radius: 9px;
  background: var(--paper); color: var(--ink);
  font: 16px/1.4 var(--text); /* 16px: iOS zooms into smaller inputs */
}
.field:focus { border-color: var(--ink); outline: none; }
textarea.field { resize: vertical; }

.chip {
  display: inline-block;
  font: 600 10.5px/1.5 var(--mono); letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 3px; padding: 0 5px;
  color: var(--muted); white-space: nowrap;
}
.chip-ink { border-color: var(--ink); color: var(--ink); }
.chip-bad { border-color: var(--bad); color: var(--bad); }
.chip-fill { background: var(--soft); }
.src { font: 600 10px/1.5 var(--mono); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; color: var(--muted); }

/* ---------- frame: phone ---------- */

.shell { min-height: 100dvh; }
.side { display: none; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 0;
}
.brand { font: 900 19px/1 var(--display); letter-spacing: -0.02em; text-decoration: none; }
.list { display: block; padding: 0 var(--gutter) calc(var(--tabs) + 40px + env(safe-area-inset-bottom)); outline: none; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 4px env(safe-area-inset-bottom);
  background: var(--paper); border-top: 1px solid var(--line);
}
.tabs a {
  display: grid; justify-items: center; gap: 4px; padding: 4px 0 6px;
  font: 500 11.5px/1.2 var(--text); color: var(--muted); text-decoration: none;
}
.tabs .icon { width: 24px; height: 24px; stroke-width: 1.75; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tabs a[aria-current="page"] .icon .fill { fill: currentColor; }

.fresh {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px;
  border: 0; background: none; padding: 0; cursor: pointer;
  font: 500 12px/1.3 var(--mono); color: var(--muted); text-align: left;
}
.fresh-dot, .src-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.is-warn > .fresh-dot, .is-warn > .src-dot { background: var(--warn); }
.is-bad > .fresh-dot, .is-bad > .src-dot { background: var(--bad); }
.is-busy > .fresh-dot, .is-busy > .src-dot { background: var(--ink); animation: pulse 1.2s ease-in-out infinite; }
.is-off > .src-dot { background: var(--line); }
.fresh.is-bad { color: var(--bad); font-weight: 600; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* The item, as a sheet from the bottom. */
.scrim {
  position: fixed; inset: 0; z-index: 30; background: var(--scrim);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.detail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-height: calc(100dvh - 40px - env(safe-area-inset-top)); overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper);
  border-top: var(--rule) solid var(--ink); border-radius: 18px 18px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(105%); visibility: hidden;
  transition: transform 0.25s ease, visibility 0s 0.25s;
}
.shell.has-item .scrim { opacity: 1; pointer-events: auto; }
.shell.has-item .detail { transform: none; visibility: visible; transition: transform 0.25s ease; }
body:has(.shell.has-item) { overflow: hidden; }
.detail-empty { display: none; }

@media (min-width: 640px) {
  :root { --gutter: 28px; }
  .list > *, .topbar { max-width: 760px; margin-inline: auto; }
  .detail { max-width: 640px; margin-inline: auto; border-inline: var(--rule) solid var(--ink); }
}

/* ---------- frame: laptop ---------- */

@media (min-width: 1000px) {
  :root { --gutter: 40px; }
  .shell { display: grid; grid-template-columns: 236px minmax(0, 1fr) minmax(380px, 30vw); height: 100dvh; }
  .topbar, .tabs, .scrim { display: none; }
  body:has(.shell.has-item) { overflow: auto; }
  .side, .list, .detail { height: 100dvh; overflow-y: auto; }
  .side {
    display: flex; flex-direction: column; gap: 4px;
    padding: 24px 16px 16px 20px; border-right: 1px solid var(--line);
  }
  .side .brand { font-size: 22px; padding: 2px 8px 18px; }
  .side-nav { display: grid; gap: 2px; }
  .side-nav a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 7px; text-decoration: none; font: 500 15px/1.3 var(--text); color: var(--muted); }
  .side-nav .icon { width: 18px; height: 18px; stroke-width: 1.75; }
  .side-nav a[aria-current="page"] .icon .fill { fill: currentColor; }
  .side-nav a:hover { color: var(--ink); }
  .side-nav a[aria-current="page"] { color: var(--ink); background: var(--soft); font-weight: 700; }
  .side-label { font: 600 11px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 22px 8px 6px; }
  .side-classes { display: grid; gap: 1px; margin-bottom: auto; }
  .side-classes a { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 7px; text-decoration: none; font-size: 14px; }
  .side-classes a:hover { background: var(--soft); }
  .side-bar { width: 4px; height: 16px; border-radius: 2px; background: var(--c); flex: none; }
  .side .fresh { margin: 16px 8px 0; }
  .list { padding: 8px var(--gutter) 80px; }
  .list > * { max-width: 760px; margin-inline: 0; }
  .detail {
    position: static; max-height: none; transform: none; visibility: visible; transition: none;
    border: 0; border-left: 1px solid var(--line); border-radius: 0; max-width: none; margin: 0;
  }
  .detail-empty { display: grid; place-content: center; gap: 14px; height: 100%; padding: 32px; color: var(--muted); text-align: center; }
  .detail-empty .keys { font-size: 13px; line-height: 2.2; max-width: 30ch; }
}

/* ---------- Today ---------- */

.today-head { display: grid; gap: 4px; padding: 18px 0 6px; }
.today-kicker { font: 600 12px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.today-date { font: 700 clamp(30px, 6vw, 42px)/1.05 var(--display); letter-spacing: -0.02em; }
.next {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 14px;
  margin-top: 14px; padding: 12px 14px;
  border: var(--rule) solid var(--ink); border-radius: 12px; text-decoration: none;
}
.next > :not(.next-count) { grid-column: 1; }
.next-label { font: 600 11px/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.next-title { font: 500 17px/1.3 var(--text); overflow-wrap: anywhere; }
.next-sub { color: var(--muted); font-size: 14px; }
.next-count { grid-column: 2; grid-row: 1 / span 3; font: 700 30px/1 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.next-none { border-color: var(--line); }
a.next:hover { background: var(--soft); }

.day { display: block; margin-top: 26px; }
.day-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding-bottom: 6px; border-bottom: var(--rule) solid var(--ink);
  font: 600 12px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.day-today .day-head { color: var(--ink); }
.day-head.is-alert { color: var(--bad); border-color: var(--bad); }
.day-right { font: 500 13px var(--text); letter-spacing: 0; text-transform: none; color: var(--ink); }
.day-link { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.day-link:hover { text-decoration: underline; }
details.day > summary { list-style: none; cursor: pointer; }
details.day > summary::-webkit-details-marker { display: none; }
details[open].day .day-right { visibility: hidden; }
.empty { padding: 12px 0; color: var(--muted); border-bottom: 1px solid var(--line); }
.more > summary {
  list-style: none; cursor: pointer; padding: 10px 0 10px 16px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 500; color: var(--muted);
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: "+ "; }
.more[open] > summary::before { content: "− "; }
.more > summary:hover { color: var(--ink); }

.row-wrap { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.row {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 11px 0; background: var(--paper);
  cursor: pointer; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  transition: transform 0.18s ease;
}
.row-wrap.is-swiping .row { transition: none; }
.row:focus-visible { outline-offset: -2px; }
.row-bar { align-self: stretch; border-radius: 2px; background: var(--c); }
.row-main { display: grid; gap: 3px; min-width: 0; }
.row-title { font: 500 16px/1.3 var(--text); overflow-wrap: anywhere; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--muted); }
.row-class { color: var(--c); font-weight: 700; }
.row-when { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; padding-top: 1px; }
.row.is-late .row-when { color: var(--bad); }
.row.is-done .row-title { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--muted); font-weight: 400; }
.row.is-done .row-bar { opacity: 0.35; }
.row-done { display: inline-flex; align-items: center; gap: 4px; color: var(--ok); font-weight: 500; }
.row-btns { display: none; }
.row.is-open { background: var(--soft); }

/* Under a swiped row: what letting go will do. */
.under {
  position: absolute; inset: 0; display: none; align-items: center; gap: 6px; padding: 0 16px;
  font: 700 14px var(--text); color: var(--paper);
}
.under .icon { width: 18px; height: 18px; stroke-width: 2.25; }
.under-right { background: var(--ok); }
.under-left { background: var(--ink); justify-content: flex-end; }
.row-wrap[data-dir="right"] .under-right, .row-wrap[data-dir="left"] .under-left { display: flex; opacity: 0.55; }
.row-wrap.is-armed .under { opacity: 1; }

/* With a mouse, a row shows its buttons on hover. */
@media (hover: hover) and (pointer: fine) {
  .row { grid-template-columns: 4px minmax(0, 1fr) auto 64px; padding-right: 4px; }
  .row:hover { background: var(--soft); }
  .row-btns { display: flex; gap: 2px; justify-content: flex-end; visibility: hidden; }
  .row:hover .row-btns, .row:focus-within .row-btns, .row:focus .row-btns { visibility: visible; }
  .row-btn {
    display: grid; place-items: center; width: 30px; height: 28px;
    border: 1px solid var(--line); border-radius: 6px; background: var(--paper); cursor: pointer;
  }
  .row-btn .icon { width: 16px; height: 16px; }
  .row-btn:hover { border-color: var(--ink); }
}

/* ---------- pages ---------- */

.page { padding-top: 20px; display: grid; gap: 12px; }
.page-title { font: 700 clamp(30px, 6vw, 42px)/1.05 var(--display); letter-spacing: -0.02em; }
.page-note { color: var(--muted); max-width: 60ch; }
.page .day { margin-top: 14px; }
.class-card { display: grid; grid-template-columns: 4px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 16px; }
.class-name { font: 500 17px/1.3 var(--text); }
.class-teacher { color: var(--muted); font-size: 14px; }
.class-courses { display: grid; gap: 2px; margin-top: 6px; font-size: 14px; }
.class-courses b { font: 600 11px var(--mono); text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.more-links { display: grid; gap: 8px; }
.search { max-width: 480px; }

.signin { max-width: 380px; margin: 0 auto; padding: 18vh var(--gutter) 40px; display: grid; gap: 14px; }
.signin h1 { font: 700 34px/1.05 var(--display); letter-spacing: -0.02em; }
.signin p:not(.brand) { color: var(--muted); }

/* ---------- the item ---------- */

.item { display: grid; gap: 14px; padding: 14px var(--gutter) 32px; }
@media (min-width: 1000px) { .item { padding: 22px 28px 48px; } }
/* The head stays put while a long item scrolls, so × is always in reach. */
.item-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  position: sticky; top: 0; z-index: 2; background: var(--paper);
  margin: -14px calc(-1 * var(--gutter)) 0; padding: 14px var(--gutter) 6px;
}
@media (min-width: 1000px) { .item-head { margin: -22px -28px 0; padding: 22px 28px 6px; } }
.item-kicker { font: 500 12px/1.5 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding-top: 6px; }
.item-class { color: var(--c); font-weight: 700; }
.item-tools { display: flex; flex: none; margin: -8px -10px 0 0; }
.item-tools .close { margin: 0; }
.item-title { font: 700 26px/1.12 var(--display); letter-spacing: -0.015em; overflow-wrap: anywhere; }
.item-sync { margin-top: -6px; font-size: 14px; color: var(--muted); }
.item-sync:empty { display: none; }
.item > .btn-primary { min-height: 48px; font-size: 16px; }
.facts { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px 12px; margin: 0; padding-top: 12px; border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: 14px; padding-top: 1px; }
.facts dd { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.facts dd small { flex-basis: 100%; color: var(--muted); }
.facts dd .prose { flex-basis: 100%; }
.item-sec {
  font: 600 11px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  padding-top: 12px; border-top: 1px solid var(--line); margin-bottom: -6px;
}
.prose { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; }
.links { display: grid; gap: 6px; }
.links li { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; overflow-wrap: anywhere; }
.links small { color: var(--muted); white-space: nowrap; }
.comments { display: grid; gap: 12px; }
.comments li { display: grid; gap: 2px; font-size: 15px; }
.comments .is-private { padding-left: 10px; border-left: 2px solid var(--accent); }
.comment-head { font-size: 13px; color: var(--muted); }
.comment-head b { color: var(--ink); font-weight: 500; }
.changes { display: grid; gap: 8px; }
.changes li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 15px; }
.changes li > span { display: grid; }
.changes small { color: var(--muted); }
.command { padding-top: 14px; border-top: 1px solid var(--line); }

.panel { display: grid; gap: 10px; padding: 14px; border: var(--rule) solid var(--ink); border-radius: 12px; }
.panel-slot:empty { display: none; }
.panel-label { font: 600 11px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.date-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.date-chip {
  display: grid; justify-items: start; gap: 1px; padding: 8px 10px; cursor: pointer; text-align: left;
  border: var(--rule) solid var(--line); border-radius: var(--btn-radius); background: var(--paper);
}
.date-chip:hover { border-color: var(--ink); }
.date-chip b { font-weight: 500; }
.date-chip small { color: var(--muted); }
.move-preview { display: grid; gap: 2px; font-size: 15px; min-height: 1.4em; }
.move-preview small { color: var(--muted); }
.is-error { color: var(--bad); }
.pick summary { cursor: pointer; font-size: 14px; color: var(--muted); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.pick summary::-webkit-details-marker { display: none; }
.pick[open] summary .icon { transform: rotate(90deg); }
.pick .field { margin-top: 8px; }

/* ---------- toast ---------- */

.toast-host {
  position: fixed; z-index: 50; left: 50%; bottom: calc(var(--tabs) + 16px + env(safe-area-inset-bottom));
  width: min(440px, calc(100vw - 2 * var(--gutter)));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.toast-host.is-shown { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
@media (min-width: 1000px) { .toast-host { bottom: 24px; } }
.toast {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 12px;
  background: var(--ink); color: var(--paper); font-size: 15px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
}
.toast.is-error { background: var(--bad); color: #fff; }
.toast-text { display: grid; gap: 2px; }
.toast-text small { opacity: 0.75; }
.toast-act { border: 0; background: none; padding: 6px 2px; cursor: pointer; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; color: inherit; }

/* ---------- Sources sheet ---------- */

dialog.sheet {
  width: 100%; max-width: 100%; max-height: 90dvh; margin: auto 0 0;
  padding: 16px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  border: 0; border-top: var(--rule) solid var(--ink); border-radius: 18px 18px 0 0;
  background: var(--paper); color: var(--ink);
}
dialog.sheet[open] { display: grid; gap: 14px; }
dialog.sheet::backdrop { background: var(--scrim); }
@media (min-width: 640px) {
  dialog.sheet { width: 480px; margin: auto; border: var(--rule) solid var(--ink); border-radius: 14px; padding: 22px 26px; }
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { font: 700 26px/1.1 var(--display); letter-spacing: -0.015em; }
.fresh-line { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.fresh-line::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.fresh-line.is-bad { color: var(--bad); }
.fresh-line.is-warn::before { background: var(--warn); }
.fresh-line.is-bad::before { background: var(--bad); }
.fresh-line.is-busy::before { background: var(--ink); animation: pulse 1.2s infinite; }
.src-list { border-top: var(--rule) solid var(--ink); }
.src-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.src-row .src-dot { margin-top: 7px; }
.src-row .btn { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.src-main { display: grid; gap: 2px; min-width: 0; }
.src-name { font-weight: 500; }
.src-state { font-size: 14px; }
.src-row.is-bad .src-state { color: var(--bad); }
.src-next { font: 12px var(--mono); color: var(--muted); }
.src-fix { display: grid; gap: 6px; margin-top: 8px; font-size: 14px; justify-items: start; }
.src-fix code { display: block; width: 100%; padding: 8px 10px; background: var(--soft); border-radius: 6px; overflow-wrap: anywhere; }
.src-note { font-size: 14px; color: var(--muted); }
.sources .more-links { font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; animation: none !important; }
}
