/* ════════════════════════════════════════════════════════════════════
   JobMate — design tokens & layout.
   One layout system: body[data-layout="mobile"|"desktop"] is always set
   explicitly by JS (auto-resolved from viewport unless the user forces
   it), so CSS never guesses. body[data-mode="simple"|"advanced"] gates
   visibility only — never behaviour.
   ════════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #f5f4f1;
  --surface:   #ffffff;
  --surface-2: #fafaf8;
  --ink:       #141414;
  --muted:     #6b7280;
  --faint:     #9ca3af;
  --border:    #e5e4e0;
  --border-2:  #d8d7d2;

  /* Pack accent — overwritten from the active trade pack at boot */
  --accent:        #4a6b5d;
  --accent-soft:   #e9f0ec;
  --accent-ink:    #ffffff;

  /* Status colour pairs (bg / ink) */
  --st-neutral-bg:#f3f4f6; --st-neutral-ink:#57606a;
  --st-blue-bg:  #dbeafe;  --st-blue-ink:  #1d4ed8;
  --st-lilac-bg: #ede9fe;  --st-lilac-ink: #6d28d9;
  --st-amber-bg: #fef3c7;  --st-amber-ink: #b45309;
  --st-orange-bg:#ffedd5;  --st-orange-ink:#c2410c;
  --st-green-bg: #dcfce7;  --st-green-ink: #15803d;
  --st-mint-bg:  #d1fae5;  --st-mint-ink:  #065f46;
  --st-red-bg:   #fee2e2;  --st-red-ink:   #b91c1c;
  --st-gray-bg:  #f3f4f6;  --st-gray-ink:  #6b7280;

  --warn-bg: #fffbeb; --warn-border:#f59e0b; --warn-ink:#92400e;

  /* Type scale */
  --fs-2xs: 0.64rem;
  --fs-xs:  0.72rem;
  --fs-sm:  0.79rem;
  --fs-md:  0.86rem;
  --fs-lg:  0.95rem;
  --fs-xl:  1.05rem;
  --fs-2xl: 1.25rem;

  /* Spacing */
  --sp-1: 4px;  --sp-2: 6px;  --sp-3: 8px;  --sp-4: 10px;
  --sp-5: 12px; --sp-6: 14px; --sp-7: 16px; --sp-8: 20px; --sp-9: 28px;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20,20,20,.05), 0 4px 16px rgba(20,20,20,.06);
  --shadow-lift: 0 6px 28px rgba(20,20,20,.16);

  --dur-fast: .13s;
  --dur: .2s;

  --tab-bar-h: 58px;
  --top-bar-h: 52px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
h1,h2,h3,h4 { margin: 0; font-weight: 600; }

/* ── Mode gating: purely visibility ── */
body[data-mode="simple"] .adv-only { display: none !important; }

/* ════════════ Frame ════════════ */
#app { min-height: 100dvh; display: flex; }
#frame { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }

#top-bar {
  position: sticky; top: 0; z-index: 40;
  height: var(--top-bar-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-5); padding: 0 var(--sp-7);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-title-wrap { display: flex; align-items: center; gap: var(--sp-4); min-width: 0; }
.top-pack-emoji { font-size: 1.15rem; }
.top-title { font-size: var(--fs-xl); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: var(--sp-3); }
.mode-chip {
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .12em;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 5px; padding: 2px 6px;
}
.icon-btn {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: border-color var(--dur-fast);
}
.icon-btn:hover { border-color: var(--border-2); }

#view {
  flex: 1; width: 100%;
  padding: var(--sp-7) var(--sp-7) calc(var(--tab-bar-h) + var(--sp-9));
  outline: none;
}

/* ════════════ Mobile tab bar ════════════ */
#tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tab-bar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.tab-btn {
  flex: 1; border: 0; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: var(--fs-2xs); font-weight: 500;
  position: relative; transition: color var(--dur-fast);
}
.tab-btn .tab-ico { font-size: 1.15rem; line-height: 1; }
.tab-btn[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tab-badge {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 16px; height: 16px; border-radius: 999px; padding: 0 4px;
  background: var(--st-red-ink); color: #fff;
  font-size: var(--fs-2xs); font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* ════════════ Desktop sidebar ════════════ */
#side-nav { display: none; }
body[data-layout="desktop"] #side-nav {
  display: flex; flex-direction: column;
  width: 218px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky; top: 0; height: 100dvh;
  padding: var(--sp-7) var(--sp-5);
}
body[data-layout="desktop"] #tab-bar { display: none; }
body[data-layout="desktop"] #view {
  max-width: 980px; margin: 0 auto;
  padding: var(--sp-8) var(--sp-9) var(--sp-9);
}
body[data-layout="mobile"] #view { max-width: 560px; margin: 0 auto; }

