/* ==========================================================================
   Agency Console — design tokens + layout + components.

   Identity: a field-ops console, not a SaaS marketing site. Monospace for
   structure (headings, nav, labels, badges, anything numeric/status-like);
   a plain system sans for prose (chat, descriptions) so long text stays
   easy to read. Warm paper/graphite palette instead of white/purple — built
   to be legible with the phone brightness turned up outdoors. See
   README.md's "Design identity" section for the reasoning.

   Every color and spacing value used anywhere below comes from the token
   block. If a view needs a new one, it gets added here first.
   ========================================================================== */

/* ---------------------------------------------------------------- Tokens */

:root {
  /* Spacing ramp — 4px base unit. Nothing outside this list. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Type: one display family (mono, for structure) + one text family (for prose). */
  --font-display: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --font-text: system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif;

  /* Type scale, ~1.25 ratio, floor of 16px for anything that is body prose. */
  --text-xs: 0.8125rem;   /* 13px — badges, timestamps, meta only, never prose */
  --text-sm: 0.875rem;    /* 14px — secondary labels only, never prose */
  --text-base: 1rem;      /* 16px — body floor */
  --text-md: 1.125rem;    /* 18px */
  --text-lg: 1.375rem;    /* 22px */
  --text-xl: 1.75rem;     /* 28px */
  --text-2xl: 2.1875rem;  /* 35px */

  --leading-body: 1.5;
  --leading-heading: 1.15;

  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --border-width: 1px;
  --focus-width: 3px;

  /* Content widths, per design.md. */
  --max-prose: 72ch;
  --max-app: 1200px;

  /* ---- Light theme (default; also the "bright daylight" theme) ---- */
  --paper: #f4efe4;
  --surface: #fffdf7;
  --surface-sunken: #ece4d2;
  --ink: #1b1712;
  --ink-muted: #57503f;
  --border: #d9d0ba;
  --border-strong: #b8ac8e;

  --accent: #8a4b06;
  --accent-strong: #8a4b06;
  --on-accent: #fffdf7;
  --accent-soft: #f3e0c2;
  --on-accent-soft: #1b1712;

  --danger: #9c2b1f;
  --on-danger: #fffdf7;
  --danger-soft: #f6dcd8;
  --on-danger-soft: #1b1712;

  --success: #2f6b3c;
  --on-success: #fffdf7;
  --success-soft: #dfeee0;
  --on-success-soft: #1b1712;

  --neutral-soft: #e7e0cd;
  --on-neutral-soft: #1b1712;

  --focus-ring: #1663c7;
  --scrim: rgba(0, 0, 0, 0.4);

  --shadow-card: 0 1px 2px rgba(27, 23, 18, 0.08), 0 1px 1px rgba(27, 23, 18, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15120d;
    --surface: #1e1a13;
    --surface-sunken: #100e0a;
    --ink: #f1ead9;
    --ink-muted: #b9ae95;
    --border: #3a3327;
    --border-strong: #574d3a;

    --accent: #e3a53a;
    --accent-strong: #e3a53a;
    --on-accent: #1b1712;
    --accent-soft: #3a2c11;
    --on-accent-soft: #f1ead9;

    --danger: #ff8a72;
    --on-danger: #1b1712;
    --danger-soft: #3d1c16;
    --on-danger-soft: #f1ead9;

    --success: #7ed08e;
    --on-success: #10250f;
    --success-soft: #16311a;
    --on-success-soft: #f1ead9;

    --neutral-soft: #2a251b;
    --on-neutral-soft: #f1ead9;

    --focus-ring: #6cb1ff;
    --scrim: rgba(0, 0, 0, 0.6);

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

/* Explicit override wins in both directions regardless of OS preference. */
:root[data-theme="light"] {
  --paper: #f4efe4;
  --surface: #fffdf7;
  --surface-sunken: #ece4d2;
  --ink: #1b1712;
  --ink-muted: #57503f;
  --border: #d9d0ba;
  --border-strong: #b8ac8e;
  --accent: #8a4b06;
  --accent-strong: #8a4b06;
  --on-accent: #fffdf7;
  --accent-soft: #f3e0c2;
  --on-accent-soft: #1b1712;
  --danger: #9c2b1f;
  --on-danger: #fffdf7;
  --danger-soft: #f6dcd8;
  --on-danger-soft: #1b1712;
  --success: #2f6b3c;
  --on-success: #fffdf7;
  --success-soft: #dfeee0;
  --on-success-soft: #1b1712;
  --neutral-soft: #e7e0cd;
  --on-neutral-soft: #1b1712;
  --focus-ring: #1663c7;
  --scrim: rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 2px rgba(27, 23, 18, 0.08), 0 1px 1px rgba(27, 23, 18, 0.06);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #15120d;
  --surface: #1e1a13;
  --surface-sunken: #100e0a;
  --ink: #f1ead9;
  --ink-muted: #b9ae95;
  --border: #3a3327;
  --border-strong: #574d3a;
  --accent: #e3a53a;
  --accent-strong: #e3a53a;
  --on-accent: #1b1712;
  --accent-soft: #3a2c11;
  --on-accent-soft: #f1ead9;
  --danger: #ff8a72;
  --on-danger: #1b1712;
  --danger-soft: #3d1c16;
  --on-danger-soft: #f1ead9;
  --success: #7ed08e;
  --on-success: #10250f;
  --success-soft: #16311a;
  --on-success-soft: #f1ead9;
  --neutral-soft: #2a251b;
  --on-neutral-soft: #f1ead9;
  --focus-ring: #6cb1ff;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ Reset */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden; /* belt-and-braces; nothing here should ever need it */
}
img, svg { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: var(--leading-heading);
  margin: 0 0 var(--space-3);
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
p { margin: 0 0 var(--space-3); max-width: var(--max-prose); }
ul, ol { margin: 0; padding: 0; list-style: none; }
code { font-family: var(--font-display); font-size: 0.9em; }

/* Visible focus ring on every interactive element — never suppressed. */
:focus-visible {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -100px;
  background: var(--accent);
  color: var(--on-accent);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  z-index: 100;
  font-family: var(--font-display);
  transition: top 0.15s ease;
}
.skip-link:focus { top: var(--space-3); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- Layout */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border-bottom: var(--border-width) solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header__brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: -0.02em;
}
.user-chip { display: flex; gap: var(--space-2); align-items: baseline; font-size: var(--text-sm); }
.user-chip__name { font-weight: 600; }
.user-chip__role {
  font-family: var(--font-display);
  text-transform: uppercase;
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

.pause-banner {
  background: var(--danger-soft);
  color: var(--on-danger-soft);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-width) solid var(--border-strong);
}
.pause-banner p { margin: 0; max-width: none; }
.pause-banner a { color: inherit; text-decoration: underline; }

.app-shell {
  /* Rough header+banner offset so the desktop side-nav's background reaches
     the bottom of the viewport on short pages. Not a design token — a
     one-off viewport calculation, not a reusable spacing/color value. */
  display: flex;
  min-height: calc(100dvh - 130px);
}

.side-nav { display: none; }

main {
  flex: 1;
  min-width: 0;
  padding: var(--space-4);
  padding-bottom: calc(72px + var(--space-4)); /* clears the fixed bottom nav */
  max-width: var(--max-app);
  margin: 0 auto;
  width: 100%;
}
main:focus { outline: none; } /* programmatic focus for routing; ring not needed here */

.view-title { margin-bottom: var(--space-2); }
.view-intro { color: var(--ink-muted); }

/* Bottom nav — mobile default. Fixed, thumb-reachable, big targets. */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: var(--border-width) solid var(--border);
  padding: var(--space-1) env(safe-area-inset-left) calc(var(--space-1) + env(safe-area-inset-bottom)) env(safe-area-inset-right);
  z-index: 20;
}
.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 56px;
  padding: var(--space-1);
  background: none;
  border: 0;
  color: var(--ink-muted);
  text-decoration: none;
  font-size: var(--text-xs);
  font-family: var(--font-display);
  position: relative;
}
.bottom-nav__item.is-active { color: var(--accent); }
.nav-glyph { font-weight: 700; }
.badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 22px);
  background: var(--danger);
  color: var(--on-danger);
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  font-size: var(--text-xs);
  line-height: 20px;
  text-align: center;
  padding: 0 var(--space-1);
  font-family: var(--font-display);
}

