/* OD-LAYOUT-PRIMITIVES v1 — structure only: display, flex/grid, overflow, wrapping, ratio.
   Put this @layer first; product CSS outside the layer always wins. */
@layer od-layout {
  :where(.od-stack,.od-row,.od-row-top,.od-cluster,.od-grid,.od-field,.od-stat,.od-cell,.od-tile) > :where(*) { min-width: 0; }

  /* containers */
  .od-stack   { display: flex; flex-direction: column; gap: var(--od-gap, 8px); }
  .od-row     { display: flex; align-items: center; gap: var(--od-gap, 8px); }
  .od-row-top { display: flex; align-items: flex-start; gap: var(--od-gap, 8px); }
  .od-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--od-gap, 8px); }
  .od-fill    { flex: 1 1 0; min-width: 0; }
  .od-fixed   { flex: none; }
  .od-grid    { display: grid; gap: var(--od-gap, 12px); grid-template-columns: repeat(var(--od-cols, 3), minmax(0, 1fr)); }

  /* stacked information: each piece is its own line — never sibling inline spans */
  .od-stat, .od-field, .od-cell { display: grid; gap: var(--od-gap, 2px); }
  :where(.od-stat,.od-field,.od-cell) > :where(*) { display: block; }
  .od-tile { display: grid; grid-template-rows: auto 1fr; }
  :where(.od-tile) > :where(*) { display: block; }

  /* media keeps its intrinsic ratio by default; never a distorted or cropped
     cover by accident. height:auto lets the ratio win over an <img height="…">
     attribute. Cropping to a uniform box is an explicit opt-in: set --od-ratio
     AND add .od-media-cover together (per the core rule, only where a crop is
     deliberate — tile thumbs, decorative fills — never on full-frame content). */
  .od-media { display: block; width: 100%; height: auto; aspect-ratio: var(--od-ratio, auto); }
  .od-media-cover { object-fit: cover; }

  /* data text only — authored copy is rewritten to its budget instead */
  .od-truncate { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .od-clamp-2, .od-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .od-clamp-2 { -webkit-line-clamp: 2; }
  .od-clamp-3 { -webkit-line-clamp: 3; }
  .od-lines-2 { min-height: calc(2 * 1.4em); }   /* block-level reservation for a shared baseline */
  .od-nowrap  { white-space: nowrap; }           /* 数字+单位 · 价格+起 · 日期+星期 */
  .od-keep    { word-break: keep-all; overflow-wrap: anywhere; } /* CJK labels break at spaces / <wbr> first */

  /* screen skeleton (optional): bars take their own space, the middle scrolls — no padding guessed for chrome */
  .od-screen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
  .od-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }

  /* horizontal rail: the next item peeks at the edge; trailing room survives overflow */
  .od-rail { display: flex; gap: var(--od-gap, 8px); overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
             padding-inline: var(--od-rail-pad, 16px); scroll-padding-inline: var(--od-rail-pad, 16px); }
  .od-rail::-webkit-scrollbar { display: none; }
  :where(.od-rail) > :where(*) { flex: none; scroll-snap-align: start; }
  :where(.od-rail) > :where(:last-child) { margin-inline-end: var(--od-rail-pad, 16px); }

  .od-spacer { flex: none; visibility: hidden; pointer-events: none; }
  .od-touch  { min-width: 44px; min-height: 44px; }
}
/* /OD-LAYOUT-PRIMITIVES v1 */

/* =========================================================
   Tổ Kiến — design tokens (tokien-spec-v1)
   ========================================================= */
:root {
  color-scheme: dark;

  /* palette: đất ẩm về đêm + hổ phách */
  --ground: #0E0C0A;
  --ground-2: #17130F;
  --surface: #1F1A14;
  --surface-2: #2A231B;
  --surface-3: #352C22;
  --line: #3A3128;
  --line-2: #4A3F33;
  --text: #F2EAD9;
  --text-muted: #B8AB95;
  --text-faint: #8A7E6B;
  --accent: #F2A516;
  --accent-deep: #C97E08;
  --accent-soft: rgba(242, 165, 22, 0.14);
  --accent-ink: #1A1206;
  --success: #7FD08B;
  --success-soft: rgba(127, 208, 139, 0.14);
  --warning: #F2C14E;
  --warning-soft: rgba(242, 193, 78, 0.14);
  --danger: #F0776B;
  --danger-soft: rgba(240, 119, 107, 0.14);
  --info: #8CC5F2;
  --info-soft: rgba(140, 197, 242, 0.14);

  /* type */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 0.8125rem;   /* 13 */
  --fs-sm: 0.875rem;    /* 14 */
  --fs-md: 1rem;        /* 16 */
  --fs-lg: 1.125rem;    /* 18 */
  --fs-xl: 1.375rem;    /* 22 */
  --fs-2xl: 1.75rem;    /* 28 */
  --fs-3xl: 2.25rem;    /* 36 */
  --fs-4xl: 3rem;       /* 48 */
  --fs-hero: clamp(3.5rem, 9vw, 7.5rem);
  --lh-body: 1.6;
  --lh-tight: 1.15;

  /* spacing (8pt) */
  --s-1: 8px; --s-2: 16px; --s-3: 24px; --s-4: 32px; --s-6: 48px; --s-8: 64px; --s-12: 96px; --s-16: 128px;

  /* shape */
  --r-sm: 6px; --r-md: 14px; --r-pill: 999px;
  --shadow-lift: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.35);

  /* motion */
  --t-micro: 180ms;
  --t-micro-out: 120ms;
  --t-move: 360ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.6, 0, 0.8, 0.2);
  --stagger: 40ms;

  --wrap: 1200px;
  --topbar-h: 64px;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body::before {
  /* hạt đất mịn */
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(242,165,22,0.05), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(242,165,22,0.04), transparent 45%);
}
main { position: relative; z-index: 1; }
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: 600; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dt, dd { margin: 0; }
a { color: var(--accent); }
code, pre { font-family: var(--font-mono); }
code { font-size: 0.92em; background: var(--surface-2); padding: 1px 6px; border-radius: var(--r-sm); color: var(--text); }
pre code { background: none; padding: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
img, svg { display: block; }
.ico { width: 20px; height: 20px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.wrap { width: min(var(--wrap), 100% - 2 * var(--s-3)); margin-inline: auto; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent); color: var(--accent-ink); }

.skip {
  position: absolute; left: var(--s-2); top: -100px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: var(--r-sm);
  font-weight: 600; text-decoration: none;
}
.skip:focus { top: var(--s-2); }

/* ---------- reveal on scroll ---------- */
html.js .reveal { opacity: 0; transform: translateY(18px); }
html.js .reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity 520ms var(--ease-out) var(--d, 0ms), transform 520ms var(--ease-out) var(--d, 0ms);
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--s-3);
  height: var(--topbar-h);
  padding-inline: var(--s-3);
  background: rgba(14, 12, 10, 0.78);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; flex: none; }
.brand-ant { width: 36px; height: 22px; color: var(--accent); }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-lg); letter-spacing: 0.01em; }
.brand-code { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); }
.nav { display: flex; gap: 4px; margin-inline: auto; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  position: relative; flex: none;
  color: var(--text-muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 500;
  padding: 10px 12px; border-radius: var(--r-pill);
  transition: color var(--t-micro) var(--ease-out), background var(--t-micro) var(--ease-out);
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.is-active { color: var(--accent-ink); background: var(--accent); }
.motion-toggle {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-muted);
  padding: 8px 12px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 500;
  min-height: 40px;
  transition: border-color var(--t-micro) var(--ease-out), color var(--t-micro) var(--ease-out), transform var(--t-micro) var(--ease-out);
}
.motion-toggle:hover { border-color: var(--accent); color: var(--text); }
.motion-toggle .ico { width: 16px; height: 16px; }
.motion-toggle[aria-pressed="true"] .ico-play, .motion-toggle[aria-pressed="false"] .ico-pause { display: none; }

/* ---------- shared bits ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 500;
  border: 1px solid var(--line);
  line-height: 1.4;
}
.chip-mono { font-family: var(--font-mono); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  min-height: 44px; padding: 10px 18px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink); border: 1px solid transparent;
  font-weight: 600; font-size: var(--fs-sm); text-decoration: none;
  transition: transform var(--t-micro) var(--ease-out), background var(--t-micro) var(--ease-out), border-color var(--t-micro) var(--ease-out), box-shadow var(--t-micro) var(--ease-out);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(242,165,22,0.25); }
.btn:active { transform: translateY(0); transition-duration: var(--t-micro-out); }
.btn .ico { width: 18px; height: 18px; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--accent); box-shadow: none; background: var(--accent-soft); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: var(--fs-xs); font-family: var(--font-mono); font-weight: 500; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.sec-head { max-width: 760px; margin-bottom: var(--s-6); }
.sec-num { font-family: var(--font-mono); color: var(--accent); font-size: var(--fs-sm); letter-spacing: 0.08em; margin-bottom: var(--s-2); }
.sec-title { font-family: var(--font-display); font-size: var(--fs-4xl); font-weight: 600; letter-spacing: -0.01em; }
.sec-title em { font-style: italic; font-weight: 500; color: var(--text-muted); }
.sec-lead { margin-top: var(--s-2); color: var(--text-muted); font-size: var(--fs-lg); max-width: 64ch; }
.section { padding-block: var(--s-12); position: relative; }
.section-alt { background: var(--ground-2); border-block: 1px solid var(--line); }

/* ---------- terminal ---------- */
.term {
  background: #0A0907; border: 1px solid var(--line-2); border-radius: var(--r-md);
  box-shadow: var(--shadow-lift);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: min(560px, 70svh); min-height: 420px;
  overflow: hidden;
}
.term-bar { display: flex; align-items: center; gap: var(--s-2); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--ground-2); }
.term-dots { display: flex; gap: 6px; flex: none; }
.term-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.term-dots i:first-child { background: var(--danger); } .term-dots i:nth-child(2) { background: var(--warning); } .term-dots i:nth-child(3) { background: var(--success); }
.term-title { flex: 1 1 0; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); text-align: center; }
.term-state { flex: none; display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--text-muted); font-family: var(--font-mono); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.term-state.is-live .pulse { background: var(--success); animation: pulse 1.4s ease-out infinite; }
.term-state.is-wait .pulse { background: var(--warning); animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(127,208,139,0.5); } 100% { box-shadow: 0 0 0 8px rgba(127,208,139,0); } }
.term-out {
  overflow-y: auto; overscroll-behavior: contain; padding: var(--s-2) var(--s-2) var(--s-1);
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.55;
  display: flex; flex-direction: column; gap: 4px;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.tl { display: flex; gap: 10px; align-items: baseline; overflow-wrap: anywhere; }
html.js .tl { animation: tl-in 220ms var(--ease-out) both; }
@keyframes tl-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tl-time { flex: none; color: var(--text-faint); font-size: var(--fs-xs); min-width: 5ch; }
.tl-who { flex: none; font-weight: 500; min-width: 10ch; }
.tl-cmd { color: var(--text); }
.tl-cmd .tl-prompt { color: var(--accent); }
.tl-sys { color: var(--text-muted); }
.tl-ok .tl-who, .tl-ok .tl-msg { color: var(--success); }
.tl-warn .tl-msg { color: var(--warning); }
.tl-err .tl-msg { color: var(--danger); }
.tl-dim { color: var(--text-faint); }
.tl-who[data-role="chua"] { color: var(--accent); }
.tl-who[data-role="ca"] { color: var(--warning); }
.tl-who[data-role="xay"] { color: var(--info); }
.tl-who[data-role="doc"] { color: var(--success); }
.tl-who[data-role="viet"] { color: var(--text-muted); }
.tl-who[data-role="canh"] { color: var(--danger); }
.tl-who[data-role="guard"] { color: var(--danger); }
.tl-block {
  margin: 6px 0; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line);
  display: grid; gap: 6px;
}
html.js .tl-block { animation: tl-in 260ms var(--ease-out) both; }
.tl-block-h { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.tl-block-h .ico { width: 16px; height: 16px; color: var(--accent); }
.tl-ask { border-color: var(--warning); background: var(--warning-soft); }
.tl-ask .tl-block-h .ico { color: var(--warning); }
.tl-ask-opts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.tl-ask-opts .btn { min-height: 36px; }
.tl-ask.is-answered .tl-ask-opts .btn { opacity: 0.5; pointer-events: none; }
.tl-ask.is-answered .tl-ask-opts .btn.is-chosen { opacity: 1; }
.tl-report { border-color: var(--accent); }
.tl-report dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; color: var(--text-muted); }
.tl-report dt { color: var(--text-faint); }
.tl-report dd { color: var(--text); }
.tl-table { display: grid; grid-template-columns: auto 1fr auto auto; gap: 2px 14px; color: var(--text-muted); }
.tl-table > span:nth-child(4n+1) { color: var(--text-faint); }
.tl-table > span:nth-child(4n+2) { color: var(--text); }
.tl-table .st { font-size: var(--fs-xs); }
.term-in { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--ground-2); }
.term-prompt { color: var(--accent); font-family: var(--font-mono); font-weight: 600; flex: none; }
.term-input {
  flex: 1 1 0; min-width: 0; background: transparent; border: 0; color: var(--text);
  font-family: var(--font-mono); font-size: var(--fs-sm); padding: 8px 0; min-height: 40px;
}
.term-input::placeholder { color: var(--text-faint); }
.term-input:focus { outline: none; }
.term-in:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
.term-run { flex: none; min-height: 36px; padding: 6px 14px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); font-size: var(--fs-xs); font-weight: 600; transition: border-color var(--t-micro) var(--ease-out), background var(--t-micro) var(--ease-out); }
.term-run:hover { border-color: var(--accent); background: var(--accent-soft); }
.term-quick { padding-block: 10px; background: var(--ground-2); --od-rail-pad: 14px; }
.qcmd {
  min-height: 32px; padding: 4px 12px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line); color: var(--text-muted);
  font-family: var(--font-mono); font-size: var(--fs-xs);
  transition: color var(--t-micro) var(--ease-out), border-color var(--t-micro) var(--ease-out), transform var(--t-micro) var(--ease-out);
}
.qcmd:hover { color: var(--text); border-color: var(--accent); transform: translateY(-1px); }
.term-hint { margin-top: var(--s-2); color: var(--text-faint); font-size: var(--fs-sm); }
.term-hint code { font-size: 0.9em; }

