/* ===================================================================
   AdvanceForm — "Soft & friendly / clay" theme
   Semantic tokens on :root (LIGHT) + [data-theme="dark"] overrides.
   Theme is controlled by <html data-theme="light|dark">.
   Persistence (JS, Phase 2): localStorage "af_theme"; else prefers-color-scheme.
   =================================================================== */

:root {
  /* ---- surfaces / text ---- */
  --bg:         #eef0f8;
  --surface:    #ffffff;
  --surface-2:  #f6f7fc;
  --text:       #232a3b;
  --muted:      #6b7488;
  --border:     #e3e7f2;

  /* ---- brand / accents (pastel violet clay family) ---- */
  --brand:      #5b21e0;
  --brand-dark: #4717b8;
  --brand-soft: #eef0ff;
  --brand-grad: linear-gradient(135deg, #7c3aed 0%, #5b21e0 50%, #4f46e5 100%);
  --accent:     #ec4899;
  --ok:         #16a34a;
  --danger:     #dc2626;

  /* ---- radii ---- */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  /* ---- clay elevation (light: highlight top-left + soft shadow bottom-right) ---- */
  --shadow-clay:
    -6px -6px 16px rgba(255, 255, 255, .9),
     8px  8px 22px rgba(83, 96, 150, .18);
  --shadow-clay-sm:
    -3px -3px 8px rgba(255, 255, 255, .85),
     4px  4px 12px rgba(83, 96, 150, .16);
  --shadow-lg:
    -8px -8px 22px rgba(255, 255, 255, .7),
     20px 26px 50px rgba(40, 32, 80, .26);

  /* ---- focus ring ---- */
  --ring: 0 0 0 3px rgba(91, 33, 224, .28);

  /* ---- motion ---- */
  --ease:        cubic-bezier(.2, .7, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --dur:         .18s;

  /* ---- legacy aliases (kept so nothing breaks; map to new tokens) ---- */
  --panel:     var(--surface);
  --ink:       var(--text);
  --line:      var(--border);
  --radius:    var(--radius-md);
  --shadow:    var(--shadow-clay-sm);
  --shadow-md: var(--shadow-clay);
}

/* ============ DARK: deep indigo-charcoal; clay re-expressed as
   elevated surfaces + subtle outer glow + hairline borders ============ */
[data-theme="dark"] {
  --bg:         #14151f;
  --surface:    #1d1f2e;
  --surface-2:  #262940;
  --text:       #e9ebf6;
  --muted:      #a2a8c2;
  --border:     #353a55;

  --brand:      #a78bfa;
  --brand-dark: #8b5cf6;
  --brand-soft: #2a2350;
  --brand-grad: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 50%, #818cf8 100%);
  --accent:     #f472b6;
  --ok:         #4ade80;
  --danger:     #f87171;

  /* dark clay = elevation glow + hairline (NOT puffy double-shadow) */
  --shadow-clay:
    0 0 0 1px rgba(255, 255, 255, .05),
    0 10px 28px rgba(0, 0, 0, .55),
    0 0 22px rgba(124, 92, 246, .10);
  --shadow-clay-sm:
    0 0 0 1px rgba(255, 255, 255, .045),
    0 5px 16px rgba(0, 0, 0, .5);
  --shadow-lg:
    0 0 0 1px rgba(255, 255, 255, .06),
    0 24px 60px rgba(0, 0, 0, .65),
    0 0 40px rgba(124, 92, 246, .14);

  --ring: 0 0 0 3px rgba(167, 139, 250, .35);
}

/* ============================ base ============================ */
* { box-sizing: border-box; }
img, svg, video { max-width: 100%; height: auto; }
html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  font-family: Nunito, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
a { color: var(--brand); }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
label { font-weight: 700; font-size: 13px; display: block; margin-bottom: 5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* ============================ buttons ============================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border: 1px solid transparent; border-radius: 999px;
  background: var(--brand-grad); background-color: var(--brand); color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .1px;
  box-shadow: var(--shadow-clay-sm);
  transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.btn:hover { filter: brightness(1.06); box-shadow: var(--shadow-clay); transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.96); box-shadow: var(--shadow-clay-sm); filter: brightness(.97); }
.btn:focus-visible { outline: none; box-shadow: var(--ring), var(--shadow-clay); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-clay-sm); }
.btn.secondary:hover { background: var(--surface-2); filter: none; border-color: var(--brand-soft); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--border); box-shadow: var(--shadow-clay-sm); }
.btn.danger:hover { background: var(--surface-2); filter: none; border-color: var(--danger); }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; filter: none; }