/* More sheet (mobile overflow nav) */
.more-sheet__backdrop {
  position: fixed; inset: 0;
  background: var(--scrim);
}
.more-sheet__panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  z-index: 31;
  max-height: 80vh;
  overflow-y: auto;
}
.more-sheet__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.more-sheet__header h2 { margin: 0; }
.more-sheet__list { display: flex; flex-direction: column; gap: var(--space-2); }
.more-sheet__link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
  background: var(--surface-sunken);
  font-size: var(--text-md);
}
.more-sheet__link.is-active { color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------ Components */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: var(--border-width) solid transparent;
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-text);
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--block { width: 100%; }
/* Visually compact, but the tap target itself still clears 44px. */
.btn--small { min-height: 44px; padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }

.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--secondary { background: var(--surface-sunken); color: var(--ink); border-color: var(--border-strong); }
.btn--danger { background: var(--danger); color: var(--on-danger); }
.btn--ghost { background: transparent; color: var(--ink-muted); border-color: var(--border); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--on-neutral-soft);
  white-space: nowrap;
}
.pill--danger { background: var(--danger-soft); color: var(--on-danger-soft); }
.pill--success { background: var(--success-soft); color: var(--on-success-soft); }
.pill--warning { background: var(--accent-soft); color: var(--on-accent-soft); }
.pill--priority-urgent { background: var(--danger-soft); color: var(--on-danger-soft); }
.pill--priority-high { background: var(--accent-soft); color: var(--on-accent-soft); }