.side-brand { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-2) var(--sp-3) var(--sp-7); }
.side-brand-emoji { font-size: 1.4rem; }
.side-brand-name { font-weight: 650; letter-spacing: -0.01em; }
.side-brand-pack { font-size: var(--fs-xs); color: var(--muted); }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: var(--sp-4);
  border: 0; background: none; text-align: left;
  padding: var(--sp-4) var(--sp-4); border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: var(--fs-md);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.side-link:hover { background: var(--surface); color: var(--ink); }
.side-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-link .tab-badge { position: static; margin-left: auto; }
.side-foot { margin-top: auto; }
.side-foot-btn {
  width: 100%; text-align: left; border: 0; background: none;
  padding: var(--sp-4); border-radius: var(--radius-sm);
  color: var(--muted); font-size: var(--fs-md);
}
.side-foot-btn:hover { background: var(--surface); color: var(--ink); }

/* ════════════ Shared components ════════════ */
.section { margin-bottom: var(--sp-8); }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-5); margin-bottom: var(--sp-4);
}
.section-title { font-size: var(--fs-sm); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.section-hint { font-size: var(--fs-xs); color: var(--faint); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card.pad { padding: var(--sp-6) var(--sp-7); }

.row-list { display: flex; flex-direction: column; gap: var(--sp-4); }
.row {
  display: flex; align-items: flex-start; gap: var(--sp-5);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--sp-5) var(--sp-6);
  width: 100%; text-align: left; box-shadow: var(--shadow);
  transition: border-color var(--dur-fast), transform var(--dur-fast);
}
button.row:hover { border-color: var(--border-2); }
button.row:active { transform: scale(.995); }
.row-ico { font-size: 1.1rem; line-height: 1.5; flex-shrink: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: var(--fs-md); display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 1px; }
.row-side { flex-shrink: 0; text-align: right; font-size: var(--fs-xs); color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-2xs); font-weight: 600; line-height: 1;
  border-radius: 999px; padding: 4px 8px;
  background: var(--st-gray-bg); color: var(--st-gray-ink);
  white-space: nowrap;
}
.pill.st-blue  { background: var(--st-blue-bg);  color: var(--st-blue-ink); }
.pill.st-lilac { background: var(--st-lilac-bg); color: var(--st-lilac-ink); }
.pill.st-amber { background: var(--st-amber-bg); color: var(--st-amber-ink); }
.pill.st-orange{ background: var(--st-orange-bg);color: var(--st-orange-ink); }
.pill.st-green { background: var(--st-green-bg); color: var(--st-green-ink); }
.pill.st-mint  { background: var(--st-mint-bg);  color: var(--st-mint-ink); }
.pill.st-red   { background: var(--st-red-bg);   color: var(--st-red-ink); }
.pill.st-neutral{background: var(--st-neutral-bg);color: var(--st-neutral-ink); }

.chip-rail { display: flex; gap: var(--sp-3); overflow-x: auto; padding-bottom: var(--sp-2); scrollbar-width: none; }
.chip-rail::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 12px;
  font-size: var(--fs-sm); font-weight: 500; color: var(--muted);
  white-space: nowrap; transition: all var(--dur-fast);
}
.chip[aria-pressed="true"] {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

.empty {
  text-align: center; color: var(--muted);
  padding: var(--sp-9) var(--sp-7);
  border: 1.5px dashed var(--border-2); border-radius: var(--radius);
  background: var(--surface-2);
}
.empty .empty-emoji { font-size: 1.8rem; display: block; margin-bottom: var(--sp-3); }
.empty .empty-title { font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.empty .empty-sub { font-size: var(--fs-sm); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-3);
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); padding: 9px 14px;
  font-weight: 600; font-size: var(--fs-md);
  transition: all var(--dur-fast);
}
.btn:hover { border-color: var(--border-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--st-red-ink); border-color: color-mix(in srgb, var(--st-red-ink) 35%, var(--border)); }
.btn.small { padding: 6px 10px; font-size: var(--fs-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.field > label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.input, textarea.input, select.input {
  border: 1px solid var(--border-2); background: var(--surface);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: var(--fs-lg); width: 100%;
}
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 96px; line-height: 1.5; }

.input-wrap { position: relative; }
.mic-btn {
  position: absolute; right: 8px; bottom: 8px;
  width: 32px; height: 32px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .95rem; transition: all var(--dur-fast);
}
.mic-btn.listening {
  background: var(--st-red-bg); border-color: var(--st-red-ink); color: var(--st-red-ink);
  animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--st-red-ink) 15%, transparent); } }