/* ============================ topbar ============================ */
.topbar {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 900; font-size: 20px; letter-spacing: -.4px; }
.brand span { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--brand); }
.badge { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); text-transform: uppercase; }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.badge.green { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); }

/* theme toggle button (sun/moon) — id wired by JS in Phase 2 */
#theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: 15px; line-height: 1;
  box-shadow: var(--shadow-clay-sm);
  transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
#theme-toggle:hover { transform: translateY(-2px) rotate(-12deg); box-shadow: var(--shadow-clay); color: var(--brand); }
#theme-toggle:active { transform: translateY(0) scale(.92); }
#theme-toggle:focus-visible { outline: none; box-shadow: var(--ring), var(--shadow-clay-sm); }

.warnbar { background: color-mix(in srgb, #f59e0b 22%, var(--surface)); color: var(--text); border-bottom: 1px solid color-mix(in srgb, #f59e0b 40%, var(--surface)); padding: 9px 20px; font-size: 13px; text-align: center; }

.container { max-width: 1040px; margin: 0 auto; padding: 24px 20px 60px; }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }

/* ============================ cards / grids ============================ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-clay); padding: 22px; overflow-wrap: break-word; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .grid.cols-2 { grid-template-columns: 1fr; } }

.event-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.event-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; background: var(--surface); box-shadow: var(--shadow-clay-sm); cursor: pointer; transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.event-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-clay); border-color: var(--brand-soft); }
.event-card h3 { margin: 0 0 4px; font-size: 16px; }
.event-card .stats { display: flex; gap: 14px; margin: 10px 0; font-size: 13px; color: var(--muted); }
.event-card .stats b { color: var(--text); }

/* ============================ form-builder field rows ============================ */
.field-row { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; background: var(--surface-2); margin-bottom: 10px; }
.field-row.dragging { opacity: .5; border-style: dashed; border-color: var(--brand); }
.field-row .field-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.handle { cursor: grab; color: var(--muted); user-select: none; padding: 0 4px; font-size: 18px; }
.handle:active { cursor: grabbing; }

.f-logic { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.f-logic select, .f-logic input { width: auto; }
.f-logic .c-field { max-width: 180px; }
.f-logic .c-val { flex: 1; min-width: 90px; }

.flow-out { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; background: var(--surface); text-align: center; }
.flow-out svg { max-width: 100%; height: auto; }

/* ============================ interactive flow builder ============================ */
.flowed { display: flex; flex-direction: column; align-items: center; }
.fe-term { font-weight: 800; padding: 8px 18px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 14px; }
.fe-term.end { background: var(--ok); color: #fff; }
.fe-conn { width: 2px; height: 16px; background: var(--border); }
.fe-conn.dashed { height: 10px; background: repeating-linear-gradient(var(--border) 0 3px, transparent 3px 6px); }
.fe-addwrap { display: flex; justify-content: center; min-height: 24px; }
.fe-add { border: 1px dashed var(--brand); color: var(--brand); background: var(--surface); border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 800; cursor: pointer; opacity: 0; transition: opacity .12s, background-color var(--dur) var(--ease); }
.fe-add:hover { background: var(--brand-soft); }
.fe-row { display: flex; align-items: center; justify-content: center; gap: 0; width: 100%; }
.fe-col { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; min-width: 0; }
.fe-link { height: 2px; min-width: 30px; background: var(--brand); align-self: center; flex: 0 0 auto; }
.fe-goto { font-size: 11.5px; color: var(--muted); margin: 2px 0 2px 14px; padding-left: 10px; border-left: 2px solid var(--brand); }
.fe-goto b { color: var(--brand); }
.fe-else { font-size: 11.5px; color: var(--muted); margin: 2px 0; }
.fe-endtag { font-size: 11.5px; font-weight: 800; color: var(--danger); margin: 2px 0; }
.flow-zoom { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.flow-zoom button { width: 28px; height: 26px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; font-weight: 800; }
.flow-zoom button:hover { background: var(--surface-2); }
.flow-out g.node:hover { opacity: .85; }
.fe-mid { flex: 0 0 auto; }
.fe-spine-list { display: flex; flex-direction: column; align-items: center; width: 100%; }
.fe-block { display: flex; flex-direction: column; align-items: center; width: 100%; }
.fe-block.dragging { opacity: .45; }
.fe-node { position: relative; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-clay-sm); padding: 10px 12px; min-width: 200px; max-width: 280px; }
.fe-handle { position: absolute; top: 6px; right: 8px; cursor: grab; color: var(--muted); font-size: 15px; line-height: 1; }
.fe-handle:active { cursor: grabbing; }
.fe-node .fe-q { padding-right: 18px; }
.fe-node.branch { border-color: var(--brand-soft); background: var(--brand-soft); }
.fe-q { font-weight: 800; font-size: 14px; overflow-wrap: break-word; }
.fe-cond { font-size: 11px; font-weight: 800; color: var(--brand); margin-bottom: 4px; }
.fe-meta { display: flex; gap: 6px; align-items: center; margin: 4px 0 8px; }
.fe-type { font-size: 11px; background: var(--brand-soft); color: var(--brand); border-radius: var(--radius-sm); padding: 1px 7px; font-weight: 800; }
.fe-req { font-size: 11px; color: var(--danger); font-weight: 800; }
.fe-acts { display: flex; flex-wrap: wrap; gap: 5px; }
.fe-acts button { font-size: 11px; padding: 3px 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 700; }
.fe-acts .fe-del { color: var(--danger); border-color: var(--border); }
.fe-branch { position: absolute; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 1px solid var(--brand); background: var(--surface); color: var(--brand); font-weight: 800; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 3; opacity: 0; transition: opacity .12s, background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.fe-branch:hover { background: var(--brand); color: #fff; }
.fe-bl { left: -13px; } .fe-br { right: -13px; }
.fe-node:hover .fe-branch { opacity: 1; }
.fe-block:hover .fe-add, .fe-add:focus { opacity: 1; }
@media (hover: none) { .fe-branch, .fe-add { opacity: 1; } }
@media (max-width: 640px) {
  .fe-node { min-width: 0; max-width: none; }
  .fe-link { min-width: 14px; }
}

/* ============================ palette ============================ */
.palette { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; padding: 12px; border: 1px dashed var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.palette-btn { border-style: dashed; }
.palette-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ============================ tables ============================ */
table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-md); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ============================ toast ============================ */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 19px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 100; font-size: 14px; font-weight: 700; animation: toast-in .32s var(--ease-spring); }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 16px) scale(.92); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* ============================ modal ============================ */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade-in var(--dur) var(--ease); }
.modal { background: var(--surface); border-radius: var(--radius-xl); width: 100%; max-width: 720px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); animation: modal-pop .3s var(--ease-spring); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--surface); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

.share-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; }
.share-box code { flex: 1; min-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
h1 { font-size: 28px; margin: 0 0 4px; overflow-wrap: break-word; letter-spacing: -.5px; font-weight: 900; }
h2 { font-size: 20px; margin: 0 0 12px; overflow-wrap: break-word; letter-spacing: -.3px; font-weight: 800; }

/* ============================ public form: opts / matrix ============================ */
.opts { display: flex; flex-direction: column; gap: 7px; }
.opt { display: flex; align-items: flex-start; gap: 8px; font-weight: 600; font-size: 14px; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.opt:hover { background: var(--surface-2); }
.opt input { width: auto; margin-top: 2px; }

table.gridq { font-size: 13px; }
table.gridq th, table.gridq td { text-align: center; padding: 7px 9px; white-space: nowrap; }
table.gridq td.rl, table.gridq th:first-child { text-align: left; font-weight: 700; }
table.gridq input { width: auto; }

.form-section { border-top: 2px solid var(--border); padding-top: 12px; margin-top: 6px; }
.form-section h3 { margin: 0; color: var(--brand); font-size: 16px; }

/* ============================ summary dashboard ============================ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-clay-sm); padding: 18px; transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease); }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-clay); }
.kpi-num { font-size: 34px; font-weight: 900; line-height: 1; letter-spacing: -1px; background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--brand); }
.kpi.alt .kpi-num { background: linear-gradient(135deg, #f59e0b, #d97706); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: #b45309; }
.kpi-lbl { font-size: 12.5px; color: var(--muted); margin-top: 7px; }
.sum-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 14px; align-items: start; }
.sum-card { margin: 0; min-width: 0; }
.sum-card.wide { grid-column: 1 / -1; }
.sum-h { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 10px; margin: 7px 0; font-size: 13px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { background: var(--surface-2); border-radius: 999px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand-grad); border-radius: 999px; min-width: 3px; transform-origin: left center; }
.bar-val { font-weight: 800; white-space: nowrap; }
.bar-val .muted { font-weight: 600; }
table.matrix { font-size: 13px; }
table.matrix td.heat { font-weight: 800; min-width: 42px; }
table.matrix td.rl, table.matrix .b { font-weight: 800; }
table.matrix td.rl { white-space: nowrap; }
table.matrix td.nm { cursor: help; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--brand) 45%, transparent); }
table.matrix td.names { text-align: left; vertical-align: top; white-space: normal; min-width: 110px; font-weight: 400; }
.cellnames { display: flex; flex-wrap: wrap; gap: 3px; }
.cellname { font-size: 11px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; white-space: nowrap; }
.sum-section { font-size: 16px; font-weight: 900; letter-spacing: -.2px; margin: 24px 0 12px; color: var(--text); display: flex; align-items: center; gap: 9px; }
.sum-section::before { content: ""; width: 4px; height: 18px; border-radius: 999px; background: var(--brand-grad); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 12px; font-size: 12.5px; font-weight: 800; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--brand); color: #fff; }
.btn.on-toggle { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft); }
.ins-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ins-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; }
.ins-n { font-size: 20px; font-weight: 900; letter-spacing: -.3px; color: var(--text); }
.ins-l { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.wcard { position: relative; }
.wcard .wx { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 12px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity var(--dur) var(--ease); }
.wcard:hover .wx { opacity: 1; }
.wcard .wx:hover { color: var(--danger); border-color: var(--danger); }
@media (hover: none) { .wcard .wx { opacity: 1; } }

/* ============================ form preview (web / phone) ============================ */
.pv-body { background: var(--bg); }
.pv-stage { display: flex; justify-content: center; padding: 8px 4px; }
.pv-stage.web #pv-form { width: 100%; max-width: 640px; }
.pv-stage.phone #pv-form { width: 380px; max-width: 100%; max-height: 72vh; overflow: auto; border: 12px solid #111827; border-radius: 40px; box-shadow: var(--shadow-lg); background: var(--surface); }
.pv-stage.phone #pv-form .card { border: 0; box-shadow: none; border-radius: 0; margin: 0; }
.pv-stage.phone #pv-form::-webkit-scrollbar { width: 0; }

/* ============================ names views ============================ */
.brk-names { padding: 8px 0; border-bottom: 1px solid var(--border); }
.brk-names:last-child { border-bottom: 0; }
.brk-names-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 800; margin-bottom: 5px; }
.namechips { display: flex; flex-wrap: wrap; gap: 5px; }
.namechip { font-size: 12px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }

/* ============================ column picker ============================ */
.colpick { position: relative; }
.colpick > summary { list-style: none; cursor: pointer; display: inline-flex; }
.colpick > summary::-webkit-details-marker { display: none; }
.colpick-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-clay); padding: 8px; min-width: 200px; max-width: min(280px, 88vw); max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.colpick-menu label { margin: 0; padding: 4px 6px; border-radius: var(--radius-sm); cursor: pointer; }
.colpick-menu label:hover { background: var(--surface-2); }
.colpick-menu .qcard { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-weight: 700; color: var(--text); }
.colpick-menu .qcard:hover { background: var(--brand-soft); color: var(--brand); }

