/* ตารางงาน · กิจนิมนต์ — mobile-first, warm palette, light + dark, large text. */

/* Mitr by Cadson Demak, SIL Open Font License 1.1 (see /fonts/OFL.txt). Served from this site: no third-party
   requests, and the service worker keeps it for offline use. Split by script like Google Fonts, so a page only
   downloads the Thai and Latin files it actually uses. */
@font-face {
  font-family: "Mitr";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/mitr-400-thai.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Mitr";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/mitr-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Mitr";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/mitr-400-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Mitr";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/mitr-500-thai.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Mitr";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/mitr-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Mitr";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/mitr-500-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Mitr";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/mitr-600-thai.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: "Mitr";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/mitr-600-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Mitr";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/mitr-600-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light dark;
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f3ece2;
  --ink: #2a211b;
  --ink-2: #5c5047;
  --muted: #6f6258;
  --line: #eadfd1;
  /* Borders of form controls and filter chips: at least 3:1 against their background. */
  --field-line: #998877;
  --brand: #a64b08;
  --brand-ink: #ffffff;
  --brand-soft: #fdf0de;
  --nimon: #b93c0b;
  --nimon-soft: #fdebdd;
  --task: #0f766e;
  --task-soft: #dcf2ef;
  --danger: #b91c1c;
  --danger-ink: #ffffff;
  --danger-soft: #fde8e8;
  --warn: #b45309;
  --shadow: 0 1px 2px rgb(60 40 20 / 0.06), 0 4px 14px rgb(60 40 20 / 0.06);
  --shadow-lg: 0 12px 40px rgb(40 25 10 / 0.18);
  --radius: 16px;
  --font: "Mitr", system-ui, -apple-system, "Segoe UI", "Noto Sans Thai UI", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  --fs: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16120e;
    --surface: #211b16;
    --surface-2: #2a231d;
    --ink: #f3ece2;
    --ink-2: #d3c7ba;
    --muted: #a89a8b;
    --line: #372e26;
    --field-line: #7d6e61;
    --brand: #f59e0b;
    --brand-ink: #1c1206;
    --brand-soft: #3a2a14;
    --nimon: #fb923c;
    --nimon-soft: #3b2415;
    --task: #2dd4bf;
    --task-soft: #12302c;
    --danger: #f87171;
    --danger-ink: #1f0a0a;
    --danger-soft: #3b1c1c;
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 12px 40px rgb(0 0 0 / 0.55);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs) / 1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
/* Mitr is loaded in 400/500/600 and already reads heavy: headings top out at 600 (no synthesized bold). */
h1, h2, h3, strong, b { font-weight: 600; }
button { cursor: pointer; }
[hidden] { display: none !important; }
dialog:not([open]) { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.brand-mark { width: 42px; height: 42px; flex: none; }
.brand-text { min-width: 0; flex: 1; }
.brand-text h1 { margin: 0; font-size: 1.1em; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 360px) { .brand-text h1 { font-size: 1em; } }
.today-label { margin: 0; font-size: 0.82em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .icon { width: 24px; height: 24px; }
.push-toggle { flex: none; }
.push-toggle.is-on { color: var(--brand); }
.push-toggle.is-on .icon { fill: currentColor; }
.push-toggle[disabled] { opacity: 0.5; }

/* ------------------------------------------------------------------ page */
.page { max-width: 720px; margin: 0 auto; padding: 14px 16px calc(116px + var(--safe-bottom)); }

.offline {
  display: flex; align-items: center; gap: 10px; max-width: 688px; margin: 0 auto 10px; padding: 8px 14px;
  border-radius: 12px; background: var(--brand-soft); color: var(--ink); font-size: 0.85em;
}
@media (max-width: 720px) { .offline { margin-inline: 16px; } }
.offline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: none; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.seg { border: 0; background: transparent; padding: 7px 14px; border-radius: 10px; font-size: 0.9em; color: var(--ink-2); min-height: 44px; }
.seg[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow); }
.count { color: var(--muted); font-weight: 400; font-size: 0.85em; }
.chips { display: inline-flex; gap: 6px; }
.chip { border: 1px solid var(--field-line); background: var(--surface); border-radius: 99px; padding: 5px 14px; font-size: 0.88em; color: var(--ink-2); min-height: 44px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip-nimon[aria-pressed="true"] { background: var(--nimon); border-color: var(--nimon); color: #fff; }
.chip-task[aria-pressed="true"] { background: var(--task); border-color: var(--task); color: #fff; }
@media (prefers-color-scheme: dark) {
  .chip-nimon[aria-pressed="true"], .chip-task[aria-pressed="true"] { color: #10100f; }
}

/* ------------------------------------------------------------------ agenda */
.agenda { display: flex; flex-direction: column; gap: 6px; }
.day { display: flex; flex-direction: column; }
.day-body { display: flex; flex-direction: column; gap: 8px; }
.day-head {
  position: sticky; top: var(--topbar-h, 64px); z-index: 5;
  display: flex; align-items: baseline; gap: 8px; padding: 12px 2px 6px;
  background: linear-gradient(var(--bg) 75%, transparent);
}
.day-head h2 { margin: 0; font-size: 0.95em; font-weight: 500; }
.day-head .rel { font-size: 0.8em; color: var(--muted); }
.day-head.is-today h2 { color: var(--brand); }

.card {
  --kind: var(--nimon);
  --kind-soft: var(--nimon-soft);
  position: relative; display: grid; grid-template-columns: 4.4em 1fr; gap: 12px;
  background: var(--surface); border-radius: var(--radius); padding: 12px 14px 12px 12px;
  box-shadow: var(--shadow); border: 1px solid var(--line); cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s ease;
  overflow: hidden;
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--kind); }
.card.kind-task { --kind: var(--task); --kind-soft: var(--task-soft); }
.card:active { transform: scale(0.985); }
.card.is-done { background: var(--surface-2); box-shadow: none; }
.card.is-done :is(.card-title, .card-time strong) { color: var(--ink-2); }
.card.is-next { border-color: var(--kind); box-shadow: 0 0 0 1px var(--kind), var(--shadow); }
.card.is-flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { background: var(--kind-soft); box-shadow: 0 0 0 3px var(--kind); } 100% { background: var(--surface); } }

.card-time { display: flex; flex-direction: column; align-items: flex-start; padding-left: 4px; font-variant-numeric: tabular-nums; }
.card-time strong { font-size: 1.15em; font-weight: 500; line-height: 1.2; }
.card-time span { font-size: 0.76em; color: var(--muted); line-height: 1.4; }
.card-time .untimed { font-size: 0.78em; color: var(--muted); line-height: 1.35; padding-top: 2px; }
.card-body { min-width: 0; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 2px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72em; font-weight: 500; padding: 1px 8px; border-radius: 99px; background: var(--kind-soft, var(--nimon-soft)); color: var(--kind, var(--nimon)); line-height: 1.6; }
.tag.kind-task { --kind: var(--task); --kind-soft: var(--task-soft); }
.tag-next { background: var(--brand); color: var(--brand-ink); }
.card-title { margin: 0; font-size: 1em; font-weight: 500; line-height: 1.45; overflow-wrap: anywhere; }
.card-line { margin: 2px 0 0; display: flex; align-items: flex-start; gap: 5px; font-size: 0.86em; color: var(--ink-2); line-height: 1.45; overflow-wrap: anywhere; }
.card-line .icon { width: 1.05em; height: 1.05em; margin-top: 0.2em; color: var(--muted); }
.card-editing { margin: 6px 0 0; display: inline-flex; align-items: center; gap: 6px; font-size: 0.8em; color: var(--ink-2); background: var(--surface-2); border-radius: 99px; padding: 2px 12px 2px 8px; }
.card-editing .icon { width: 1em; height: 1em; }
.card-editing .dots::after { content: "…"; animation: blink 1.2s infinite; }

.skeleton { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
.skeleton i { display: block; height: 92px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .icon { width: 44px; height: 44px; stroke-width: 1.4; }
.empty p { margin: 8px 0 16px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 500; font-size: 0.95em; white-space: nowrap; transition: filter 0.12s, background 0.12s;
}
.btn .icon { width: 1.15em; height: 1.15em; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger); color: var(--danger-ink); }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.btn.is-busy { cursor: progress; }
.spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
.btn.is-busy .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.fab {
  position: fixed; right: max(16px, calc((100vw - 720px) / 2 + 16px)); bottom: calc(20px + var(--safe-bottom)); z-index: 30;
  display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 99px;
  padding: 0 22px 0 18px; height: 58px; background: var(--brand); color: var(--brand-ink);
  font-weight: 500; box-shadow: var(--shadow-lg); transition: transform 0.15s ease;
}
.fab .icon { width: 24px; height: 24px; stroke-width: 2.4; }
.fab:active { transform: scale(0.96); }

/* ------------------------------------------------------------------ sheets & dialogs */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgb(24 16 8 / 0.45); }

.sheet {
  width: 100%; max-width: 720px; max-height: min(94dvh, 100%);
  margin: auto auto 0; border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  padding-bottom: var(--safe-bottom);
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 0.24s cubic-bezier(0.2, 0.9, 0.25, 1); }
.sheet[open]::backdrop { animation: fade-in 0.24s ease; }
.sheet form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
@media (min-width: 760px) {
  .sheet { margin: auto; border-radius: 22px; max-height: 88dvh; padding-bottom: 0; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0.4; } }
@keyframes fade-in { from { opacity: 0; } }

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 10px 4px 20px; flex: none; }
.sheet-head-end { justify-content: flex-end; padding: 8px 8px 0; }
.sheet-head h2 { margin: 0; font-size: 1.15em; }
.sheet-scroll { overflow-y: auto; overscroll-behavior: contain; padding: 8px 20px 16px; flex: 1; min-height: 0; }
.sheet-actions { display: flex; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); flex: none; background: var(--surface); }
.sheet-actions .btn { flex: 1; }
.sheet-actions .btn-primary { flex: 1.4; }
/* Detail sheet: quiet text buttons instead of filled blocks. */
.sheet-actions-quiet { gap: 0; padding-block: 4px; }
.btn-quiet { position: relative; background: transparent; color: var(--ink-2); font-weight: 400; }
.btn-quiet:hover, .btn-quiet:active { background: var(--surface-2); }
.btn-quiet-danger { color: var(--danger); }
.btn-quiet + .btn-quiet::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1px; background: var(--line); }

