*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: var(--fs-md)/1.45 var(--font); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: var(--fs-sm); }
[hidden] { display: none !important; }

/* focus: always visible for keyboard users */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }

svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.s { width: 15px; height: 15px; }

/* buttons */
/* --surface-2 rather than --surface: a button has to stay visible on the recessed --bg panes AND on the
   raised --surface thread, and --surface would vanish into the second one. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); height: 32px; padding: 0 var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.btn:hover:not(:disabled) { background: var(--neutral-soft); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.icon { width: 36px; padding: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* form controls */
.field { display: grid; gap: var(--sp-1); }
.field > label, .field > .label { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); }
.field input, .field select, .field textarea, select.pill, .input {
  width: 100%; min-height: 34px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--bg); padding: 0 var(--sp-3);
}
.field textarea { padding: var(--sp-2) var(--sp-3); min-height: 76px; resize: vertical; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .input:focus-visible { border-color: var(--accent); }
select.pill { width: auto; height: 32px; background: var(--surface-2); }

/* chips and badges */
.chip { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: 11px; padding: 1px 7px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.chip.urgent { color: var(--danger); border-color: var(--danger); }
.chip.high { color: var(--warn); border-color: var(--warn); }
.chip.ok { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: var(--r-pill); padding: 0 6px; font-size: 11px; font-weight: 700; min-width: 18px; text-align: center; }

/* avatars */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: var(--fs-md); color: #fff; flex: none; }
.av-0 { background: var(--av-0); } .av-1 { background: var(--av-1); } .av-2 { background: var(--av-2); } .av-3 { background: var(--av-3); }
.av-4 { background: var(--av-4); } .av-5 { background: var(--av-5); } .av-6 { background: var(--av-6); } .av-7 { background: var(--av-7); }

/* loading / empty / error states, used by every view */
.state { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--muted); display: grid; gap: var(--sp-3); justify-items: center; }
.state.error { color: var(--danger); }
.state b { display: block; font-family: var(--serif); font-size: var(--fs-lg); font-weight: 600; color: var(--text); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* toasts */
.toast-host { position: fixed; left: 50%; bottom: var(--sp-5); transform: translateX(-50%); display: grid; gap: var(--sp-2); z-index: var(--z-toast); width: min(480px, calc(100vw - 2 * var(--sp-4))); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); box-shadow: var(--shadow); pointer-events: auto; cursor: pointer; }
.toast.error { background: var(--danger); color: var(--on-danger); }

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

/* The icon sprite in index.html defines <symbol>s only; it is never rendered directly. CSP forbids
   style="", so this is a class instead of an inline style. */
.icon-sprite { display: none; }