/* ---------- module panels ---------- */
.feat-mod { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; color: var(--accent); letter-spacing: 0.06em; margin-left: 8px; }
.board-epic { font-size: var(--fs-sm); color: var(--text-muted); }
.board-epic strong { color: var(--text); font-weight: 500; }

/* Board */
.board {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s-2);
  min-height: 260px;
}
.bcol { background: var(--ground-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-2); display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.bcol-stuck { border-style: dashed; }
.bcol-h { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); padding-bottom: var(--s-1); border-bottom: 1px solid var(--line); }
.bcount { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); background: var(--surface-2); padding: 0 8px; border-radius: var(--r-pill); min-width: 24px; text-align: center; }
.bcol[data-state="xong"] .bcol-h { color: var(--success); }
.bcol[data-state="ket"] .bcol-h { color: var(--danger); }
.bcol[data-state="dang-lam"] .bcol-h { color: var(--info); }
.bcol[data-state="cho-cham"] .bcol-h { color: var(--warning); }
.blist { display: flex; flex-direction: column; gap: var(--s-1); min-height: 80px; }
.task {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--rc, var(--line-2));
  border-radius: var(--r-sm); padding: 10px 12px; display: grid; gap: 6px;
  will-change: transform;
}
.task.is-new { animation: task-in 380ms var(--ease-out) both; }
@keyframes task-in { from { opacity: 0; transform: translateY(-8px) scale(0.98); } to { opacity: 1; transform: none; } }
.task.is-moving { transition: transform var(--t-move) var(--ease-out); }
.task-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-id { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); }
.task-role { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--rc); background: var(--surface-2); padding: 1px 8px; border-radius: var(--r-pill); white-space: nowrap; }
.task-title { font-size: var(--fs-sm); line-height: 1.4; color: var(--text); font-weight: 500; }
.task-acc { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.45; }
.task-acc::before { content: "Acceptance · "; color: var(--text-faint); }
.task-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-xs); color: var(--text-faint); }
.task-owner { display: inline-flex; align-items: center; gap: 6px; }
.task-owner svg { width: 18px; height: 11px; color: var(--rc); }
.task-tries { font-family: var(--font-mono); color: var(--warning); }
.task-stuck { color: var(--danger); }
.task.is-working::after {
  content: ""; position: absolute; right: 10px; top: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--info);
  animation: pulse-info 1.2s ease-out infinite;
}
@keyframes pulse-info { 0% { box-shadow: 0 0 0 0 rgba(140,197,242,0.5); } 100% { box-shadow: 0 0 0 8px rgba(140,197,242,0); } }
.board-empty { margin-top: var(--s-2); color: var(--text-faint); font-size: var(--fs-sm); }
.board-empty[hidden] { display: none; }

/* Bus */
.bus-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s-4); }
.bus-meta { --od-gap: 12px; flex-wrap: wrap; margin-bottom: var(--s-2); }
.bus-round { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-muted); }
.bus-thread { display: flex; flex-direction: column; gap: var(--s-2); min-height: 320px; padding: var(--s-3); background: var(--ground-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.bus-empty { color: var(--text-faint); font-size: var(--fs-sm); margin: auto; text-align: center; max-width: 36ch; }
.msg { display: grid; grid-template-columns: 36px 1fr; gap: 10px; max-width: 86%; }
.msg.is-lead { grid-template-columns: 1fr 36px; margin-left: auto; }
.msg.is-lead .msg-ant { order: 2; }
html.js .msg { animation: msg-in 360ms var(--ease-out) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.msg-ant { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--mc); }
.msg-ant svg { width: 28px; height: 18px; }
.msg-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; display: grid; gap: 6px; }
.msg.is-lead .msg-body { background: var(--surface-2); }
.msg-h { display: flex; align-items: baseline; gap: 10px; font-size: var(--fs-xs); font-family: var(--font-mono); color: var(--text-faint); flex-wrap: wrap; }
.msg-h b { color: var(--mc); font-weight: 500; }
.msg-text { font-size: var(--fs-sm); color: var(--text); }
.msg-ev { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--success); background: var(--success-soft); padding: 2px 10px; border-radius: var(--r-pill); width: fit-content; }
.msg-ev .ico { width: 14px; height: 14px; }
.msg.is-final .msg-body { border-color: var(--accent); }
.msg-stamp { font-family: var(--font-display); font-style: italic; font-weight: 600; color: var(--accent); font-size: var(--fs-lg); }
.bus-rules { display: grid; gap: var(--s-2); align-content: start; padding: var(--s-3); background: var(--ground-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.bus-rules h4 { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); font-weight: 500; }
.rule-list { display: grid; gap: 10px; }
.rule-list li { display: flex; gap: 12px; align-items: flex-start; font-size: var(--fs-sm); color: var(--text); }
.rule-n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; }
.escalate { display: grid; gap: 6px; counter-reset: e; }
.escalate li { counter-increment: e; display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--text-muted); padding-left: 4px; }
.escalate li::before { content: counter(e) "."; font-family: var(--font-mono); color: var(--warning); }

/* Guard */
.guard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--s-4); }
.verdict-card { display: grid; gap: var(--s-2); align-content: start; }
.verdict-head { --od-gap: 10px; color: var(--text-muted); font-size: var(--fs-sm); }
.verdict-head .ico { color: var(--danger); }
.code { margin: 0; padding: var(--s-2) var(--s-3); background: #0A0907; border: 1px solid var(--line); border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.6; color: var(--text-muted); overflow-x: auto; }
.tok-str { color: var(--success); }
.tok-bad { color: var(--danger); }
.verdict-loop { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: var(--fs-xs); color: var(--text-faint); }
.verdict-loop .ico { width: 16px; height: 16px; }
.vl { padding: 4px 10px; border-radius: var(--r-pill); font-weight: 500; }
.vl-a { background: var(--warning-soft); color: var(--warning); }
.vl-b { background: var(--success-soft); color: var(--success); }
.vl-c { background: var(--danger-soft); color: var(--danger); }
.vl-d { background: var(--surface-3); color: var(--text); }
.vl-or { font-style: italic; }
.fence { display: grid; gap: var(--s-3); padding: var(--s-3); background: var(--ground-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.fence-h { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); font-weight: 500; }
.fence-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fence-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line); font-size: var(--fs-sm);
  transition: border-color var(--t-micro) var(--ease-out), background var(--t-micro) var(--ease-out);
}
.fence-list li .ico { color: var(--text-faint); width: 18px; height: 18px; transition: color var(--t-micro) var(--ease-out); }
.fence-list li.is-hit { border-color: var(--danger); background: var(--danger-soft); animation: shake 320ms var(--ease-out); }
.fence-list li.is-hit .ico { color: var(--danger); }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.fence-try { display: grid; gap: 10px; }
.fence-try-h { font-size: var(--fs-sm); color: var(--text-muted); }
.fence-result { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); padding: 10px 12px; background: #0A0907; border-radius: var(--r-sm); border: 1px solid var(--line); min-height: 44px; display: flex; align-items: center; gap: 8px; }
.fence-result.is-blocked { color: var(--danger); border-color: var(--danger); }

/* Memory */
.mem-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-4); }
.handoff { display: grid; gap: var(--s-2); align-content: start; padding: var(--s-3); background: var(--ground-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.handoff-bar { --od-gap: 12px; }
.ctx-meter { width: 120px; height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; display: block; }
.ctx-fill { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0.35); }
html.js .is-in .ctx-fill { animation: ctx-grow 6s var(--ease-out) infinite alternate; }
@keyframes ctx-grow { from { transform: scaleX(0.35); } to { transform: scaleX(0.96); } }
.handoff-dl { display: grid; gap: var(--s-2); }
.handoff-dl dt { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent); letter-spacing: 0.06em; }
.handoff-dl dd { color: var(--text); font-size: var(--fs-sm); }
.handoff-foot { color: var(--text-faint); font-size: var(--fs-sm); }
.grow { display: grid; gap: var(--s-2); align-content: start; }
.grow-h { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); font-weight: 500; }
.grow-steps { display: grid; gap: var(--s-2); position: relative; }
.grow-step { display: grid; gap: 4px; padding: var(--s-2) var(--s-3); border-left: 2px solid var(--line-2); position: relative; }
.grow-step::before { content: ""; position: absolute; left: -7px; top: 20px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.grow-when { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent); }
.grow-what { color: var(--text); font-size: var(--fs-md); }
.lessons { margin-top: 6px; display: grid; gap: 6px; }
.lessons li { font-size: var(--fs-sm); color: var(--text-muted); padding-left: 14px; position: relative; }
.lessons li::before { content: ""; position: absolute; left: 0; top: 0.65em; width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }

/* Models */
.models-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s-4); }
.model-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.model-table th, .model-table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.model-table th { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.model-table td:first-child { font-weight: 500; }
.model-table td { color: var(--text-muted); }
.model-table td:first-child { color: var(--text); }
.model-table tbody tr { transition: background var(--t-micro) var(--ease-out); }
.model-table tbody tr:hover { background: var(--surface-2); }
.budget { display: grid; gap: var(--s-3); align-content: start; padding: var(--s-3); background: var(--ground-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.budget-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: var(--fs-md); font-weight: 600; }
.meter { display: grid; gap: 8px; }
.meter-l { font-size: var(--fs-sm); color: var(--text-muted); }
.meter-l .od-nowrap { font-family: var(--font-mono); color: var(--text); }
.meter-bar { height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.meter-fill { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(calc(var(--w) / 100)); transition: transform 600ms var(--ease-out); }
.meter-fill.is-hot { background: var(--danger); }
.cost-by-role { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.stat-v { font-family: var(--font-mono); font-size: var(--fs-xl); color: var(--text); }
.stat-c { font-size: var(--fs-xs); color: var(--text-faint); }
.budget-note { font-size: var(--fs-xs); color: var(--text-faint); }

/* ---------- 05 vòng đời ---------- */
.life { display: grid; gap: var(--s-4); }
.life-svg { width: 100%; height: auto; overflow: visible; }
.life-path { fill: none; stroke: var(--line-2); stroke-width: 10; stroke-linecap: round; }
.life-path-done { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 0 10000; transition: stroke-dasharray 700ms var(--ease-out); }
.lnode circle { fill: var(--surface-2); stroke: var(--line-2); stroke-width: 2; transition: fill var(--t-move) var(--ease-out), stroke var(--t-move) var(--ease-out); }
.lnode text { fill: var(--text-muted); font-family: var(--font-mono); font-size: 13px; text-anchor: middle; transition: fill var(--t-move) var(--ease-out); }
.lnode.is-done circle { fill: var(--accent); stroke: var(--accent); }
.lnode.is-done text { fill: var(--accent-ink); font-weight: 600; }
.life-ant { color: var(--accent); transition: transform 700ms var(--ease-out); }
html.js .life-ant use { animation: ant-bob 0.7s ease-in-out infinite; }
.life-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-2); }
.lstep-btn {
  width: 100%; height: 100%; text-align: left; display: grid; gap: 6px; align-content: start;
  padding: var(--s-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--t-micro) var(--ease-out), transform var(--t-move) var(--ease-out), background var(--t-micro) var(--ease-out);
}
.lstep-btn:hover { border-color: var(--line-2); transform: translateY(-3px); }
.lstep-btn[aria-current="step"] { border-color: var(--accent); background: var(--surface-2); }
.lstep-n { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 700; font-style: italic; color: var(--text-faint); display: block; }
.lstep-btn[aria-current="step"] .lstep-n, .lstep.is-done .lstep-n { color: var(--accent); }
.lstep-who { display: block; font-weight: 600; font-size: var(--fs-md); }
.lstep-what { display: block; font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.45; }
.lstep-what code { font-size: 0.85em; }
.life-ctl { --od-gap: 12px; }

/* ---------- 06 bắt đầu ---------- */
.checklist { display: grid; gap: var(--s-2); }
.ck { position: relative; }
.ck input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ck label {
  display: grid; grid-template-columns: 28px 1fr; gap: var(--s-2); align-items: start;
  padding: var(--s-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer;
  transition: border-color var(--t-micro) var(--ease-out), background var(--t-micro) var(--ease-out), transform var(--t-move) var(--ease-out);
}
.ck label:hover { border-color: var(--line-2); transform: translateX(4px); }
.ck input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.ck-box { width: 28px; height: 28px; border-radius: var(--r-sm); border: 2px solid var(--line-2); display: grid; place-items: center; color: var(--accent-ink); background: transparent; margin-top: 1px; transition: background var(--t-micro) var(--ease-out), border-color var(--t-micro) var(--ease-out); }
.ck-box .ico { width: 18px; height: 18px; opacity: 0; transform: scale(0.6); transition: opacity var(--t-micro) var(--ease-out), transform var(--t-micro) var(--ease-out); }
.ck input:checked + label { border-color: var(--accent); }
.ck input:checked + label .ck-box { background: var(--accent); border-color: var(--accent); }
.ck input:checked + label .ck-box .ico { opacity: 1; transform: scale(1); }
.ck input:checked + label .ck-text { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--line-2); }
.ck-text { display: block; color: var(--text); line-height: 1.5; }
.progress-ring { position: relative; width: 160px; height: 160px; }
.progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset 600ms var(--ease-out); }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 0; }
.ring-v { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: 600; }
.ring-c { font-size: var(--fs-xs); color: var(--text-faint); }
.start-note { color: var(--text-muted); font-size: var(--fs-sm); max-width: 30ch; }
.phase { width: 100%; text-align: left; display: grid; gap: 10px; padding-top: var(--s-3); border-top: 1px solid var(--line); }
.phase-h { font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.phase-list { display: grid; gap: 8px; }
.phase-list li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: baseline; font-size: var(--fs-sm); color: var(--text); }
.phase-tag { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent); white-space: nowrap; }
.phase-foot { font-size: var(--fs-xs); color: var(--text-faint); }

/* ---------- footer ---------- */
.foot { position: relative; z-index: 1; border-top: 1px solid var(--line); padding-block: var(--s-4); background: var(--ground-2); }
.foot-row { --od-gap: 12px; flex-wrap: wrap; color: var(--text-muted); font-size: var(--fs-sm); }
.foot-name { font-family: var(--font-display); font-weight: 600; color: var(--text); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .life-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cost-by-role { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .bus-grid, .guard-grid, .mem-grid, .models-grid { grid-template-columns: 1fr; }
  .brand-code { display: none; }
}
@media (max-width: 768px) {
  :root { --topbar-h: 56px; }
  .section { padding-block: var(--s-8); }
  .sec-title { font-size: var(--fs-3xl); }
  .sec-lead { font-size: var(--fs-md); }
  .topbar { gap: var(--s-2); padding-inline: var(--s-2); }
  .motion-toggle .motion-label { display: none; }
  .motion-toggle { padding: 8px; width: 40px; justify-content: center; }
  .board { display: flex; overflow-x: auto; scroll-snap-type: x proximity; gap: var(--s-2); padding-bottom: var(--s-1); scrollbar-width: thin; }
  .bcol { flex: 0 0 78vw; max-width: 300px; scroll-snap-align: start; }
  .fence-list { grid-template-columns: 1fr; }
  .life-steps { grid-template-columns: 1fr; }
  .msg { max-width: 100%; }
  .tl-who { min-width: 7ch; }
  .tl-time { display: none; }
  .term { height: 480px; }
}
@media (max-width: 420px) {
  .term-run { display: none; }
  .tl-table { grid-template-columns: auto 1fr; }
  .tl-table > span:nth-child(4n+3), .tl-table > span:nth-child(4n+4) { grid-column: 2; }
  .cost-by-role { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (hover: none) {
  .lstep-btn:hover, .ck label:hover, .btn:hover { transform: none; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html.js .reveal { opacity: 1; transform: none; }
}
html.motion-off .ant-walker, html.motion-off .mini-ant, html.motion-off .life-ant use, html.motion-off .antcard-fig svg { animation: none !important; }

/* =========================================================
   Dashboard /kien status (màn #/dashboard trong console)
   ========================================================= */
.nav-dash { display: inline-flex; align-items: center; gap: 8px; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.nav-ico { width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; display: inline-block; }
.btn-danger { color: var(--danger); border-color: var(--line-2); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-danger.is-armed { background: var(--danger); color: var(--accent-ink); border-color: var(--danger); }
.mono { font-family: var(--font-mono); font-size: var(--fs-xs); }

/* nhịp sống trên topbar */
.live { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-muted); }
.live .pulse { background: var(--text-faint); }
.live.is-live .pulse { background: var(--success); animation: pulse 1.4s ease-out infinite; }
.live.is-wait .pulse { background: var(--warning); animation: pulse 1.4s ease-out infinite; }
.live.is-paused .pulse { background: var(--text-faint); }
.live.is-done .pulse { background: var(--accent); }
.live.is-live { border-color: rgba(127,208,139,0.4); color: var(--text); }
.live.is-wait { border-color: rgba(242,193,78,0.5); color: var(--text); }

/* khung trang */
.page-dash .dash { padding-block: var(--s-6) var(--s-12); display: grid; gap: var(--s-4); }
.dash-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-4); align-items: end; }
.dash-title { font-family: var(--font-display); font-size: var(--fs-4xl); font-weight: 600; letter-spacing: -0.01em; margin-top: var(--s-1); }
.dash-epic { margin-top: var(--s-2); color: var(--text-muted); font-size: var(--fs-lg); max-width: 70ch; }
.dash-epic strong { color: var(--text); font-weight: 600; }
.dash-goal { font-style: italic; }
.dash-updated { margin-top: 6px; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); }
.dash-ctl { --od-gap: 10px; justify-content: flex-end; }

/* câu hỏi chờ anh */
.ask-banner {
  display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--warning-soft); border: 1px solid var(--warning);
}
html.js .ask-banner:not([hidden]) { animation: detail-in 360ms var(--ease-out) both; }
.ask-fig { position: relative; width: 72px; height: 72px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; color: var(--accent); }
/* icon kiến cũ: chỉ áp cho svg con trực tiếp, không chạm SVG bên trong tk-mascot */
.ask-fig > svg { width: 52px; height: 32px; }
html.js .ask-fig > svg { animation: ant-bob 1.2s ease-in-out infinite; }
.ask-eyebrow { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--warning); letter-spacing: 0.06em; }
.ask-q { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 600; margin-top: 4px; }
.ask-note { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 4px; }
.ask-opts { display: grid; gap: 10px; }
.ask-opt { display: grid; grid-template-columns: 28px 1fr; gap: 10px; text-align: left; justify-content: start; padding: 10px 16px 10px 10px; border-radius: var(--r-md); min-width: 260px; }
.ask-k { display: block; width: 28px; height: 28px; border-radius: 50%; background: rgba(0,0,0,0.18); display: grid; place-items: center; font-family: var(--font-mono); font-weight: 600; }
.btn-ghost .ask-k { background: var(--surface-2); color: var(--accent); }
.ask-l { display: block; font-weight: 500; }