.speak-btn.speaking {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
  animation: micPulse 1.4s ease-in-out infinite;
}

/* Segmented control */
.seg { display: inline-flex; background: var(--st-gray-bg); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg > button {
  border: 0; background: none; border-radius: 5px;
  padding: 6px 12px; font-size: var(--fs-sm); font-weight: 500; color: var(--muted);
  transition: all var(--dur-fast);
}
.seg > button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* Toggle switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6); padding: var(--sp-5) 0; }
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.switch-label { font-weight: 550; }
.switch-sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 1px; }
.switch {
  position: relative; width: 44px; height: 26px; border-radius: 999px;
  border: 0; background: var(--border-2); transition: background var(--dur);
  flex-shrink: 0;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 999px; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--dur);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* Warning callout (risky AI etc.) */
.callout-warn {
  background: var(--warn-bg); border: 1.5px dashed var(--warn-border);
  border-radius: var(--radius); padding: var(--sp-5) var(--sp-6);
  color: var(--warn-ink); font-size: var(--fs-sm);
}

/* ════════════ Sheet (modal) ════════════ */
#sheet-root:empty { display: none; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20,20,20,.42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn var(--dur) ease;
}
body[data-layout="desktop"] .sheet-backdrop { align-items: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px;
  max-height: 92dvh; overflow-y: auto;
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-lift);
  animation: sheetUp var(--dur) cubic-bezier(.2,.9,.3,1);
  padding: 0 var(--sp-7) var(--sp-9);
}
body[data-layout="desktop"] .sheet { border-radius: 16px; max-width: 640px; max-height: 86dvh; }
.sheet-grip { position: sticky; top: 0; background: var(--bg); padding: var(--sp-4) 0 var(--sp-2); z-index: 2; }
.sheet-grip::before {
  content: ''; display: block; width: 40px; height: 4px; border-radius: 4px;
  background: var(--border-2); margin: 0 auto;
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-5); padding: var(--sp-4) 0 var(--sp-6); }
.sheet-title { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.01em; display:flex; align-items:center; gap: var(--sp-3); }
.sheet-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.sheet-close {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; width: 30px; height: 30px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: .85rem;
}
@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(28px); opacity: .6; } }

/* ════════════ Toast ════════════ */
#toast-root {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-bar-h) + var(--sp-7)); z-index: 90;
  display: flex; flex-direction: column; gap: var(--sp-3); align-items: center;
  pointer-events: none;
}
body[data-layout="desktop"] #toast-root { bottom: var(--sp-8); }
.toast {
  background: var(--ink); color: #fff;
  border-radius: 999px; padding: 9px 16px;
  font-size: var(--fs-sm); font-weight: 500;
  box-shadow: var(--shadow-lift);
  animation: toastIn var(--dur) ease;
  max-width: min(92vw, 440px); text-align: center;
}
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* ════════════ View-specific ════════════ */
/* Today */
.today-hero { margin-bottom: var(--sp-7); }
.today-date { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.015em; }
.today-meta { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }
.holiday-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--st-amber-bg); color: var(--st-amber-ink);
  border-radius: 999px; padding: 4px 10px; font-size: var(--fs-xs); font-weight: 600;
}

/* Jobs board (desktop) */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 252px; gap: var(--sp-5); overflow-x: auto; padding-bottom: var(--sp-5); align-items: start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-4); }
.board-col-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-2) var(--sp-3) var(--sp-4); font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.board-col .row { box-shadow: none; margin-bottom: var(--sp-3); flex-direction: column; gap: var(--sp-3); }
.board-col .row .row-ico { display: none; }
.board-col .row .row-side { flex-direction: row; flex-wrap: wrap; align-items: center; text-align: left; }

/* Provenance badges */
.prov {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--fs-2xs); font-weight: 600;
  border-radius: 4px; padding: 2px 5px; vertical-align: 1px;
}
.prov.verbatim { background: var(--st-gray-bg); color: var(--st-gray-ink); }
.prov.inferred { background: var(--st-lilac-bg); color: var(--st-lilac-ink); }
.prov.user     { background: var(--st-blue-bg); color: var(--st-blue-ink); }
.verbatim-quote {
  font-style: italic; color: var(--muted);
  border-left: 3px solid var(--border-2); padding-left: var(--sp-4);
  margin: var(--sp-3) 0; font-size: var(--fs-sm);
}