.toast-region {
  position: fixed;
  bottom: calc(72px + var(--space-3));
  left: var(--space-3);
  right: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 40;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: auto;
}
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--error { background: var(--danger); color: var(--on-danger); }
.toast--success { background: var(--success); color: var(--on-success); }
.toast__close { background: none; border: 0; color: inherit; font-size: var(--text-lg); min-width: 44px; min-height: 44px; cursor: pointer; }

.error-banner {
  background: var(--danger-soft);
  color: var(--on-danger-soft);
  border: var(--border-width) solid var(--danger);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}
.notice {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-4);
}
.notice--info { background: var(--surface-sunken); border: var(--border-width) solid var(--border); }
.notice__list { padding-left: var(--space-5); list-style: disc; margin: var(--space-2) 0; }
.notice__list li { margin-bottom: var(--space-1); }

.muted-note { color: var(--ink-muted); font-size: var(--text-sm); }
.empty-state { color: var(--ink-muted); padding: var(--space-4) 0; }

/* Auth overlay — replaces the whole app until Access sees a session. */
/* The hidden attribute must always win. Its UA default (display: none) is
   overridden by ANY authored display value, so `.auth-overlay { display: flex }`
   kept the overlay — an opaque, inset:0, z-index:50 sheet — permanently over a
   fully working dashboard. Every element this app toggles with `.hidden = true`
   needs this guard, so it is global and important on purpose. */
[hidden] { display: none !important; }

.auth-overlay {
  position: fixed; inset: 0;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 50;
}
.auth-overlay__panel {
  max-width: 420px;
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

/* Chat */
.chat-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: 55vh;
  overflow-y: auto;
  padding: var(--space-2);
  background: var(--surface-sunken);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
}
.chat-bubble { max-width: 85%; padding: var(--space-3); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.chat-bubble--me { align-self: flex-end; background: var(--accent-soft); color: var(--on-accent-soft); }
.chat-bubble--system { align-self: center; background: var(--danger-soft); color: var(--on-danger-soft); font-size: var(--text-sm); }
.chat-bubble__text { margin: 0 0 var(--space-1); white-space: pre-wrap; }
.chat-bubble__meta { font-family: var(--font-display); font-size: var(--text-xs); color: var(--ink-muted); }
.chat-composer { display: flex; gap: var(--space-2); align-items: flex-end; }
.chat-composer__input {
  flex: 1;
  min-height: 44px;
  max-height: 30vh;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--border-strong);
  background: var(--surface);
  resize: vertical;
}
.chat-composer__send { flex-shrink: 0; }