.modal { width: min(420px, calc(100% - 32px)); border-radius: 20px; padding: 20px; box-shadow: var(--shadow-lg); }
.modal[open] { animation: pop-in 0.18s ease-out; }
@keyframes pop-in { from { transform: scale(0.96); opacity: 0; } }
.modal h2 { margin: 0 0 6px; font-size: 1.1em; }
.modal p { margin: 0 0 18px; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; }

/* detail */
.detail-kind { margin-top: 4px; }
.detail-title { margin: 6px 0 12px; font-size: 1.35em; line-height: 1.4; overflow-wrap: anywhere; }
.facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.fact { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.fact:last-child { border-bottom: 0; }
.fact > .icon { color: var(--muted); justify-self: center; }
.fact-main { min-width: 0; overflow-wrap: anywhere; }
.fact-main small { display: block; color: var(--muted); font-size: 0.76em; line-height: 1.3; }
.fact-note { white-space: pre-line; }
.fact-link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font-size: 0.82em; font-weight: 500; color: var(--brand); text-decoration: none; background: var(--brand-soft); padding: 6px 12px; border-radius: 99px; white-space: nowrap; }
.detail-meta { margin: 12px 0 0; font-size: 0.78em; color: var(--muted); }
.detail-gone { text-align: center; padding: 32px 0; color: var(--muted); }
.detail-gone .icon { width: 44px; height: 44px; stroke-width: 1.4; }