/* chỉ số */
.kpis { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) minmax(0, 0.8fr) minmax(0, 0.8fr); gap: var(--s-2); }
.kpi { padding: var(--s-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); display: grid; gap: var(--s-2); align-content: start; }
.kpi-v { font-family: var(--font-display); font-size: clamp(1.75rem, 4vw, 2.75rem); font-weight: 600; line-height: 1; color: var(--text); }
.kpi-c { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); margin-top: 6px; }
.kpi-sub { font-size: var(--fs-sm); color: var(--text-muted); }
.kpi-meters { display: grid; gap: 10px; }
.kpi-meters .meter-l { font-size: var(--fs-xs); }
.kpi-meters .meter-bar { height: 8px; }
.kpi-ants { display: flex; gap: 4px; flex-wrap: wrap; }
.kpi-ant { width: 30px; height: 19px; color: var(--c); opacity: 0.3; transition: opacity var(--t-move) var(--ease-out); }
.kpi-ant.is-on { opacity: 1; }
html.js .kpi-ant.is-on { animation: ant-bob 0.9s ease-in-out infinite; }
.kpi-states { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.kstate { padding: var(--s-3) var(--s-2); background: var(--surface); position: relative; }
.kstate::before { content: ""; position: absolute; left: var(--s-2); top: var(--s-2); width: 8px; height: 8px; border-radius: 50%; background: var(--sc, var(--text-faint)); }
.kstate[data-state="dang-lam"] { --sc: var(--info); } .kstate[data-state="cho-cham"] { --sc: var(--warning); } .kstate[data-state="xong"] { --sc: var(--success); } .kstate[data-state="ket"] { --sc: var(--danger); } .kstate[data-state="da-nhan"] { --sc: var(--text-muted); }
.kstate-v { font-family: var(--font-display); font-size: clamp(1.75rem, 3.5vw, 2.5rem); font-weight: 600; line-height: 1; margin-top: var(--s-2); }
.kstate-c { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); margin-top: 6px; }
.is-bump { animation: bump 320ms var(--ease-out); }
@keyframes bump { 0% { transform: translateY(6px); opacity: 0.4; } 100% { transform: none; opacity: 1; } }

/* panel */
.dash-grid { display: grid; gap: var(--s-2); }
.dash-grid-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.dash-grid-aux { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); display: grid; grid-template-rows: auto 1fr; align-content: start; min-width: 0; }
.panel-h { --od-gap: 10px; padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--line); color: var(--text-muted); }
.panel-h h2 { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 600; color: var(--text); }
.panel-h .ico { color: var(--accent); }
.panel-empty { padding: var(--s-4) var(--s-3); color: var(--text-faint); font-size: var(--fs-sm); }
.panel-empty[hidden] { display: none; }

/* bảng task */
.task-table-wrap { padding: 0 var(--s-1) var(--s-1); }
.task-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.task-table[hidden] { display: none; }
.task-table th { text-align: left; padding: 10px 12px; font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); border-bottom: 1px solid var(--line); }
.task-table td { padding: 12px; vertical-align: top; border-bottom: 1px solid var(--line); }
.task-table tr:last-child td { border-bottom: 0; }
.task-table tbody tr { transition: background var(--t-move) var(--ease-out); }
.task-table tbody tr.is-new { animation: task-in 380ms var(--ease-out) both; }
.task-table tbody tr.is-flash { animation: row-flash 700ms var(--ease-out); }
@keyframes row-flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.task-table tbody tr.is-working td:first-child { box-shadow: inset 3px 0 0 var(--info); }
.td-title { min-width: 0; }
.task-t { display: block; font-weight: 500; color: var(--text); }
.task-a { display: block; font-size: var(--fs-xs); color: var(--text-faint); margin-top: 2px; }
.task-a::before { content: "Acceptance · "; }
.td-owner { color: var(--text-muted); white-space: nowrap; }
.rolechip { display: inline-block; font-family: var(--font-mono); font-size: 0.6875rem; color: var(--rc); background: var(--surface-2); padding: 2px 8px; border-radius: var(--r-pill); white-space: nowrap; }
.statechip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 500; padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-muted); white-space: nowrap; }
.statechip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.statechip[data-state="da-nhan"] { color: var(--text); }
.statechip[data-state="dang-lam"] { color: var(--info); background: var(--info-soft); } .statechip[data-state="dang-lam"]::before { background: var(--info); }
.statechip[data-state="cho-cham"] { color: var(--warning); background: var(--warning-soft); } .statechip[data-state="cho-cham"]::before { background: var(--warning); }
.statechip[data-state="xong"] { color: var(--success); background: var(--success-soft); } .statechip[data-state="xong"]::before { background: var(--success); }
.statechip[data-state="ket"] { color: var(--danger); background: var(--danger-soft); } .statechip[data-state="ket"]::before { background: var(--danger); }
.td-tries { color: var(--warning); white-space: nowrap; }

/* kiến */
.roster { display: grid; }
.ant-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: var(--s-2); align-items: center; padding: 12px var(--s-3); border-bottom: 1px solid var(--line); }
.ant-row:last-child { border-bottom: 0; }
.ant-row-fig { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--rc); opacity: 0.55; transition: opacity var(--t-move) var(--ease-out); }
.ant-row-fig svg { width: 30px; height: 19px; }
.ant-row[data-status="working"] .ant-row-fig, .ant-row[data-status="waiting"] .ant-row-fig { opacity: 1; }
html.js .ant-row[data-status="working"] .ant-row-fig svg { animation: ant-bob 0.9s ease-in-out infinite; }
.ant-row-name { font-weight: 600; }
.ant-row-detail { font-size: var(--fs-xs); color: var(--text-muted); }
.ant-row-side { text-align: right; max-width: 150px; }
.ant-row-status { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); }
.ant-row[data-status="working"] .ant-row-status { color: var(--success); }
.ant-row[data-status="waiting"] .ant-row-status { color: var(--warning); }
.ant-row-model { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-faint); }
.ant-row-tok { color: var(--text); min-width: 5ch; text-align: right; }

/* sự kiện */
.feed { display: grid; max-height: 460px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.feed-item { display: grid; grid-template-columns: 5ch auto minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 10px var(--s-3); border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.feed-item:last-child { border-bottom: 0; }
html.js .feed-item { animation: tl-in 260ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * var(--stagger)); }
.feed-t { color: var(--text-faint); }
.feed-who { display: inline-flex; align-items: center; gap: 6px; color: var(--rc); font-weight: 500; white-space: nowrap; }
.feed-who svg { width: 18px; height: 11px; }
.feed-msg { color: var(--text-muted); overflow-wrap: anywhere; }
.feed-item.tl-ok .feed-msg { color: var(--success); }
.feed-item.tl-err .feed-msg { color: var(--danger); }
.feed-item.tl-warn .feed-msg { color: var(--warning); }
.feed-item.tl-sys .feed-msg { color: var(--text-faint); }
.feed-msg code { font-size: 0.85em; }

/* chi phí theo vai */
.costbars { display: grid; gap: var(--s-2); padding: var(--s-3); }
.costbar { display: grid; gap: 6px; }
.costbar-l { font-size: var(--fs-sm); }
.costbar-ant { width: 24px; height: 15px; color: var(--rc); }
.costbar-v { font-family: var(--font-mono); color: var(--text); }
.costbar .meter-bar { height: 8px; }
.costbar .meter-fill { background: var(--rc); }
.panel .budget-note { padding: 0 var(--s-3) var(--s-3); }

/* báo cáo */
.report { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--r-md); display: grid; }
html.js .report:not([hidden]) { animation: detail-in 400ms var(--ease-out) both; }
.report-dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2) var(--s-4); padding: var(--s-3); }
.report-dl dt { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent); letter-spacing: 0.06em; }
.report-dl dd { color: var(--text); font-size: var(--fs-sm); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-states { grid-column: 1 / -1; }
}
@media (max-width: 1024px) {
  .dash-grid-main, .dash-grid-aux { grid-template-columns: 1fr; }
  .dash-head { grid-template-columns: 1fr; align-items: start; }
  .dash-ctl { justify-content: flex-start; }
  .ask-banner { grid-template-columns: 56px 1fr; }
  .ask-opts { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .ask-opt { min-width: 0; }
}
@media (max-width: 768px) {
  .page-dash .dash { padding-block: var(--s-4) var(--s-8); }
  .dash-title { font-size: var(--fs-3xl); }
  .kpi-states { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis { grid-template-columns: 1fr; }
  .ask-opts { grid-template-columns: 1fr; }
  .ask-fig { width: 56px; height: 56px; } .ask-fig > svg { width: 40px; height: 25px; }
  .live .live-text { display: none; } .live { padding: 8px; width: 40px; justify-content: center; }
  /* bảng task thành thẻ */
  .task-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .task-table, .task-table tbody { display: block; }
  .task-table tbody tr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "id role tries" "title title title" "owner state state"; gap: 6px 10px; padding: 12px; border-bottom: 1px solid var(--line); }
  .task-table td { display: block; padding: 0; border: 0; }
  .td-id { grid-area: id; } .td-title { grid-area: title; } .td-role { grid-area: role; } .td-owner { grid-area: owner; font-size: var(--fs-xs); } .td-state { grid-area: state; justify-self: end; } .td-tries { grid-area: tries; justify-self: end; }
  .task-table tbody tr.is-working td:first-child { box-shadow: none; }
  .task-table tbody tr.is-working { box-shadow: inset 3px 0 0 var(--info); }
  .ant-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .ant-row-tok { grid-column: 2 / -1; text-align: left; }
  .feed-item { grid-template-columns: 1fr; gap: 4px; }
  .report-dl { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .is-bump, .task-table tbody tr.is-flash, .feed-item, .ask-banner, .report { animation: none !important; }
}

/* =========================================================
   Console (index.html) — tokien-spec-v2
   ========================================================= */
:root { --side-w: 248px; --sb-h: 64px; --dock-h: 340px; --bottom-nav-h: 60px; }

@keyframes ant-bob { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-2px) rotate(-3deg); } }
@keyframes detail-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.tunnel { fill: none; stroke: var(--line); stroke-width: 26; stroke-linecap: round; opacity: 0.55; }
.tunnel-thin { stroke-width: 10; }
.ant-walker { color: var(--accent); }
.crown { position: absolute; top: -6px; right: 2px; width: 16px; height: 10px; background: var(--accent); clip-path: polygon(0 100%, 0 30%, 25% 60%, 50% 0, 75% 60%, 100% 30%, 100% 100%); }