/* Needs-you queue */
.queue-list { display: flex; flex-direction: column; gap: var(--space-3); }
.queue-item {
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-left: var(--space-1) solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
}
.queue-item--job { border-left-color: var(--danger); }
.queue-item__title { margin-bottom: var(--space-1); }
.queue-item__desc { color: var(--ink-muted); margin-bottom: var(--space-2); }
.queue-item__meta { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; font-size: var(--text-xs); font-family: var(--font-display); color: var(--ink-muted); margin-bottom: var(--space-3); }
.queue-item__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.queue-list--compact .queue-item { padding: var(--space-3); }

.answer-form { display: flex; flex-direction: column; gap: var(--space-2); width: 100%; }
.answer-form__input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--border-strong);
  background: var(--surface);
}
.answer-form__buttons { display: flex; gap: var(--space-2); }

.confirm-inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  background: var(--danger-soft);
  color: var(--on-danger-soft);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  width: 100%;
}
.confirm-inline--stacked { flex-direction: column; align-items: stretch; }
.confirm-inline__msg { font-weight: 600; }

/* Board */
.board-strip {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-3);
  scroll-snap-type: x proximity;
  /* Contained scroll — the page itself never scrolls horizontally. */
}
.board-column {
  flex: 0 0 88%;
  max-width: 320px;
  scroll-snap-align: start;
  background: var(--surface-sunken);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}
.board-column__heading { display: flex; justify-content: space-between; align-items: center; font-size: var(--text-sm); }
.board-column__count { font-family: var(--font-display); color: var(--ink-muted); }
.board-column__cards { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-3); }
.empty-state--column { font-size: var(--text-sm); padding: var(--space-3) 0; }

.board-card {
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  box-shadow: var(--shadow-card);
}
.board-card__title { font-size: var(--text-base); font-family: var(--font-text); font-weight: 600; margin-bottom: var(--space-2); }
.board-card__meta { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-2); }
.card__client { font-size: var(--text-xs); font-family: var(--font-display); color: var(--ink-muted); }
.board-card__foot { display: flex; justify-content: space-between; font-size: var(--text-xs); font-family: var(--font-display); color: var(--ink-muted); margin-bottom: var(--space-2); }
.board-card__actions { margin-top: var(--space-2); }

/* Inbox */
.inbox-list { display: flex; flex-direction: column; gap: var(--space-3); }
.inbox-item { background: var(--surface); border: var(--border-width) solid var(--border); border-radius: var(--radius-md); padding: var(--space-3); }
.inbox-item__head { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-2); font-size: var(--text-xs); font-family: var(--font-display); color: var(--ink-muted); }
.inbox-item__from { font-weight: 600; color: var(--ink); }
.inbox-item__actions { margin-top: var(--space-2); }

/* Clients / Projects */
.record-list { display: flex; flex-direction: column; gap: var(--space-2); }
.record-list__link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  padding: var(--space-3);
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--ink);
}
.record-list__name { font-weight: 600; }
.record-detail { margin-bottom: var(--space-5); }
.record-detail__notes { color: var(--ink-muted); }
.external-link { margin-left: var(--space-3); font-size: var(--text-sm); }
.project-item { border: var(--border-width) solid var(--border); border-radius: var(--radius-md); padding: var(--space-3); margin-bottom: var(--space-3); background: var(--surface); }
.project-item__summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 600; min-height: 44px; }
.scope-editor { margin-top: var(--space-3); }
.scope-editor__input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--border-strong);
  background: var(--surface);
}
.scope-editor__row { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-2); }
.scope-editor__status { font-size: var(--text-sm); color: var(--ink-muted); }