/* ============================ AI (Gemini) panel ============================ */
.ai-box { border: 1px solid var(--brand-soft); background: linear-gradient(180deg, var(--brand-soft), var(--surface)); border-radius: var(--radius-md); padding: 12px 14px; }
.ai-box textarea { margin: 8px 0; }
.ai-sample { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 9px 11px; border: 1px dashed var(--brand-soft); border-radius: var(--radius-md); background: var(--surface); }
.ai-sample-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ai-sample-tag { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .3px; color: var(--brand); }
.ai-sample-text { font-size: 13px; color: var(--text); font-style: italic; }
.ai-sample-use { white-space: nowrap; flex: 0 0 auto; }
/* Summary AI parameter palette — tap-to-insert chips built from the form's own questions */
.param-pal { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); padding: 2px 12px 12px; }
.param-pal > summary { cursor: pointer; font-weight: 800; font-size: 13px; padding: 10px 0; list-style: none; }
.param-pal > summary::-webkit-details-marker { display: none; }
.param-pal > summary::before { content: "▸"; display: inline-block; margin-right: 6px; color: var(--brand); transition: transform var(--dur); }
.param-pal[open] > summary::before { transform: rotate(90deg); }
.param-grp { margin-top: 8px; }
.param-grp-h { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); margin-bottom: 6px; }
.param-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.param-chip { font: inherit; font-size: 12px; font-weight: 700; padding: 5px 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; transition: transform var(--dur) var(--ease-spring), background var(--dur), color var(--dur), border-color var(--dur); }
.param-chip:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft); transform: translateY(-1px); }
.param-chip:active { transform: translateY(0) scale(.97); }
/* Ready-made request = an action template whose column is picked inline (avoids a
   floating dropdown that the scrolling drawer would clip). Goes full-width when open. */