/* khung ứng dụng */
.page-console { overflow: hidden; height: 100dvh; }
.page-console::before { display: none; }
.app {
  display: grid; height: 100dvh;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  grid-template-rows: var(--sb-h) minmax(0, 1fr) auto;
  grid-template-areas: "side statusbar" "side content" "side dock";
}
.side { grid-area: side; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--ground-2); border-right: 1px solid var(--line); min-height: 0; }
.statusbar { grid-area: statusbar; }
.content { grid-area: content; overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding: var(--s-3) var(--s-4) var(--s-6); scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.dock { grid-area: dock; }
.dock[hidden] { display: none; }

/* thanh bên */
.side-brand { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: center; padding: 14px var(--s-2); height: var(--sb-h); border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.side-brand .brand-ant { width: 36px; height: 22px; }
.side-brand-text { gap: 0; }
.side-brand .brand-name { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-lg); line-height: 1.1; }
.side-brand .brand-code { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-faint); }
.side-nav { padding: var(--s-2) var(--s-1); overflow-y: auto; scrollbar-width: none; display: grid; gap: 2px; align-content: start; }
.side-nav::-webkit-scrollbar { display: none; }
.side-group { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); padding: 14px 12px 6px; }
.side-group:first-child { padding-top: 4px; }
.side-nav a {
  position: relative; display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm); color: var(--text-muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; min-height: 40px;
  transition: background var(--t-micro) var(--ease-out), color var(--t-micro) var(--ease-out);
}
.side-nav a:hover { background: var(--surface); color: var(--text); }
.side-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.side-nav a[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--accent); }
.side-nav a[aria-current="page"] .ico { color: var(--accent); }
.side-nav .ico { width: 18px; height: 18px; color: var(--text-faint); }
.side-count { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-faint); background: var(--surface-2); padding: 1px 8px; border-radius: var(--r-pill); }
.side-badge { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.side-badge.is-wait { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.side-badge[hidden] { display: none; }
.side-ext { margin-top: 6px; border-top: 1px solid var(--line); border-radius: 0 0 var(--r-sm) var(--r-sm); }
.side-foot { padding: 0 var(--s-2) var(--s-2); display: grid; gap: 8px; }
.side-trail { width: 100%; height: 36px; overflow: visible; }
.side-trail .tunnel { opacity: 0.5; }
.side-foot-row { --od-gap: 8px; }
.iconbtn { width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text-muted); display: grid; place-items: center; transition: border-color var(--t-micro) var(--ease-out), color var(--t-micro) var(--ease-out); }
.iconbtn:hover { border-color: var(--accent); color: var(--text); }
.iconbtn .ico { width: 16px; height: 16px; }

/* thanh trạng thái */
.statusbar { display: grid; grid-template-columns: minmax(180px, auto) minmax(0, 1fr) auto auto auto; gap: var(--s-3); align-items: center; padding: 0 var(--s-4); background: rgba(14, 12, 10, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.sb-title { gap: 0; }
.sb-crumb { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.sb-h { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 600; line-height: 1.15; }
.sb-epic { --od-gap: 8px; min-width: 0; color: var(--text-muted); font-size: var(--fs-sm); }
.sb-epic .ico { width: 16px; height: 16px; color: var(--accent); }
.sb-epic strong { color: var(--text); font-weight: 500; }
.sb-tok { gap: 0; text-align: right; }
.sb-tok-v { font-family: var(--font-mono); font-size: var(--fs-md); color: var(--text); }
.sb-tok-c { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-faint); }
.sb-actions { --od-gap: 8px; }
.sb-actions kbd { font-family: var(--font-mono); font-size: 0.6875rem; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; margin-left: 2px; color: var(--text-muted); }
.btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.live.is-stale .pulse { background: var(--warning); }

/* màn hình */
.view { display: grid; gap: var(--s-3); max-width: 1320px; margin-inline: auto; }
.view[hidden] { display: none; }
html.js .view { animation: view-in 220ms var(--ease-out) both; }
.view-lead { color: var(--text-muted); max-width: 80ch; }
.panel-desc { padding: var(--s-2) var(--s-3) 0; color: var(--text-muted); font-size: var(--fs-sm); max-width: 90ch; }
.panel-body { padding: var(--s-3); color: var(--text-muted); font-size: var(--fs-sm); }
.panel-body p { color: var(--text); }
.panel-note .panel-h .ico { color: var(--text-faint); }
.panel > .board, .panel > .bus-grid, .panel > .guard-grid, .panel > .mem-grid, .panel > .models-grid, .panel > .bridge-grid, .panel > .life { padding: var(--s-3); }
.panel > .board-empty { padding: 0 var(--s-3) var(--s-3); margin: 0; }
.panel .board { min-height: 220px; }
.panel .bus-thread { min-height: 260px; }
.panel .life-svg { max-height: 160px; }

/* bảng dữ liệu */
.table-scroll { overflow-x: auto; scrollbar-width: thin; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th, .data-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table thead th { font-family: var(--font-mono); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); background: var(--ground-2); position: sticky; top: 0; z-index: 1; }
.data-table tbody th { font-weight: 500; color: var(--text); }
.data-table tbody td { color: var(--text-muted); }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--t-micro) var(--ease-out); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table code { font-size: 0.85em; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-faint); }
.td-act { text-align: right; white-space: nowrap; }
.cmd-code { background: none; padding: 0; color: var(--accent); font-size: var(--fs-sm); }

/* bảng kiến */
.antcell { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; min-width: 150px; }
.antcell-fig { position: relative; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--rc); }
.antcell-fig svg { width: 30px; height: 19px; }
.antcell-fig .crown { top: -4px; right: 2px; width: 14px; height: 9px; }
.ants-table tbody tr[data-status="working"] .antcell-fig { box-shadow: 0 0 0 2px var(--rc); }
html.js .ants-table tbody tr[data-status="working"] .antcell-fig svg { animation: ant-bob 0.9s ease-in-out infinite; }
.perm-ok, .perm-no { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text); }
.perm-ok::before, .perm-no::before { content: ""; width: 7px; height: 7px; border-radius: 2px; flex: none; }
.perm-ok::before { background: var(--success); }
.perm-no::before { background: var(--danger); }
.td-live { white-space: nowrap; }
.steps-inline { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--s-2); }
.steps-inline li { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text); padding: 4px 12px 4px 4px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); }
.step-n { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--accent); }

/* cây tệp */
.tree { padding: var(--s-2) var(--s-3) var(--s-3); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text); display: grid; gap: 6px; }
.tree ul { padding-left: 18px; border-left: 1px solid var(--line); margin: 6px 0 0 6px; display: grid; gap: 4px; }
.tree li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tree-dir { color: var(--text-muted); display: block; }
.tree-dir > ul li { color: var(--text); }
.tree-ant { width: 22px; height: 14px; color: var(--c); display: inline-block; }
.tree-ant svg { width: 22px; height: 14px; }

/* module */
.modgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.modcard { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); color: var(--text); text-decoration: none; transition: border-color var(--t-micro) var(--ease-out), transform var(--t-move) var(--ease-out); }
.modcard:hover { border-color: var(--accent); transform: translateY(-2px); }
.mod-letter { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; font-style: italic; background: var(--accent); color: var(--accent-ink); flex: none; }
.mod-letter-sm { width: 30px; height: 30px; font-size: var(--fs-md); }
.mod-name { font-weight: 600; font-size: var(--fs-sm); }
.mod-sub { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-faint); }
.mod-state { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-faint); padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface-2); white-space: nowrap; }
.mod-state.is-live { color: var(--success); background: var(--success-soft); }
.modpanel { scroll-margin-top: var(--s-2); }
.modpanel.is-target { border-color: var(--accent); }
.provider-row { --od-gap: 6px; }
.bridge-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--s-3); }
.bridge-conf { display: grid; gap: var(--s-2); align-content: start; }
.bridge-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--text-faint); }
.bridge-flow .ico { width: 16px; height: 16px; }

/* danh mục */
.note-strip { display: grid; grid-template-columns: 20px 1fr; gap: 12px; align-items: start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); color: var(--text-muted); font-size: var(--fs-sm); }
.note-strip .ico { color: var(--accent); margin-top: 2px; }
.cat-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s-2); }
.cat-sum { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); display: grid; gap: 2px; cursor: pointer; text-align: left; color: var(--text); transition: border-color var(--t-micro) var(--ease-out); }
.cat-sum:hover, .cat-sum.is-on { border-color: var(--accent); }
.cat-sum-v { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 600; line-height: 1; }
.cat-sum-c { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-faint); }
.cat-sum-bar { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.cat-sum-bar span { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(calc(var(--w) / 100)); }
.cat-filters { display: flex; flex-wrap: wrap; gap: 10px var(--s-3); align-items: center; }
.search { display: flex; align-items: center; gap: 8px; min-width: 240px; flex: 1 1 240px; max-width: 360px; padding: 0 12px; height: 40px; background: var(--ground-2); border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--text-faint); }
.search:focus-within { border-color: var(--accent); }
.search .ico { width: 16px; height: 16px; }
.search input { flex: 1 1 0; min-width: 0; background: none; border: 0; color: var(--text); font: inherit; font-size: var(--fs-sm); height: 100%; }
.search input:focus { outline: none; }
.search input::placeholder { color: var(--text-faint); }
.filter-group { --od-gap: 6px; }
.filter-l { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-right: 4px; }
.fchip { min-height: 32px; padding: 4px 12px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 500; transition: border-color var(--t-micro) var(--ease-out), color var(--t-micro) var(--ease-out), background var(--t-micro) var(--ease-out); }
.fchip:hover { border-color: var(--accent); color: var(--text); }
.fchip.is-on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
select#catGroup, select#dbTaskFilter, select#ovTaskFilter { min-height: 32px; padding: 4px 32px 4px 12px; border-radius: var(--r-pill); background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 10l4 4 4-4' fill='none' stroke='%23B8AB95' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 16px; border: 1px solid var(--line); color: var(--text); font: inherit; font-size: var(--fs-xs); font-weight: 500; appearance: none; -webkit-appearance: none; cursor: pointer; }
.cat-table tbody tr.is-hidden { display: none; }
.cat-group { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.06em; color: var(--text-muted); white-space: nowrap; }
.cat-fn { color: var(--text); }
.cat-fn code { font-size: 0.85em; }
.cat-fn mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px; }
.srcchip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-muted); white-space: nowrap; }
.srcchip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.srcchip[data-src="co-san"] { color: var(--success); background: var(--success-soft); } .srcchip[data-src="co-san"]::before { background: var(--success); }
.srcchip[data-src="xay"] { color: var(--accent); background: var(--accent-soft); } .srcchip[data-src="xay"]::before { background: var(--accent); }
.srcchip[data-src="hon-hop"] { color: var(--info); background: var(--info-soft); } .srcchip[data-src="hon-hop"]::before { background: var(--info); }
.srcnote { display: block; font-size: 0.6875rem; color: var(--text-faint); margin-top: 4px; white-space: normal; }
.phasechip { display: inline-flex; gap: 4px; font-family: var(--font-mono); font-size: var(--fs-xs); white-space: nowrap; }
.phasechip i { font-style: normal; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--line); }
.phasechip i.is-on { background: var(--surface-3); color: var(--text); border-color: var(--line-2); }

/* checklist dạng bảng việc */
.panel .checklist { padding: var(--s-2); }
.ck label { grid-template-columns: 28px 1fr auto; }
.ck-state { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--text-faint); padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface-2); align-self: start; white-space: nowrap; }
.ck input:checked + label .ck-state { color: var(--success); background: var(--success-soft); }
.start-side .panel-body { justify-items: center; text-align: center; }
.start-side .phase { text-align: left; width: 100%; }