/* Jobs */
.filter-row { display: flex; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.filter-select { min-height: 44px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: var(--border-width) solid var(--border-strong); background: var(--surface); }
.job-list { display: flex; flex-direction: column; gap: var(--space-3); }
.job-item { background: var(--surface); border: var(--border-width) solid var(--border); border-radius: var(--radius-md); padding: var(--space-3); }
.job-item--stale { border-color: var(--danger); }
.job-item__head { display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-2); flex-wrap: wrap; }
.job-item__role { font-family: var(--font-display); font-weight: 700; }
.job-item__task { margin-bottom: var(--space-2); }
.job-item__meta { display: flex; gap: var(--space-4); font-size: var(--text-xs); font-family: var(--font-display); color: var(--ink-muted); margin-bottom: var(--space-2); flex-wrap: wrap; }
.job-item__error { color: var(--danger); font-size: var(--text-sm); margin-top: var(--space-2); }

/* Settings */
.settings-block { margin-bottom: var(--space-6); padding-bottom: var(--space-5); border-bottom: var(--border-width) solid var(--border); }
.settings-row { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-3) 0; }
.settings-row__state { font-family: var(--font-display); }

.switch {
  /* The button itself is the tap target, so it must clear 44x44 even
     though a toggle track is visually thinner than that by convention. */
  width: 56px;
  height: 44px;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: var(--border-width) solid var(--border-strong);
  position: relative;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.switch__thumb {
  position: absolute;
  top: 50%;
  left: var(--space-1);
  transform: translateY(-50%);
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--ink-muted);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch.is-on { background: var(--accent-soft); border-color: var(--accent); }
.switch.is-on .switch__thumb { transform: translateY(-50%) translateX(var(--space-5)); background: var(--accent); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }

.confirm-type { background: var(--danger-soft); color: var(--on-danger-soft); padding: var(--space-4); border-radius: var(--radius-md); margin: var(--space-3) 0; }
.confirm-type__label { display: block; font-weight: 600; margin-bottom: var(--space-2); }
.confirm-type__input {
  width: 100%;
  max-width: 240px;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 2px solid var(--border-strong);
  background: var(--surface);
  font-family: var(--font-display);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}
.confirm-type__input[aria-invalid="true"] { border-color: var(--danger); }
.confirm-type__buttons { display: flex; gap: var(--space-2); }
.field-error { color: var(--danger); font-weight: 600; font-size: var(--text-sm); }

.table-scroll { overflow-x: auto; border: var(--border-width) solid var(--border); border-radius: var(--radius-md); }
.data-table { border-collapse: collapse; width: 100%; min-width: 520px; }
.data-table th, .data-table td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: var(--border-width) solid var(--border); }
.data-table th { font-family: var(--font-display); font-size: var(--text-sm); background: var(--surface-sunken); }

/* ------------------------------------------------------------ Breakpoints */

@media (min-width: 640px) {
  main { padding: var(--space-5); padding-bottom: calc(72px + var(--space-5)); }
  .board-column { flex-basis: 60%; }
}

@media (min-width: 768px) {
  .app-shell { min-height: calc(100dvh - 60px); }
  .side-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    width: 220px;
    flex-shrink: 0;
    padding: var(--space-5) var(--space-3);
    background: var(--surface);
    border-right: var(--border-width) solid var(--border);
  }
  .side-nav__link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--ink);
    text-decoration: none;
    font-size: var(--text-base);
  }
  .side-nav__link:hover { background: var(--surface-sunken); }
  .side-nav__link.is-active { background: var(--accent-soft); color: var(--on-accent-soft); font-weight: 600; }
  .bottom-nav, .more-sheet { display: none !important; }
  main { padding-bottom: var(--space-6); }
  .board-column { flex-basis: 320px; }
  .toast-region { bottom: var(--space-4); left: auto; right: var(--space-4); width: 360px; }
}

@media (min-width: 1024px) {
  main { padding: var(--space-6) var(--space-7); }
}

@media (min-width: 1280px) {
  /* Content is capped at --max-app (1200px) and centered, so the only thing
     left to do at the widest tier is give the side rail more breathing
     room instead of leaving it looking cramped next to a lot of empty page. */
  .side-nav { width: 260px; padding: var(--space-6) var(--space-4); }
}

/* ------------------------------------------------------- Reduced motion */

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