/* Notes */
.note-item { display: flex; gap: var(--sp-4); padding: var(--sp-4) 0; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.note-item:first-child { border-top: 0; }
.note-emoji { flex-shrink: 0; }
.note-scope { font-size: var(--fs-2xs); color: var(--faint); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; margin-left: var(--sp-2); }

/* Map */
#map-canvas { height: 46dvh; min-height: 300px; border-radius: var(--radius); border: 1px solid var(--border); z-index: 1; }
body[data-layout="desktop"] #map-canvas { height: 54dvh; }
.dist-row { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4) 0; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.dist-row:first-child { border-top: 0; }
.dist-km { margin-left: auto; font-weight: 600; white-space: nowrap; }
.map-pin-dot { border-radius: 999px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }

/* Debug admin */
.debug-table-wrap { overflow-x: auto; }
.debug-table { border-collapse: collapse; width: 100%; font-size: var(--fs-xs); }
.debug-table th, .debug-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.debug-table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.debug-table td.inherit { color: var(--faint); }
.debug-table td.override { background: var(--accent-soft); font-weight: 550; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: var(--fs-xs); }
.event-line { padding: var(--sp-3) 0; border-top: 1px solid var(--border); font-size: var(--fs-xs); display: flex; gap: var(--sp-4); }
.event-line:first-child { border-top: 0; }
.event-time { color: var(--faint); white-space: nowrap; }

/* Settings */
.settings-group { margin-bottom: var(--sp-8); }
.pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-4); }
.pack-card {
  border: 1.5px solid var(--border); background: var(--surface);
  border-radius: var(--radius); padding: var(--sp-6);
  text-align: left; transition: all var(--dur-fast);
}
.pack-card:hover { border-color: var(--border-2); }
.pack-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.pack-card .pack-emoji { font-size: 1.5rem; display: block; margin-bottom: var(--sp-2); }
.pack-card .pack-name { font-weight: 600; font-size: var(--fs-md); }
.pack-card .pack-sub { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }

.place-row { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4) 0; border-top: 1px solid var(--border); }
.place-row:first-child { border-top: 0; }
.star-btn { border: 0; background: none; font-size: 1.05rem; padding: 2px; opacity: .35; }
.star-btn[aria-pressed="true"] { opacity: 1; }

/* Utility */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.stack-2 { display: flex; flex-direction: column; gap: var(--sp-2); }
.hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-4); }

/* Inline text-button link (used inside callouts). */
.linklike {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline;
}

/* ── AI load: prefilled spec on the left, the original kept alongside on
      the right (word-for-word). Stacks under a phone-width layout. ── */
.proposal-2pane { display: grid; grid-template-columns: 1fr; gap: var(--sp-6); margin-top: var(--sp-2); }
body[data-layout="desktop"] .proposal-2pane { grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); align-items: start; }
.pane-spec { min-width: 0; }
.pane-original {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--sp-5);
}
body[data-layout="desktop"] .pane-original { position: sticky; top: var(--sp-4); }
.pane-original .original-box {
  width: 100%; min-height: 140px; margin: 0; font-size: var(--fs-sm);
  background: var(--surface); color: var(--ink); line-height: 1.55;
}
.pane-original .original-box[readonly] { cursor: default; }

/* ── Invoice builder ── */
.inv-line { display: flex; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-3); }
.inv-line .input { margin: 0; }
.inv-line-head { display: flex; gap: var(--sp-3); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: var(--sp-2); }
.inv-totals { margin-top: var(--sp-5); border-top: 1px solid var(--border); padding-top: var(--sp-4); }
.inv-total-row { display: flex; justify-content: space-between; gap: var(--sp-5); padding: 3px 0; font-size: var(--fs-md); }

/* ════════ Density + grouping (v2.1) ════════ */
.section { margin-bottom: var(--sp-7); }               /* was sp-8 — tighter */
.row-sub { display: flex; align-items: center; gap: var(--sp-2); }

/* Colour-coded initial chip: ties a client's jobs together, sets clients apart. */
.client-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 19px; height: 19px; border-radius: 50%; flex-shrink: 0;
  font-size: 0.6rem; font-weight: 700; letter-spacing: -0.02em;
  background: hsl(var(--av-h, 220) 58% 90%); color: hsl(var(--av-h, 220) 42% 32%);
}