.param-tpl[open] { flex: 1 1 100%; }
.param-tpl > summary { list-style: none; cursor: pointer; display: inline-flex; }
.param-tpl > summary::-webkit-details-marker { display: none; }
.param-tpl > summary::after { content: "▾"; margin-left: 5px; font-size: 10px; opacity: .65; }
.param-tpl[open] > summary { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft); }
.param-tpl[open] > summary::after { content: "▴"; }
.param-subchips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; margin-top: 8px; padding: 8px; border-radius: var(--radius-md); border: 1px dashed var(--border); background: var(--surface); }
.param-subchips .param-chip { font-weight: 600; }
/* Money field on the public form: currency-prefixed input, live per-field echo, grand total */
.money-in { display: flex; align-items: center; gap: 8px; }
.money-in .money-cur { font-weight: 900; color: var(--muted); font-size: 15px; }
.money-in .money-amt { flex: 1; min-width: 0; }
.money-echo { font-size: 12px; font-weight: 800; color: var(--brand); margin-top: 4px; }
.money-echo:empty { display: none; }
.money-total { background: var(--brand-soft); border: 1px solid var(--brand-soft); border-radius: var(--radius-md); padding: 12px 16px; font-size: 14px; font-weight: 700; color: var(--text); display: flex; align-items: baseline; justify-content: flex-end; }
.money-total b { color: var(--brand); font-size: 20px; margin-left: 6px; }
/* Rating field: clickable stars (CSS-only hover preview; .on = persisted selection) */
.rating { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rating-stars { display: inline-flex; gap: 4px; }
.rating-star { font-size: 28px; line-height: 1; background: none; border: none; padding: 0 1px; cursor: pointer; color: var(--border); transition: transform var(--dur) var(--ease-spring), color var(--dur); }
.rating-star.on { color: #f5b301; }
.rating-star:hover { transform: scale(1.18); }
.rating-stars:hover .rating-star { color: #f5b301; }              /* hover fills left→right… */
.rating-star:hover ~ .rating-star { color: var(--border); }       /* …and empties the ones after */
.rating-stars:focus-within .rating-star { color: #f5b301; }       /* same preview for keyboard focus */
.rating-star:focus-within ~ .rating-star { color: var(--border); }
.rating-clear { background: none; border: none; padding: 2px 6px; font: inherit; font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; border-radius: 999px; }
.rating-clear:hover { color: var(--danger); background: var(--surface-2); }
.ai-keywrap { position: relative; }
.ai-keywrap > summary { list-style: none; cursor: pointer; }
.ai-keywrap > summary::-webkit-details-marker { display: none; }
.ai-keymenu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-clay); padding: 10px; width: 280px; max-width: 88vw; }
.ai-keymenu input { width: 100%; }
.ai-keymenu button { margin-top: 6px; }

/* ============================ responses table extras ============================ */
.search { max-width: 320px; margin-bottom: 12px; }
.tagchip { display: inline-block; font-size: 11px; font-weight: 800; color: #fff; padding: 2px 8px; border-radius: 999px; margin: 1px 3px 1px 0; white-space: nowrap; }
tr.duprow { opacity: .55; }
tr.duprow td { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.dup { font-size: 10px; font-weight: 900; color: #fff; background: var(--muted); padding: 1px 5px; border-radius: 4px; }
.warn-inline { background: color-mix(in srgb, #f59e0b 18%, var(--surface)); color: var(--text); border: 1px solid color-mix(in srgb, #f59e0b 40%, var(--surface)); border-radius: var(--radius-sm); padding: 9px 13px; font-size: 13px; margin-bottom: 12px; }

/* ============================ rules editor ============================ */
.rule-block { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 14px; background: var(--surface-2); }
.rule-block h3 { margin: 0 0 6px; font-size: 14px; color: var(--brand); }
.rrow { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 8px; }
.rrow select, .rrow input[type=text], .rrow .t-val, .rrow .a-eq, .rrow .o-label { width: auto; }
.dq-list { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.dq-list li { margin: 3px 0; }

/* ============================ hand-out list ============================ */
.ho-opt { border-top: 1px solid var(--border); padding-top: 9px; margin-top: 9px; }
.ho-opt:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.ho-opt-h { margin-bottom: 3px; }
.ho-names { list-style: none; margin: 4px 0 0; padding: 0; }
.ho-names li { padding: 2px 0; }
.ho-name { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.ho-name input { width: auto; }
.ho-name.done span { text-decoration: line-through; color: var(--muted); }

/* ============================ roster job capacity chips ============================ */
.jobchip { display: inline-block; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; margin: 0 6px 6px 0; background: var(--brand-soft); color: var(--brand); border: 1px solid var(--brand-soft); }
.jobchip.full { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--surface)); }
.jobchip.over { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 38%, var(--surface)); }
.jobchip.gray { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
td.nm { font-weight: 700; white-space: nowrap; }

/* ============================ duty roster (time blocks × dates) ============================ */
table.matrix.duty td.duty-cell { vertical-align: top; text-align: left; min-width: 140px; white-space: normal; padding: 8px 10px; }
.duty-slot { margin-bottom: 6px; }
.duty-slot:last-child { margin-bottom: 0; }
.duty-names { font-size: 12.5px; color: var(--text); margin-top: 1px; }

/* ============================ per-slot schedule (slots × jobs) ============================ */
table.matrix.sched td.sch-cell { vertical-align: top; text-align: left; min-width: 150px; white-space: normal; padding: 8px; }
table.matrix.sched td.sch-cell.full { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
table.matrix.sched td.sch-cell.over { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.sch-cap { display: flex; align-items: center; gap: 5px; margin-bottom: 5px; }
.sch-people { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.schchip { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; background: var(--brand-soft); color: var(--brand); border: 1px solid var(--brand-soft); border-radius: 999px; padding: 1px 4px 1px 9px; }
.schchip .sch-x { border: 0; background: none; color: var(--brand); cursor: pointer; font-size: 11px; padding: 0 2px; line-height: 1; }
.sch-add { width: 100%; font-size: 12px; }
.sch-coverage { padding: 12px 14px; border-left: 4px solid var(--ok); }
.sch-coverage.warn { border-left-color: #f59e0b; }
.sch-gap-n { color: #b45309; font-weight: 800; }
.sch-gaps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.schgap { font-size: 12px; background: color-mix(in srgb, #f59e0b 16%, var(--surface)); color: var(--text); border: 1px solid color-mix(in srgb, #f59e0b 40%, var(--surface)); border-radius: 999px; padding: 2px 9px; }

/* ============================ data-tip callout ============================ */
.tipbox { position: absolute; z-index: 9990; max-width: 320px; background: var(--text); color: var(--bg); padding: 9px 11px; border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.5; box-shadow: var(--shadow-lg); pointer-events: none; animation: tour-pop-in .12s var(--ease-spring); }
.tipline { overflow-wrap: anywhere; }
.tipline:first-child { font-weight: 800; margin-bottom: 3px; padding-bottom: 3px; border-bottom: 1px solid color-mix(in srgb, var(--bg) 22%, transparent); }
[data-tip] { cursor: help; }

/* ============================ roster job rows ============================ */
.jrow { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); margin-bottom: 8px; }
.jrow.dragging { opacity: .5; border-style: dashed; border-color: var(--brand); }
.jrow-main { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 8px; }
.jrow-main input { width: auto; }
.j-handle { cursor: grab; color: var(--muted); font-size: 16px; padding: 0 2px; }
.j-handle:active { cursor: grabbing; }
.j-condn:empty { display: none; }
.j-condn { background: var(--brand); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 900; padding: 0 5px; margin-left: 2px; }
.jrow-conds { padding: 4px 10px 12px 32px; border-top: 1px dashed var(--border); }
.jrow-conds.hidden { display: none; }
.crow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.crow select, .crow input { width: auto; }

/* ============================ right-side drawer ============================ */
.drawer-bg { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 400px; max-width: 92vw; background: var(--surface);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; pointer-events: auto; animation: drawer-in .3s var(--ease-spring); }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-head { padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.drawer-body { padding: 16px; overflow: auto; flex: 1; }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }

/* ===================================================================
   NEW — Phase 2 components (tokenized, both themes)
   =================================================================== */

/* ---- skeleton shimmer loading placeholder ---- */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  min-height: 1em;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  animation: skeleton-shimmer 1.3s infinite;
}

/* ---- drag-and-drop roster board ---- */
.ros-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; align-items: start; }
.ros-col {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-clay-sm); padding: 12px; min-height: 80px;
  display: flex; flex-direction: column; gap: 8px;
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease-spring);
}
.ros-col-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 800; color: var(--text); }
.ros-col-cap { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.ros-col.drop-ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 26%, transparent); }
.ros-col.drop-bad { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 24%, transparent); }
.person-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 12px; cursor: grab; box-shadow: var(--shadow-clay-sm);
  transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.person-chip:hover { transform: translateY(-2px); box-shadow: var(--shadow-clay); border-color: var(--brand-soft); }
.person-chip:active { cursor: grabbing; }
.person-chip.chip-dragging { opacity: .5; cursor: grabbing; transform: scale(1.04) rotate(-2deg); box-shadow: var(--shadow-lg); }

/* ---- calendar / timeline ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); text-align: center; padding: 4px 0; }
.cal-cell {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  min-height: 76px; padding: 7px 8px; display: flex; flex-direction: column; gap: 4px;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease-spring);
}
.cal-cell:hover { transform: translateY(-2px); border-color: var(--brand-soft); }
.cal-cell.cal-muted { background: var(--surface-2); color: var(--muted); }
.cal-cell.cal-today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal-day { font-size: 12px; font-weight: 800; color: var(--text); }
.cal-event { font-size: 11px; font-weight: 700; color: #fff; background: var(--brand-grad); border-radius: 999px; padding: 1px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); border-radius: 999px; }
.timeline-item { position: relative; padding: 6px 0 14px; }
.timeline-dot { position: absolute; left: -18px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--brand-soft); }
.timeline-time { font-size: 11.5px; font-weight: 800; color: var(--muted); }
.timeline-body { font-size: 13.5px; color: var(--text); margin-top: 2px; }

/* ---- conflict / fairness badges ---- */
.conflict {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .3px;
  color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--surface));
  border-radius: 999px; padding: 2px 9px;
}
.warn-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .3px;
  color: var(--text); background: color-mix(in srgb, #f59e0b 18%, var(--surface));
  border: 1px solid color-mix(in srgb, #f59e0b 42%, var(--surface));
  border-radius: 999px; padding: 2px 9px;
}

/* ============================ print ============================ */
@media print {
  .topbar, .no-print, .btn, #theme-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .sum-grid { grid-template-columns: 1fr 1fr; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ============================ mobile ============================ */
@media (max-width: 640px) {
  .container { padding: 16px 14px 56px; }
  .topbar { padding: 10px 14px; }
  .topbar .brand { font-size: 17px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }

  .kpi-num { font-size: 27px; }
  .kpi { padding: 14px; }
  .sum-section { font-size: 15px; margin: 18px 0 10px; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

  .modal-head .row { gap: 6px; }

  .modal-bg { padding: 0; place-items: stretch; }
  .modal { max-width: 100%; max-height: 100vh; min-height: 100vh; border-radius: 0; }
  .modal-head, .modal-foot { border-radius: 0; }
  .modal-foot .btn { flex: 1; justify-content: center; }
  .modal-foot .btn.danger { flex-basis: 100%; order: 3; margin-right: 0 !important; }

  .field-row .field-head { flex-wrap: wrap; }
  .field-row .f-label { flex: 1 1 100%; }
  .field-row .f-type { flex: 1 1 auto; width: auto !important; }

  .event-list { grid-template-columns: 1fr; }
  .ros-board { grid-template-columns: 1fr; }
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 56px; }

  .center-screen { padding: 14px; }

  input, select, textarea { font-size: 16px; }
  .small, .muted.small { font-size: 13px; }
}

/* larger tap targets on touch devices */
@media (hover: none) and (pointer: coarse) {
  .btn { padding: 11px 16px; }
  .btn.small { padding: 8px 12px; }
}

/* ===================================================================
   motion & polish — spring vocabulary
   =================================================================== */
.opt, .fe-acts button, .btn.secondary, .seg button, .badge,
.colpick-menu label, .palette-btn { transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease-spring); }
.opt { cursor: pointer; }
.opt:active, .fe-acts button:active { transform: scale(.97); }
tbody tr { transition: background-color var(--dur) var(--ease); }
a { transition: color var(--dur) var(--ease); }

/* Each routed view fades/rises in gently when it mounts. */
.container { animation: view-in .3s var(--ease-spring); }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Dashboard entrance: only when #sum has .anim (initial open, not on toggles). */
@keyframes card-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes cell-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes skeleton-shimmer { to { transform: translateX(100%); } }
.anim .kpi, .anim .sum-card { animation: card-rise .5s var(--ease-spring) both; }
.anim .kpi:nth-child(1) { animation-delay: .02s; } .anim .kpi:nth-child(2) { animation-delay: .07s; }
.anim .kpi:nth-child(3) { animation-delay: .12s; } .anim .kpi:nth-child(4) { animation-delay: .17s; }
.anim .kpi:nth-child(5) { animation-delay: .22s; } .anim .kpi:nth-child(n+6) { animation-delay: .27s; }
.anim .sum-grid > *:nth-child(2) { animation-delay: .06s; } .anim .sum-grid > *:nth-child(3) { animation-delay: .12s; }
.anim .sum-grid > *:nth-child(4) { animation-delay: .18s; } .anim .sum-grid > *:nth-child(n+5) { animation-delay: .24s; }
.anim .bar-fill { animation: bar-grow .7s var(--ease) both; }
.anim table.matrix td.heat { animation: cell-pop .45s var(--ease-spring) both; }

/* Honour reduced-motion: kill transforms/animation, keep instant state. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover, .event-card:hover, .kpi:hover, #theme-toggle:hover,
  .person-chip:hover, .cal-cell:hover, .ros-col { transform: none; }
  .skeleton::after { animation: none; }
}

/* ===================================================================
   onboarding spotlight tour
   =================================================================== */
.tour-block { position: fixed; inset: 0; z-index: 9997; cursor: default; }
.tour-cutout { position: fixed; z-index: 9998; border-radius: var(--radius-md); box-shadow: 0 0 0 9999px rgba(15, 23, 42, .66); pointer-events: none;
  transition: top .25s var(--ease), left .25s var(--ease), width .25s var(--ease), height .25s var(--ease), opacity .2s var(--ease); }
.tour-cutout::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-md); box-shadow: inset 0 0 0 2px #fff, 0 0 0 3px color-mix(in srgb, var(--brand) 55%, transparent); }
.tour-cutout.noh::after { display: none; }
.tour-pop { position: fixed; z-index: 9999; width: 320px; max-width: calc(100vw - 32px); background: var(--surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 16px 16px 14px; animation: tour-pop-in .2s var(--ease-spring); }
@keyframes tour-pop-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.tour-step { font-size: 11px; font-weight: 900; letter-spacing: .5px; text-transform: uppercase;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: var(--brand); }
.tour-pop h4 { margin: 5px 0 5px; font-size: 16px; font-weight: 900; letter-spacing: -.2px; }
.tour-pop p { margin: 0 0 14px; font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.tour-pop p b { color: var(--text); }
.tour-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-skip { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 4px; }
.tour-skip:hover { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .tour-cutout { transition: none; } }