/* form */
.field { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.label { display: block; font-size: 0.85em; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; padding: 0; }
.label em { color: var(--danger); font-style: normal; }
.counter { font-size: 0.74em; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.is-near { color: var(--warn); }
.counter.is-full { color: var(--danger); font-weight: 500; }
.field-hint { margin: 4px 0 0; font-size: 0.8em; color: var(--muted); }
.field-hint:empty { display: none; }
.row { display: grid; gap: 0 12px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-2:has(> .field[hidden]) { grid-template-columns: 1fr; }
input[type="text"], input[type="tel"], input[type="date"], input[type="time"], input[type="number"], textarea {
  width: 100%; min-height: 50px; padding: 10px 12px; font-size: max(16px, 1em);
  background: var(--bg); border: 1.5px solid var(--field-line); border-radius: 12px; outline: none; appearance: none; -webkit-appearance: none;
}
input[type="date"], input[type="time"] { display: block; }
input::-webkit-date-and-time-value { text-align: left; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field.has-error input, .field.has-error textarea { border-color: var(--danger); }
.field.has-error .kind-toggle span { border-color: var(--danger); }
.field-error { margin: 4px 0 0; font-size: 0.8em; color: var(--danger); }
.field-error:empty { display: none; }

.kind-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kind-toggle label { position: relative; }
.kind-toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.kind-toggle span { display: grid; place-items: center; min-height: 50px; border-radius: 12px; border: 1.5px solid var(--field-line); background: var(--bg); font-weight: 500; color: var(--ink-2); }
.kind-toggle input:checked + span { border-color: var(--nimon); background: var(--nimon-soft); color: var(--nimon); }
.kind-toggle label:nth-child(2) input:checked + span { border-color: var(--task); background: var(--task-soft); color: var(--task); }
.kind-toggle input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 2px; }
.preset { border: 1px dashed var(--field-line); background: transparent; border-radius: 99px; padding: 4px 12px; font-size: 0.8em; color: var(--ink-2); min-height: 44px; }
.preset:hover { border-color: var(--brand); color: var(--brand); }

.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; margin-bottom: 12px; border-radius: 12px; background: var(--brand-soft); font-size: 0.88em; }
.notice p { margin: 0; flex: 1 1 200px; }
.notice .btn { min-height: 40px; padding: 0 12px; font-size: 0.85em; }
.notice-error { background: var(--danger-soft); color: var(--danger); }

.form-footnote { margin: 4px 0 0; font-size: 0.76em; line-height: 1.5; color: var(--muted); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* toasts */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(92px + var(--safe-bottom)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; width: fit-content;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 10px 10px 10px 16px; box-shadow: var(--shadow-lg);
  font-size: 0.9em; animation: toast-in 0.2s ease-out;
}
.toast.is-error { background: var(--danger); color: var(--danger-ink); }
.toast.is-leaving { animation: toast-out 0.18s ease-in forwards; }
.toast button { border: 0; background: transparent; color: inherit; font-weight: 500; padding: 6px 10px; border-radius: 8px; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; white-space: nowrap; }
.toast p { margin: 0; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(8px); opacity: 0; } }
dialog .toasts { bottom: 16px; }
/* Inside a bottom sheet, keep toasts clear of its action bar. */
.sheet .toasts { bottom: calc(88px + var(--safe-bottom)); }

.noscript { text-align: center; padding: 40px 16px; }
.boot-fail { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin: 12px 0; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--field-line); }
.boot-fail p { margin: 0; }

@media (max-width: 400px) {
  .card { grid-template-columns: 4em 1fr; gap: 10px; }
  .seg { padding: 7px 11px; }
  .chip { padding: 5px 11px; }
}
/* Only very narrow screens drop the add button's label. */
@media (max-width: 340px) {
  .fab span { display: none; }
  .fab { padding: 0; width: 58px; justify-content: center; }
}

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