/* ── Proposal card: grouped, compact, provenance-tinted ── */
.proposal-card { gap: var(--sp-3); padding: var(--sp-5) var(--sp-6); }
.proposal-head { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

.spec-body { position: relative; display: flex; flex-direction: column; gap: var(--sp-4); margin-top: var(--sp-2); }
.spec-group {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: var(--sp-4) var(--sp-5) var(--sp-5);
}
.spec-group-head {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin-bottom: var(--sp-3);
}
.spec-group > * + * { margin-top: var(--sp-3); }

.field { min-width: 0; }
.field-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: 3px; }
.field-label { font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.grid-addr { display: grid; grid-template-columns: 2fr 1fr; gap: var(--sp-4); }
.spec-actions { display: flex; justify-content: flex-end; gap: var(--sp-3); margin-top: var(--sp-4); }

/* Compact inputs inside the card. */
.spec-body .input, .spec-body select.input { padding: 7px 10px; }
.spec-body textarea.input { min-height: 38px; }

/* Provenance tint: AI-extracted cells lilac, verbatim cells grey. */
.field.is-ai .input, .field.is-ai select.input { background: color-mix(in srgb, var(--st-lilac-bg) 42%, var(--surface)); border-color: color-mix(in srgb, var(--st-lilac-ink) 22%, var(--border-2)); }
.field.is-verbatim .input { background: color-mix(in srgb, var(--st-gray-bg) 60%, var(--surface)); }

/* Loading: grey the cells + a pulsing badge while AI is still reading. */
.spec-loading { pointer-events: none; }
.spec-loading > .spec-group { opacity: .5; }
.spec-loading .input, .spec-loading select.input { background: var(--st-gray-bg); color: var(--muted); }
.spec-loading-badge {
  position: absolute; top: -9px; right: 0; pointer-events: none;
  font-size: var(--fs-2xs); font-weight: 600; color: var(--st-lilac-ink);
  background: var(--st-lilac-bg); padding: 2px 8px; border-radius: 999px;
  animation: aiPulse 1.2s ease-in-out infinite;
}
@keyframes aiPulse { 50% { opacity: .5; } }

/* ── WYSIWYG time-of-day window picker (colour-coded AM/PM/evening) ── */
.win-picker { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.win-chip {
  flex: 1 1 0; min-width: 64px;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: var(--sp-3) var(--sp-2); cursor: pointer;
  border: 1.5px solid var(--border); border-top-width: 3px; border-radius: var(--radius-sm);
  background: var(--surface); transition: all var(--dur-fast);
}
.win-emoji { font-size: 1.05rem; }
.win-label { font-weight: 600; color: var(--ink); font-size: var(--fs-sm); }
.win-hint { font-size: var(--fs-2xs); color: var(--faint); }
.win-am  { border-top-color: var(--st-amber-ink); }
.win-pm  { border-top-color: var(--st-orange-ink); }
.win-eve { border-top-color: var(--st-lilac-ink); }
.win-all { border-top-color: var(--st-green-ink); }
.win-am[aria-pressed="true"]  { background: var(--st-amber-bg);  border-color: var(--st-amber-ink); }
.win-pm[aria-pressed="true"]  { background: var(--st-orange-bg); border-color: var(--st-orange-ink); }
.win-eve[aria-pressed="true"] { background: var(--st-lilac-bg);  border-color: var(--st-lilac-ink); }
.win-all[aria-pressed="true"] { background: var(--st-green-bg);  border-color: var(--st-green-ink); }
.win-chip[aria-pressed="true"] .win-hint { color: inherit; }

/* ── WYSIWYG urgency scale (calm → alarm) ── */
.urg-scale { display: flex; gap: 3px; }
.urg-seg {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: var(--sp-3) 2px; cursor: pointer; color: var(--muted);
  border: 1.5px solid var(--border); border-bottom-width: 3px; border-radius: var(--radius-sm);
  background: var(--surface); transition: all var(--dur-fast);
}
.urg-emoji { font-size: 1rem; }
.urg-lbl { font-size: var(--fs-2xs); font-weight: 600; }
.urg-whenever  { border-bottom-color: var(--st-neutral-ink); }
.urg-soon      { border-bottom-color: var(--st-blue-ink); }
.urg-urgent    { border-bottom-color: var(--st-amber-ink); }
.urg-emergency { border-bottom-color: var(--st-red-ink); }
.urg-whenever[aria-pressed="true"]  { background: var(--st-neutral-bg); border-color: var(--st-neutral-ink); color: var(--st-neutral-ink); }
.urg-soon[aria-pressed="true"]      { background: var(--st-blue-bg);   border-color: var(--st-blue-ink);   color: var(--st-blue-ink); }
.urg-urgent[aria-pressed="true"]    { background: var(--st-amber-bg);  border-color: var(--st-amber-ink);  color: var(--st-amber-ink); }
.urg-emergency[aria-pressed="true"] { background: var(--st-red-bg);    border-color: var(--st-red-ink);    color: var(--st-red-ink); }

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