/* ngăn cửa sổ lệnh */
.dock { height: var(--dock-h); border-top: 1px solid var(--line); background: var(--ground-2); box-shadow: 0 -4px 16px rgba(0,0,0,0.35); padding: 0; }
html.js .dock:not([hidden]) { animation: dock-in 240ms var(--ease-out) both; }
@keyframes dock-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.dock .term { height: 100%; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
.dock .term-bar .iconbtn { width: 28px; height: 28px; margin-left: 4px; }

/* điều hướng dưới (màn hẹp) */
.bottom-nav { display: none; }

/* ---- responsive console ---- */
@media (max-width: 1200px) {
  .statusbar { grid-template-columns: minmax(160px, auto) minmax(0, 1fr) auto auto; }
  .sb-tok { display: none; }
  .modgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cat-summary { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  :root { --side-w: 72px; }
  .side-brand { grid-template-columns: 1fr; justify-items: center; padding: 14px 8px; }
  .side-brand-text, .side-group, .side-nav a > span:not(.side-badge), .side-count, .side-trail, .side-foot .chip { display: none; }
  .side-nav a { grid-template-columns: 1fr; justify-items: center; padding: 10px; }
  .side-nav a .ico { width: 20px; height: 20px; }
  .side-badge { position: absolute; top: 6px; right: 10px; }
  .side-foot-row { justify-content: center; }
  .bridge-grid { grid-template-columns: 1fr; }
  .cat-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .statusbar { grid-template-columns: minmax(140px, auto) minmax(0, 1fr) auto; padding: 0 var(--s-3); gap: var(--s-2); }
  .live .live-text { display: none; } .live { padding: 8px; width: 40px; justify-content: center; }
  .sb-actions #sbStart span, .sb-actions .btn { font-size: 0.6875rem; padding: 6px 10px; }
}
@media (max-width: 768px) {
  :root { --sb-h: 56px; --dock-h: 300px; }
  .page-console { height: auto; overflow: visible; }
  .app { display: block; height: auto; }
  .side { display: none; }
  .statusbar { position: sticky; top: 0; z-index: 40; grid-template-columns: minmax(0, 1fr) auto auto; }
  .sb-epic { display: none; }
  .sb-actions #sbStart { display: none; }
  .content { overflow: visible; padding: var(--s-2) var(--s-2) calc(var(--bottom-nav-h) + var(--s-6)); }
  .view-lead { font-size: var(--fs-sm); }
  .modgrid { grid-template-columns: 1fr; }
  .cat-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cat-filters .search { max-width: none; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .data-table, .data-table tbody, .data-table tr, .data-table th, .data-table td { display: block; }
  .data-table tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
  .data-table th, .data-table td { padding: 0; border: 0; }
  .data-table td::before { content: attr(data-l); display: block; font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 2px; }
  .data-table td:not([data-l])::before { display: none; }
  .td-act { text-align: left; }
  .dock { position: fixed; left: 0; right: 0; bottom: var(--bottom-nav-h); z-index: 45; }
  .bottom-nav { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottom-nav-h); background: var(--ground-2); border-top: 1px solid var(--line); z-index: 50; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a, .bottom-nav button { display: grid; justify-items: center; align-content: center; gap: 2px; color: var(--text-muted); text-decoration: none; font-size: 0.6875rem; background: none; border: 0; min-height: 44px; }
  .bottom-nav a[aria-current="page"] { color: var(--accent); }
  .bottom-nav .ico { width: 20px; height: 20px; }
  .panel > .board, .panel > .bus-grid, .panel > .guard-grid, .panel > .mem-grid, .panel > .models-grid, .panel > .bridge-grid, .panel > .life { padding: var(--s-2); }
  .life-steps { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html.js .view, html.js .dock:not([hidden]) { animation: none; }
}

/* =========================================================
   Sơ đồ tổ — D3 + PixiJS
   ========================================================= */
.hive { position: relative; width: 100%; height: 100%; overflow: hidden; }
.hive canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
.hive-stage { width: 100%; height: 100%; min-height: 240px; }
.hive-stage-compact { height: 320px; min-height: 320px; }
.hive-panel { display: block; padding: 0; overflow: hidden; min-height: 480px; height: calc(100dvh - var(--sb-h) - 236px); }
.hive-panel-compact { grid-template-rows: auto 320px; }
.hive-bar { --od-gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.hive-bar .view-lead { margin: 0; }
.hive-tip { position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; display: grid; gap: 4px; max-width: 280px; padding: 10px 12px; background: var(--ground-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); box-shadow: var(--shadow-soft); font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.45; }
.hive-tip[hidden] { display: none; }
.hive-tip b { color: var(--text); font-weight: 600; display: block; }
.hive-tip span { display: block; }
.hive-tip-m { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); }
.hive-fallback { padding: var(--s-4); color: var(--text-muted); font-size: var(--fs-sm); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: var(--fs-xs); color: var(--text-muted); padding: 0 4px; }
.legend-i { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.legend-ring { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--c); background: var(--surface-2); flex: none; }
.legend-sep { width: 1px; height: 14px; background: var(--line-2); }
html.js .legend-pulse { animation: pulse 1.4s ease-out infinite; }
@media (max-width: 1024px) { .hive-panel { height: calc(100dvh - var(--sb-h) - 280px); } }
@media (max-width: 768px) { .hive-panel { height: 60dvh; min-height: 360px; } .hive-stage-compact { height: 260px; min-height: 260px; } }
@media (prefers-reduced-motion: reduce) { html.js .legend-pulse { animation: none; } }

/* ---------- vào việc luôn ---------- */
.quick-start { display: grid; gap: 10px; padding: var(--s-2) var(--s-3); background: var(--surface); border: 1px solid var(--accent); border-radius: var(--r-md); }
.quick-start[hidden] { display: none; }
.qs-label { gap: 2px; }
.qs-l { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.qs-h { font-size: var(--fs-sm); color: var(--text-muted); }
.qs-row { --od-gap: 10px; flex-wrap: wrap; }
.qs-row .term-prompt { font-size: var(--fs-sm); }
.qs-input { flex: 1 1 260px; min-width: 0; min-height: 44px; padding: 8px 12px; background: var(--ground-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); color: var(--text); font-family: var(--font-mono); font-size: var(--fs-sm); }
.qs-input::placeholder { color: var(--text-faint); }
.qs-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.panel-more { padding: 10px var(--s-3) 0; color: var(--text-muted); font-size: var(--fs-sm); max-width: 90ch; }
.panel-more summary { cursor: pointer; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); letter-spacing: 0.06em; text-transform: uppercase; list-style: none; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
.panel-more summary::-webkit-details-marker { display: none; }
.panel-more summary::before { content: ""; width: 0; height: 0; border-left: 5px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform var(--t-micro) var(--ease-out); }
.panel-more[open] summary::before { transform: rotate(90deg); }
.panel-more summary:hover { color: var(--text); }
.panel-more p { margin-top: 6px; }
.hive-bar { justify-content: flex-end; }
.page-dash .dash-head { align-items: center; padding-bottom: var(--s-2); border-bottom: 1px solid var(--line); }
.page-dash .dash-title { font-size: var(--fs-xl); margin-top: 0; font-family: var(--font-mono); font-weight: 500; letter-spacing: 0; }
.page-dash .dash-epic { margin-top: 4px; font-size: var(--fs-sm); }
.page-dash .dash-updated { margin-top: 2px; }
@media (max-width: 768px) { .qs-row .btn { flex: 1 1 auto; } }

/* ---------- lịch sử mục tiêu + hộp Ctrl+K + Dashboard ---------- */
.qs-history { --od-gap: 8px; min-height: 32px; }
.qs-hl { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-right: 4px; }
.qs-empty { font-size: var(--fs-xs); color: var(--text-faint); }
.hchip { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; max-width: 100%; }
.hchip-use { background: none; border: 0; color: var(--text); font-size: var(--fs-xs); font-weight: 500; padding: 6px 4px 6px 12px; min-height: 32px; max-width: 46ch; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hchip-use:hover { color: var(--accent); }
.hchip-x { background: none; border: 0; border-left: 1px solid var(--line); color: var(--text-faint); width: 28px; display: grid; place-items: center; }
.hchip-x .ico { width: 14px; height: 14px; }
.hchip-x:hover { color: var(--danger); background: var(--danger-soft); }
.qs-kbd { font-size: var(--fs-xs); color: var(--text-faint); }
kbd { font-family: var(--font-mono); font-size: 0.6875rem; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; color: var(--text-muted); }
.goal-dialog { width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--accent); border-radius: var(--r-md); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lift); }
.goal-dialog::backdrop { background: rgba(14, 12, 10, 0.7); }
html.js .goal-dialog[open] { animation: detail-in 200ms var(--ease-out) both; }
.gd-form { display: grid; gap: var(--s-2); padding: var(--s-3); }
.gd-head { --od-gap: 10px; }
.gd-head h2 { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 600; }
.gd-state { padding: 10px 12px; border-radius: var(--r-sm); background: var(--warning-soft); color: var(--warning); font-size: var(--fs-sm); }
.gd-new { display: grid; gap: 10px; }
.gd-new[hidden], .gd-running[hidden], .gd-state[hidden] { display: none; }
.gd-running { --od-gap: 10px; }
.db-bar { padding: var(--s-2) var(--s-3); display: grid; gap: 10px; }
.db-ctl { --od-gap: 8px; }
.db-meta { text-align: right; gap: 0; }
.db-meta .mono { color: var(--text-faint); }
.db-counts { --od-gap: 6px; }
.db-counts .statechip b { font-family: var(--font-mono); font-weight: 600; margin-left: 2px; }
@media (max-width: 768px) { .db-meta { text-align: left; } .goal-dialog { width: calc(100vw - 32px); } .hchip-use { max-width: 60vw; } }
@media (prefers-reduced-motion: reduce) { html.js .goal-dialog[open] { animation: none; } }

/* ---------- Dashboard: sơ đồ tổ thu nhỏ ---------- */
.db-hive { display: grid; grid-template-rows: auto 280px; padding: 0; overflow: hidden; }
.db-hive .hive-stage-compact { height: 280px; min-height: 280px; }
@media (max-width: 768px) { .db-hive { grid-template-rows: auto 240px; } .db-hive .hive-stage-compact { height: 240px; min-height: 240px; } }

/* ---------- Command palette (Ctrl+K) ---------- */
.cmdk { width: min(640px, calc(100vw - 32px)); }
.cmdk .gd-form { gap: 12px; padding: var(--s-2); }
.cmdk-field { --od-gap: 10px; padding: 0 12px; background: var(--ground-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); }
.cmdk-field:focus-within { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.cmdk-field .ico { flex: none; color: var(--text-faint); }
.cmdk-input { flex: 1 1 auto; border: 0; background: none; padding: 8px 0; font-size: 1rem; }
.cmdk-input:focus { outline: none; border: 0; }
.cmdk-list { position: relative; max-height: min(56dvh, 440px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; margin: 0 -8px; padding: 0 8px; }
.cmdk-gh { padding: 12px 8px 4px; font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.cmdk-opt { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px; border-radius: var(--r-sm); cursor: pointer; color: var(--text); }
.cmdk-opt > * { min-width: 0; }
.cmdk-opt .ico { flex: none; color: var(--text-faint); }
.cmdk-l { flex: 1 1 auto; font-size: var(--fs-sm); font-weight: 500; }
.cmdk-opt.is-mono .cmdk-l { font-family: var(--font-mono); }
.cmdk-h { flex: 0 1 auto; max-width: 45%; font-size: var(--fs-xs); color: var(--text-muted); }
.cmdk-opt .chip { flex: none; }
.cmdk-opt[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.cmdk-opt[aria-selected="true"] .ico { color: var(--accent); }
.cmdk-opt[aria-disabled="true"] { cursor: default; color: var(--text-faint); }
.cmdk-opt[aria-disabled="true"] .cmdk-h { color: var(--text-faint); }
.cmdk-empty { padding: 24px 8px; text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }
.cmdk-hint { --od-gap: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--text-faint); }
.cmdk-hint kbd { margin-right: 4px; }
@media (max-width: 768px) { .cmdk-hint-tip { display: none; } .cmdk-h { max-width: 40%; } }

/* ---------- Dashboard: lọc task theo kiến · xuất nhật ký ---------- */
select#dbTaskFilter, select#ovTaskFilter { min-height: 36px; max-width: 160px; }
select#dbTaskFilter:hover, select#ovTaskFilter:hover { border-color: var(--accent); }
select#dbTaskFilter:focus-visible, select#ovTaskFilter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.db-filterbar { --od-gap: 12px; padding: 8px var(--s-3); background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.db-filterbar[hidden] { display: none; }
.db-filterbar .rolechip { flex: none; font-size: var(--fs-xs); padding: 4px 12px; }
.db-filter-note { font-size: var(--fs-xs); color: var(--text); }
.task-table tr[hidden] { display: none; }
.db-export { --od-gap: 4px; flex: none; }
@media (max-width: 768px) { .db-filterbar { flex-wrap: wrap; padding: 8px var(--s-2); } select#dbTaskFilter, select#ovTaskFilter { max-width: 128px; } }
.panel-h:has(.db-export), .panel-h:has(.kf) { flex-wrap: wrap; row-gap: 8px; }

/* ---------- Dashboard: dòng kiến bấm để lọc ---------- */
#dbRoster .ant-row, #roster .ant-row { cursor: pointer; transition: background-color var(--t-move) var(--ease-out); }
#dbRoster .ant-row:focus-visible, #roster .ant-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#dbRoster .ant-row.is-selected, #roster .ant-row.is-selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
#dbRoster .ant-row.is-selected .ant-row-fig, #roster .ant-row.is-selected .ant-row-fig { opacity: 1; }
@media (hover: hover) { #dbRoster .ant-row:not(.is-selected):hover, #roster .ant-row:not(.is-selected):hover { background: var(--surface-2); } }
.cmdk-hint .btn { min-height: 32px; }
#gdClearRecent[hidden] { display: none; }
#dbFeedChip.is-filtered, #ovFeedChip { color: var(--text); border-color: var(--accent); }
#ovFeedChip[hidden] { display: none; }

/* ---------- Lọc nhiều kiến: ô chọn, chip, chip trên thanh trạng thái ---------- */
.kf { position: relative; flex: none; }
.kf-sum { list-style: none; cursor: pointer; gap: 8px; max-width: 200px; }
.kf-sum::-webkit-details-marker { display: none; }
.kf-sum .ico { flex: none; }
.kf-v { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kf-chev { transition: transform var(--t-micro) var(--ease-out); }
.kf[open] .kf-chev { transform: rotate(180deg); }
.kf-sum.is-on { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.kf-sum:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kf-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: min(328px, calc(100vw - 32px)); max-height: min(70dvh, 560px); overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 4px; padding: 8px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: var(--shadow-lift); }
html.js .kf[open] .kf-menu { animation: detail-in 160ms var(--ease-out) both; }
.kf-opt { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 4px 8px; border-radius: var(--r-sm); cursor: pointer; color: var(--text); font-size: var(--fs-sm); }
.kf-opt input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
.kf-opt input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kf-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rc); flex: none; }
@media (hover: hover) { .kf-opt:hover { background: var(--surface-3); } }
.kf-clear { margin-top: 4px; justify-self: stretch; justify-content: center; }
.kf-chips { --od-gap: 8px; flex: none; max-width: 100%; }
.kf-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 8px 4px 12px; border: 1px solid var(--line-2); cursor: pointer; font-size: var(--fs-xs); }
.kf-chip .ico { width: 14px; height: 14px; color: var(--text-muted); }
@media (hover: hover) { .kf-chip:hover { border-color: var(--rc); } .kf-chip:hover .ico { color: var(--text); } }
.kf-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.db-filterbar .kf-chips + .db-filter-note { min-width: 160px; }
.sb-filter { --od-gap: 0; margin-left: 8px; border: 1px solid var(--accent); border-radius: var(--r-pill); background: var(--accent-soft); overflow: hidden; }
.sb-filter[hidden] { display: none; }
.sb-filter-v { padding: 4px 8px 4px 12px; min-height: 32px; display: inline-flex; align-items: center; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text); text-decoration: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.sb-filter-x { width: 32px; min-height: 32px; display: grid; place-items: center; background: none; border: 0; border-left: 1px solid var(--accent); color: var(--text); cursor: pointer; }
.sb-filter-x .ico { width: 14px; height: 14px; }
@media (hover: hover) { .sb-filter-v:hover, .sb-filter-x:hover { background: var(--surface-3); } }
.sb-filter-v:focus-visible, .sb-filter-x:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 768px) {
  .sb-epic:has(.sb-filter:not([hidden])) { display: flex; grid-column: 1 / -1; padding-bottom: 8px; }
  .sb-epic:has(.sb-filter:not([hidden])) > :not(.sb-filter) { display: none; }
  .sb-epic .sb-filter { margin-left: 0; }
  .kf-menu { right: auto; left: 0; }
}
@media (prefers-reduced-motion: reduce) { html.js .kf[open] .kf-menu { animation: none; } .kf-chev { transition: none; } }

/* phím tắt + preset bộ lọc */
.kf-kbd { flex: none; color: var(--text-muted); }
.kf-sec { display: grid; gap: 8px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.kf-h, .kf-save-l { padding: 0 8px; font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.kf-presets { display: grid; gap: 4px; }
.kf-empty { padding: 0 8px; font-size: var(--fs-xs); color: var(--text-muted); }
.kf-preset { --od-gap: 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.kf-preset-use { display: grid; gap: 2px; min-height: 44px; padding: 6px 8px; background: none; border: 0; text-align: left; color: var(--text); cursor: pointer; }
.kf-preset-n { font-size: var(--fs-sm); font-weight: 600; }
.kf-preset-r { font-size: var(--fs-xs); color: var(--text-muted); }
.kf-preset-use.is-on { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.kf-preset-x { flex: none; width: 36px; align-self: stretch; display: grid; place-items: center; background: none; border: 0; border-left: 1px solid var(--line); color: var(--text-muted); cursor: pointer; }
.kf-preset-x .ico { width: 14px; height: 14px; }
@media (hover: hover) { .kf-preset-use:not(.is-on):hover { background: var(--surface-3); } .kf-preset-x:hover { color: var(--danger); background: var(--danger-soft); } }
.kf-preset-use:focus-visible, .kf-preset-x:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.kf-save { display: grid; gap: 4px; }
.kf-save-row { --od-gap: 8px; padding: 0 4px; }
.kf-save-in { min-height: 36px; padding: 4px 8px; background: var(--ground-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); color: var(--text); font: inherit; font-size: var(--fs-sm); }
.kf-save-in::placeholder { color: var(--text-faint); }
.kf-save-in:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.kf-err { padding: 0 8px; min-height: 0; font-size: var(--fs-xs); color: var(--danger); }
.kf-err:empty { display: none; }

/* preset: đổi thứ tự, đổi tên */
.kf-preset-a { flex: none; width: 32px; align-self: stretch; display: grid; place-items: center; background: none; border: 0; border-left: 1px solid var(--line); color: var(--text-muted); cursor: pointer; }
.kf-preset-a .ico { width: 14px; height: 14px; }
.kf-preset-a.is-up .ico { transform: rotate(180deg); }
.kf-preset-a:disabled { cursor: default; color: var(--text-faint); opacity: 0.45; }
@media (hover: hover) { .kf-preset-a:not(:disabled):hover { color: var(--text); background: var(--surface-3); } .kf-preset-a.is-del:hover { color: var(--danger); background: var(--danger-soft); } }
.kf-preset-a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.kf-ren { display: grid; gap: 4px; padding: 8px 0; border: 1px solid var(--accent); border-radius: var(--r-sm); background: var(--surface); }
.kf-ren .kf-save-row .btn { flex: none; }

/* bảng phím tắt */
.kb-dialog { width: min(520px, calc(100vw - 32px)); }
.kb-list { display: grid; gap: 0; max-height: min(70dvh, 560px); overflow-y: auto; }
.kb-dl { margin: 0; }
.kb-grp { margin: 0; padding: 16px 0 4px; font-weight: 500; }
.kb-grp:first-child { padding-top: 0; }
.kb-h { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.kb-row { display: grid; grid-template-columns: minmax(140px, auto) minmax(0, 1fr); gap: 16px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kb-row dt { white-space: nowrap; color: var(--text-muted); font-size: var(--fs-xs); }
.kb-row dd { margin: 0; font-size: var(--fs-sm); color: var(--text); }
.kb-row kbd { font-size: 0.75rem; padding: 1px 6px; }
.kb-or { font-family: var(--font-body); text-transform: none; letter-spacing: 0; color: var(--text-faint); }
@media (max-width: 480px) { .kb-row { grid-template-columns: 1fr; gap: 4px; } }

/* preset: kéo thả + phím Alt+Shift */
.kf-grip { cursor: grab; touch-action: none; }
.kf-grip:active { cursor: grabbing; }
.kf-preset { position: relative; transition: opacity var(--t-micro) var(--ease-out); }
.kf-preset.is-dragging { opacity: 0.5; border-style: dashed; border-color: var(--accent); }
.kf-preset.drop-before { box-shadow: 0 -2px 0 0 var(--accent); }
.kf-preset.drop-after { box-shadow: 0 2px 0 0 var(--accent); }
.kf-pkbd { flex: none; align-self: center; margin: 0 6px; color: var(--text-muted); }
.kf-hint { padding: 4px 8px 0; font-size: var(--fs-xs); color: var(--text-faint); }
@media (prefers-reduced-motion: reduce) { .kf-preset { transition: none; } }

/* nút Phím tắt trên thanh trạng thái */
.sb-keys { gap: 6px; }
.sb-keys kbd { margin-left: 2px; }
@media (max-width: 1280px) { .sb-keys-l { display: none; } }
@media (max-width: 768px) { .sb-keys kbd { display: none; } .sb-keys { min-width: 44px; min-height: 44px; justify-content: center; } }

/* =====================================================================
   Lượt 5 — bàn điều hành gọn: biết ngay tổ đang ở đâu và việc tiếp theo là gì.
   Mono chỉ cho lệnh, mã, số; màu nhấn chỉ cho hành động chính, mục đang chọn và cảnh báo.
   ===================================================================== */
.btn-sm, .chip-mono, .live, .kpi-c { font-family: var(--font-body); }
.sb-crumb { font-family: var(--font-body); font-size: var(--fs-xs); letter-spacing: 0.02em; text-transform: none; }
.panel-h .ico, .sb-epic .ico { color: var(--text-faint); }
.report { border-color: var(--line-2); }
.report-dl dt { font-family: var(--font-body); color: var(--text-faint); letter-spacing: 0.02em; }
.ask-banner[hidden] { display: none; }            /* thẻ câu hỏi chỉ hiện khi tổ thật sự đang hỏi */
.view { grid-template-columns: minmax(0, 1fr); }  /* không phần con nào ép trang rộng hơn màn */
.view > * { min-width: 0; }
.iconbtn[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* thanh bên: 7 mục, link nhỏ tới màn treo tường */
.side-link { --od-gap: 8px; padding: 8px 12px; border-radius: var(--r-sm); color: var(--text-faint); font-size: var(--fs-xs); text-decoration: none; }
.side-link .ico { width: 14px; height: 14px; }
.side-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) { .side-link:hover { color: var(--text); background: var(--surface); } }
@media (max-width: 1024px) { .side-link { justify-content: center; } .side-link > span { display: none; } }

/* thanh trên: trái tên màn · phải [trạng thái + token] [nút chính] [biểu tượng] */
.statusbar { grid-template-columns: minmax(160px, auto) minmax(0, 1fr) auto auto; gap: var(--s-3); }
.sb-state { --od-gap: 12px; padding: 2px 16px 2px 2px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); }
.sb-state .live { border: 0; background: none; min-height: 36px; padding: 6px 4px 6px 12px; }
.sb-state .sb-tok { display: grid; }
.sb-tok-v { font-size: var(--fs-sm); }
.sb-main { min-width: 152px; }
.sb-icon { width: 40px; height: 40px; border-radius: var(--r-pill); }
.sb-icon .ico { width: 18px; height: 18px; }
@media (max-width: 1024px) {
  .statusbar { grid-template-columns: minmax(120px, auto) minmax(0, 1fr) auto auto; }
  .sb-state { padding: 2px; }
  .sb-state .sb-tok { display: none; }
  .sb-main { min-width: 0; }
}
@media (max-width: 768px) {
  .statusbar { grid-template-columns: minmax(0, 1fr) auto auto; }
  .sb-actions #sbStart { display: inline-flex; }
  #dockToggle { display: none; }                  /* màn hẹp: cửa sổ lệnh mở từ thanh dưới */
  .sb-icon { width: 44px; height: 44px; }
  .content { overflow-x: clip; }
}
@media (max-width: 480px) {
  .sb-main { width: 44px; min-height: 44px; padding: 0; }
  .sb-main-l { display: none; }                   /* chỉ còn biểu tượng; tên nút vẫn đọc qua aria-label */
}

/* thanh tab của Cấu trúc tổ */
.subtabs { --od-gap: 4px; max-width: 1320px; margin: 0 auto var(--s-3); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs[hidden] { display: none; }
.subtabs a { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s-2); margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 500; text-decoration: none; white-space: nowrap; }
.subtabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.subtabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-sm); }
@media (hover: hover) { .subtabs a:not([aria-current]):hover { color: var(--text); } }
@media (max-width: 768px) { .subtabs { margin-bottom: var(--s-2); } }

/* Tổng quan · hàng 1: trạng thái tổ + việc tiếp theo */
.next-card { grid-template-rows: auto; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--s-4); align-items: center; padding: var(--s-3) var(--s-4); }
.next-card:has(.quick-start[hidden]) { grid-template-columns: minmax(0, 1fr); }
.next-main { --od-gap: 8px; }
.next-eyebrow { --od-gap: 8px; color: var(--text-muted); font-size: var(--fs-sm); }
.next-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.next-card[data-mode="live"] .next-dot { background: var(--success); }
.next-card[data-mode="waiting"] .next-dot, .next-card[data-mode="stale"] .next-dot { background: var(--warning); }
.next-card[data-mode="done"] .next-dot { background: var(--success); }
.next-epic { flex: 1 1 0; color: var(--text-faint); }
.next-h { display: grid; gap: 4px; }
.next-l { display: block; color: var(--text-faint); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.next-t { display: block; font-family: var(--font-display); font-size: clamp(1.375rem, 2.2vw, 1.75rem); font-weight: 600; line-height: 1.2; color: var(--text); }
.next-d { max-width: 62ch; color: var(--text-muted); font-size: var(--fs-sm); }
.next-act { --od-gap: 8px; }
.next-act[hidden] { display: none; }
.next-card .quick-start { padding: var(--s-2); background: var(--ground-2); border: 1px solid var(--line); }
@media (max-width: 1024px) { .next-card { grid-template-columns: minmax(0, 1fr); gap: var(--s-2); } }
@media (max-width: 768px) { .next-card { padding: var(--s-2); } }

/* Tổng quan · phần phụ thu gọn (kiến, sơ đồ thu nhỏ, nhật ký, chi phí, điều khiển khác) */
.ov-more { display: grid; gap: var(--s-1); }
.ov-det { grid-template-rows: auto; }
.ov-det-sum { min-height: 52px; border-bottom: 0; cursor: pointer; list-style: none; }
.ov-det-sum::-webkit-details-marker { display: none; }
.ov-det[open] > .ov-det-sum { border-bottom: 1px solid var(--line); }
.ov-det-sum:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-md); }
.ov-det-t { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; color: var(--text); }
.ov-det-chev { transition: transform var(--t-micro) var(--ease-out); }
.ov-det[open] .ov-det-chev { transform: rotate(180deg); }
.ov-det-body { display: grid; gap: var(--s-2); padding: var(--s-2) var(--s-3) var(--s-3); }
.ov-det .db-export { justify-content: flex-end; }
.ov-det-link { justify-self: start; }
.ov-det .hive-stage-compact { height: 300px; min-height: 300px; border-radius: var(--r-sm); overflow: hidden; }
.ov-legacy, .ov-legacy[hidden] { display: none !important; }
@media (max-width: 768px) {
  .ov-det-body { padding: var(--s-1) var(--s-2) var(--s-2); }
  .ov-det .hive-stage-compact { height: 240px; min-height: 240px; }
  .bottom-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .ov-det-chev { transition: none; } }

/* Bảng việc (màn Sáu module) ở màn hẹp: cột .bcol cuộn ngang trong khung riêng, không đẩy trang rộng ra */
.panel > * { min-width: 0; }
.board { max-width: 100%; }

/* =====================================================================
   Lượt 6 — bản sắc hình ảnh: logo khối lục giác, mascot Kiến Chúa, phản hồi khi bấm.
   Icon, logo, mascot nằm trong brand.js (dùng chung cho cả 3 trang).
   ===================================================================== */
[hidden] { display: none !important; }            /* thuộc tính hidden luôn thắng (sửa lỗi 2 nút "Dừng" cùng hiện) */
#sbStop { display: none !important; }              /* nút chính đã tự đổi thành Dừng; nút phụ chỉ còn cho mã cũ */

/* logo */
.side-brand .brand-logo { width: 32px; height: 32px; justify-self: center; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }
.start-hero { --od-gap: var(--s-3); padding: var(--s-2) 0; }
.tk-logo-xl { width: clamp(96px, 12vw, 160px); height: clamp(96px, 12vw, 160px); filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4)); }
.start-hero-name { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: 600; line-height: 1.1; color: var(--text); }
.start-hero-sub { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-faint); }
.st-logo { width: clamp(72px, 11vw, 160px); height: clamp(72px, 11vw, 160px); }
@media (max-width: 768px) { .tk-logo-xl { width: 88px; height: 88px; } .start-hero-name { font-size: var(--fs-2xl); } }

/* mascot trong ô Việc tiếp theo, thẻ câu hỏi, màn trống, màn trạng thái */
.next-main { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--s-2); row-gap: 8px; align-items: center; }
.next-main > :not(.next-mascot) { grid-column: 2; }
.next-mascot { grid-row: 1 / span 4; width: 96px; height: 96px; align-self: start; }
.next-mascot.is-quiet .tkm, .next-mascot.is-quiet .tkm * { animation: none !important; }
.ask-fig { overflow: visible; }
.ask-fig tk-mascot { width: 84px; height: 84px; }
html.js .ask-fig tk-mascot svg { animation: none; }
.panel-empty-m { display: flex; align-items: center; gap: var(--s-2); }
tk-mascot.tkm-sm { width: 56px; height: 56px; }
.st-mascot { width: 64px; height: 64px; }
@media (max-width: 768px) {
  .next-mascot { width: 64px; height: 64px; }
  .ask-fig tk-mascot { width: 60px; height: 60px; }
}

/* nút có phản hồi khi bấm */
.iconbtn { transition: border-color var(--t-micro) var(--ease-out), color var(--t-micro) var(--ease-out), transform var(--t-micro) var(--ease-out); }
.btn:active:not([disabled]), .iconbtn:active, .modcard:active { transform: translateY(1px) scale(0.98); }
@media (prefers-reduced-motion: reduce) { .btn:active, .iconbtn:active, .modcard:active { transform: none; } }

/* =====================================================================
   Lượt 7 — mascot thẻ câu hỏi rõ hơn; chấm "tin mới" trên nút Cửa sổ lệnh
   ===================================================================== */
/* thẻ câu hỏi: mascot "chờ anh trả lời" cỡ ngang ô Việc tiếp theo, đặt trên đĩa sáng ấm cho tương phản */
.ask-banner { grid-template-columns: 104px minmax(0, 1fr) auto; }
.ask-fig { width: 104px; height: 104px; border-radius: 50%; background: radial-gradient(circle at 50% 46%, #FBEFD6 0%, #F1DCB0 62%, #E5C88E 100%); border: 1px solid var(--warning); box-shadow: inset 0 -6px 12px rgba(120, 72, 16, 0.18); }
.ask-fig tk-mascot { width: 92px; height: 92px; display: block; flex: none; }
/* Lượt 7b: SVG của mascot lấp đầy khung, cân giữa vòng tròn, giữ thở/chớp mắt bên trong */
.ask-fig tk-mascot > svg { display: block; width: 100%; height: 100%; animation: none; }
.ask-fig { background: radial-gradient(circle at 50% 42%, #FFF8EA 0%, #FBEBCB 64%, #F2D7A4 100%); }
@media (max-width: 1024px) { .ask-banner { grid-template-columns: 80px minmax(0, 1fr); } .ask-fig { width: 80px; height: 80px; } .ask-fig tk-mascot { width: 72px; height: 72px; } }
@media (max-width: 768px) { .ask-banner { grid-template-columns: 72px minmax(0, 1fr); } .ask-fig { width: 72px; height: 72px; } .ask-fig tk-mascot { width: 64px; height: 64px; } }

/* nút Cửa sổ lệnh: chấm nhỏ khi có dòng mới lúc cửa sổ đang đóng (thay cho tự bật cửa sổ) */
#dockToggle, #dockToggleMobile { position: relative; }
#dockToggle.has-news::after, #dockToggleMobile.has-news::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--ground); }
#dockToggleMobile.has-news::after { top: 8px; right: calc(50% - 16px); }
