/* Youngstone Visions brand on a Tailwind-style finish.
   From the YSV design system: royal blue #0051ba and azure #008dc7, the cool neutral ramp, Archivo with heavy
   tight-tracked headings, flush-left labels and strong 2px rules as structural markers.
   Tailwind-style details: hairline inset rings with soft shadows, small radii, a frosted sticky header,
   underline tabs, pill segmented controls, tinted ring badges and a 2px accent focus ring.
   YSV itself is square-cornered: set --r-sm/--r-md/--r-lg to 0 to return to it. */
:root {
  color-scheme: light;

  /* YSV tokens (Youngstone Visions Design System/styles.css) */
  --color-bg: #f2f4f6;
  --color-text: #13171f;
  --color-accent: #0051ba;
  --color-accent-2: #008dc7;
  --color-neutral-50: #f8f9fb;
  --color-neutral-100: #f2f3f6;
  --color-neutral-200: #e5e7eb;
  --color-neutral-300: #cfd3d8;
  --color-neutral-400: #adb1b8;
  --color-neutral-500: #8b8f96;
  --color-neutral-600: #6a6f76;
  --color-neutral-700: #4f5359;
  --color-neutral-800: #34383f;
  --color-neutral-900: #1f232a;
  --color-accent-50: #f5f9ff;
  --color-accent-100: #ebf3ff;
  --color-accent-200: #d4e5ff;
  --color-accent-300: #b3d1ff;
  --color-accent-400: #78abfc;
  --color-accent-600: #0049a9;
  --color-accent-700: #003784;
  --color-accent-800: #032a63;
  --color-accent-2-100: #e6f5fe;
  --color-accent-2-700: #00567b;
  --color-cta: #16a34a;

  /* Status colours (semantic, used sparingly) */
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --orange: #ea580c;

  /* Roles used throughout */
  --bg: #ffffff;
  --sunken: var(--color-neutral-100);
  --raised: #ffffff;
  --hover: var(--color-neutral-50);
  --ink: var(--color-text);
  --ink-2: var(--color-neutral-700);
  --ink-3: var(--color-neutral-600);
  --ink-4: var(--color-neutral-500);
  --line: rgba(19, 23, 31, 0.08);
  --line-2: var(--color-neutral-300);
  --brand: var(--color-accent);

  --font-display: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;

  --ring: 0 0 0 1px rgba(19, 23, 31, 0.08);
  --shadow-xs: 0 1px 2px rgba(19, 23, 31, 0.05);
  --shadow-card: 0 0 0 1px rgba(19, 23, 31, 0.06), 0 1px 2px rgba(19, 23, 31, 0.06);
  --shadow-card-hover: 0 0 0 1px rgba(0, 81, 186, 0.25), 0 4px 10px -2px rgba(19, 23, 31, 0.08);
  --shadow-pop: 0 0 0 1px rgba(19, 23, 31, 0.06), 0 10px 15px -3px rgba(19, 23, 31, 0.1), 0 4px 6px -4px rgba(19, 23, 31, 0.1);
  --shadow-panel: 0 0 0 1px rgba(19, 23, 31, 0.06), 0 25px 50px -12px rgba(19, 23, 31, 0.25);
  --col-w: 304px;
}
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
::selection { background: var(--color-accent-200); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.ico { display: inline-flex; flex: none; }
.ico svg { display: block; }

.app {
  position: relative; max-width: 1720px; margin: 0 auto;
  padding-block: 0 48px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}
.main { container-type: inline-size; container-name: main; transition: padding-right 0.2s ease; }
@media (min-width: 1100px) {
  body.drawer-open .main { padding-right: calc(min(480px, 40vw) + 16px); }
}
body.tab-graph .hero, body.tab-graph .banner { display: none; }
body.tab-graph .toolbar { margin-top: 20px; }
body.tab-graph .g-stage { height: clamp(520px, calc(100vh - 150px), 1100px); }

.glass { background: var(--raised); border: 0; box-shadow: var(--shadow-card); }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: stretch; gap: 16px; flex-wrap: wrap;
  margin: 0 calc(-1 * max(24px, env(safe-area-inset-left, 0px))); padding: 0 24px;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(255, 255, 255, 0.85); -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; margin-right: auto; padding: 10px 0; }
.mark { width: 32px; height: 32px; flex: none; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text .eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand); }
.brand-text .project { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 24px; align-items: stretch; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 0 2px; border: 0; background: none;
  color: var(--ink-3); font-weight: 500; font-size: 14px; transition: color 0.15s;
}
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.tab:hover { color: var(--ink); }
.tab:hover::after { background: var(--color-neutral-300); }
.tab[aria-current="page"] { color: var(--brand); font-weight: 600; }
.tab[aria-current="page"]::after { background: var(--brand); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: #fff;
  font-size: 11px; font-weight: 600; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums;
}
.top-actions { display: flex; align-items: center; gap: 8px; padding: 10px 0; }
.search-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; min-width: 240px; padding: 0 8px 0 10px; border-radius: var(--r-sm);
  border: 0; background: var(--color-neutral-100); color: var(--ink-3); font-size: 14px; transition: background 0.15s;
}
.search-btn .lbl { flex: 1; text-align: left; }
.search-btn:hover { background: var(--color-neutral-200); }
kbd { font-family: var(--font-body); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--raised); box-shadow: var(--ring); color: var(--ink-3); }
.icon-btn {
  position: relative; width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; border-radius: var(--r-sm);
  border: 0; background: none; color: var(--ink-3); transition: background 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--color-neutral-100); color: var(--ink); }
.icon-btn:active:not(:disabled) { background: var(--color-neutral-200); }
.icon-btn[aria-pressed="true"] { color: var(--brand); background: var(--color-accent-100); }
.icon-btn:disabled { opacity: 0.45; }
.icon-btn .badge { position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; box-shadow: 0 0 0 2px var(--bg); }
.presence { display: flex; align-items: center; padding-left: 6px; }
.presence .av { margin-left: -6px; box-shadow: 0 0 0 2px var(--bg); }
.presence .more { margin-left: 6px; font-size: 12px; color: var(--ink-3); }

/* avatars */
.av {
  width: 28px; height: 28px; border-radius: 999px; flex: none; display: inline-grid; place-items: center; overflow: hidden;
  font-size: 11px; font-weight: 600; color: #fff; background: var(--c, var(--brand)); position: relative;
}
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av.sm { width: 24px; height: 24px; font-size: 10px; }
.av.xs { width: 16px; height: 16px; font-size: 8px; }

/* banner */
.banner {
  margin: 20px 0 0; padding: 12px 12px 12px 16px; border-radius: var(--r-md); display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--color-accent-50); box-shadow: inset 0 0 0 1px var(--color-accent-200);
}
.banner .spark { color: var(--brand); }
.banner p { margin: 0; flex: 1; min-width: 200px; color: var(--color-accent-800); }
.banner strong { font-weight: 600; }

/* ---------- page header ---------- */
.hero { display: grid; grid-template-columns: minmax(260px, 0.85fr) minmax(0, 2.6fr); gap: 32px; align-items: end; margin: 32px 0 24px; padding-bottom: 24px; border-bottom: 2px solid var(--ink); }
.hero h1 { margin: 6px 0 8px; font-family: var(--font-display); font-weight: 800; font-size: 32px; line-height: 1.1; letter-spacing: -0.025em; color: var(--ink); text-wrap: balance; }
.hero p { margin: 0; color: var(--ink-3); max-width: 48ch; font-size: 15px; line-height: 1.6; text-wrap: pretty; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--brand); }
.live-dot { position: relative; width: 8px; height: 8px; border-radius: 999px; background: var(--green); }
.live-dot.on::after { content: ""; position: absolute; inset: -3px; border-radius: inherit; background: var(--green); opacity: 0.25; }
.live-dot.off { background: var(--ink-4); }
.live-dot.warn { background: var(--amber); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.55fr); gap: 12px; }
.kpi {
  position: relative; border-radius: var(--r-md); padding: 14px 16px; min-width: 0;
  display: flex; flex-direction: column; gap: 10px; text-align: left; color: inherit;
  background: var(--raised); border: 0; box-shadow: var(--shadow-card); transition: box-shadow 0.15s;
}
button.kpi:hover { box-shadow: var(--shadow-card-hover); }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kpi .eyebrow { font-size: 13px; font-weight: 500; color: var(--ink-3); }
.kpi-fig { font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--ink); }
.kpi-fig small { font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--ink-4); margin-left: 3px; }
.kpi-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring { width: 36px; height: 36px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring .trk { stroke: var(--color-neutral-200); }
.ring .val { stroke: var(--c); stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.bars { display: flex; gap: 3px; height: 6px; }
.bars span { flex: 1; border-radius: 999px; background: var(--color-neutral-200); overflow: hidden; position: relative; }
.bars i { position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--c); border-radius: 999px; transition: width 0.6s ease; }
.note { background: var(--color-accent-50); box-shadow: inset 0 0 0 1px var(--color-accent-200); border-left: 0; }
.note-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.note-head .eyebrow { color: var(--brand); display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.note-meta { font-size: 12px; color: var(--color-accent-700); opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note textarea { width: 100%; min-height: 56px; resize: none; border: 0; padding: 0; background: transparent; color: var(--color-accent-800); line-height: 1.5; font-size: 14px; }
.note textarea::placeholder { color: var(--color-accent-700); opacity: 0.6; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 0 0 16px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--color-neutral-100); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button { flex: none; }
.seg button {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: calc(var(--r-md) - 2px); border: 0;
  background: none; color: var(--ink-3); font-size: 14px; font-weight: 500; transition: color 0.15s, background 0.15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-card); }
.dot { width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex: none; }
.seg .n { font-size: 12px; font-weight: 600; color: var(--ink-3); background: var(--color-neutral-200); border-radius: 999px; padding: 0 7px; line-height: 18px; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] .n { background: var(--color-accent-100); color: var(--brand); }
.filter {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: var(--r-sm);
  background: var(--raised); color: var(--ink-4); flex: 0 1 260px; min-width: 180px;
  box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-xs); transition: box-shadow 0.15s;
}
.filter:focus-within { box-shadow: inset 0 0 0 2px var(--brand); }
.filter input { border: 0; background: none; outline: none; width: 100%; color: var(--ink); min-width: 0; }
.filter input::placeholder { color: var(--ink-4); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 0; background: var(--raised); color: var(--ink-2); font-size: 13px; font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--line-2); transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.chip:hover { background: var(--hover); color: var(--ink); }
.chip[aria-pressed="true"] { color: var(--brand); background: var(--color-accent-50); box-shadow: inset 0 0 0 1px var(--color-accent-300); }
.chip .n { font-size: 11px; font-weight: 600; color: #fff; background: var(--brand); border-radius: 999px; padding: 0 6px; line-height: 16px; }
.status-line { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-4); }

/* ---------- board ---------- */
.board {
  display: flex; align-items: flex-start; gap: 12px; overflow-x: auto; padding: 2px 2px 16px;
  scroll-snap-type: x proximity; overscroll-behavior-x: contain;
  scrollbar-color: var(--color-neutral-300) transparent; scrollbar-width: thin;
}
.col {
  flex: 0 0 var(--col-w); min-width: 0; border-radius: var(--r-lg); padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px;
  scroll-snap-align: start; position: relative; background: var(--sunken); overflow: hidden;
}
.col::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--gc); }
.col-head { display: grid; gap: 8px; padding: 14px 6px 4px; }
.col-title { display: flex; align-items: center; gap: 8px; }
.col-title .dot { display: none; }
.col-name {
  flex: 1; min-width: 0; height: 28px; padding: 0 6px; margin-left: -6px; border-radius: var(--r-sm); border: 0; background: transparent;
  color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: -0.005em;
  text-overflow: ellipsis;
}
.col-name:not([readonly]):hover { background: rgba(19, 23, 31, 0.05); }
.col-name:focus { background: var(--raised); box-shadow: inset 0 0 0 2px var(--brand); }
.col-del { width: 28px; height: 28px; opacity: 0; transition: opacity 0.15s; }
.col:hover .col-del, .col-del:focus-visible { opacity: 1; }
@media (hover: none) { .col-del { opacity: 0.7; } }
.col-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); }
.col-meta b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.col-bar { height: 4px; border-radius: 999px; background: var(--color-neutral-200); overflow: hidden; }
.col-bar i { display: block; height: 100%; width: var(--w); background: var(--green); border-radius: 999px; transition: width 0.5s ease; }
.col-list { display: flex; flex-direction: column; gap: 8px; min-height: 48px; }
.col-empty { margin: 0; padding: 18px 12px; border: 1px dashed var(--color-neutral-300); border-radius: var(--r-md); text-align: center; font-size: 13px; color: var(--ink-4); }
.col-list:has(.drop-ph) .col-empty { display: none; }
.add-btn { display: flex; align-items: center; gap: 6px; width: 100%; height: 36px; padding: 0 8px; border-radius: var(--r-md); border: 0; background: none; color: var(--ink-3); font-size: 14px; font-weight: 500; transition: background 0.15s, color 0.15s; }
.add-btn:hover { background: rgba(19, 23, 31, 0.05); color: var(--ink); }
.add-form { display: grid; gap: 8px; }
.add-actions { display: flex; gap: 6px; align-items: center; }
.add-col {
  flex: 0 0 auto; height: 40px; padding: 0 14px; border-radius: var(--r-md); border: 1px dashed var(--color-neutral-300); background: none;
  color: var(--ink-3); display: grid; place-items: center; font-weight: 500; font-size: 14px; white-space: nowrap;
}
.add-col:hover { background: var(--hover); color: var(--ink); border-color: var(--color-neutral-400); }
.add-col span { display: inline-flex; align-items: center; gap: 6px; }

/* cards */
.task {
  position: relative; display: grid; gap: 8px; padding: 12px; border-radius: var(--r-md);
  background: var(--raised); border: 0; box-shadow: var(--shadow-card);
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: box-shadow 0.15s;
}
.task:hover { box-shadow: var(--shadow-card-hover); }
.task:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.task.is-open { box-shadow: 0 0 0 2px var(--brand), 0 4px 10px -2px rgba(0, 81, 186, 0.15); }
.task.st-done { background: var(--color-neutral-50); }
.task.st-done .task-title { color: var(--ink-4); }
.task.is-viewed { box-shadow: var(--shadow-card), 0 0 0 2px var(--vc); }
.task-top { display: flex; align-items: flex-start; gap: 10px; }
.st-btn {
  flex: none; width: 18px; height: 18px; margin-top: 1px; padding: 0; display: grid; place-items: center; border-radius: 999px;
  border: 1.5px solid var(--color-neutral-400); background: var(--raised); color: transparent; transition: background 0.15s, border-color 0.15s;
}
.st-btn:hover:not(:disabled) { border-color: var(--brand); background: var(--color-accent-50); }
.st-btn svg { width: 11px; height: 11px; }
.st-doing .st-btn { border-color: var(--brand); background: conic-gradient(var(--brand) 0 50%, transparent 50% 100%); }
.st-waiting .st-btn { border-color: var(--amber); color: var(--amber); }
.st-done .st-btn { border-color: var(--green); background: var(--green); color: #fff; }
.st-btn.tick-pop { animation: tickpop 0.3s ease-out; }
@keyframes tickpop { 0% { transform: scale(0.7); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.task-num { flex: none; font-size: 12px; line-height: 20px; font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; }
.task-title { flex: 1; min-width: 0; margin: 0; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink); overflow-wrap: anywhere; text-wrap: pretty; }
.st-done .task-title { text-decoration: line-through; text-decoration-color: var(--color-neutral-400); }
.grip {
  flex: none; width: 24px; height: 24px; margin: -2px -4px -2px 0; display: grid; place-items: center; border-radius: var(--r-sm);
  color: var(--ink-4); cursor: grab; touch-action: none; opacity: 0; transition: opacity 0.15s, background 0.15s;
}
.task:hover .grip, .task:focus-within .grip { opacity: 1; }
@media (hover: none) { .grip { opacity: 0.7; } }
.grip:hover { background: var(--color-neutral-100); color: var(--ink); }
.task-text { margin: 0 0 0 28px; font-size: 13px; line-height: 18px; color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-answer { margin: 0 0 0 28px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; line-height: 18px; color: #14532d; background: #f0fdf4; box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.task-answer b { color: #15803d; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 700; margin-right: 6px; }
.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-left: 28px; min-height: 0; }
.task-meta:empty { display: none; }
/* tinted ring badges */
.tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: var(--r-sm); font-size: 11px; font-weight: 600; white-space: nowrap; line-height: 20px; }
.tag-p1 { color: #b91c1c; background: #fef2f2; box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.15); }
.tag-paper { color: #92400e; background: #fffbeb; box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.25); }
.tag-unc { color: #9a3412; background: #fff7ed; box-shadow: inset 0 0 0 1px rgba(234, 88, 12, 0.2); }
.tag-st { color: var(--sc); background: color-mix(in srgb, var(--sc) 8%, #ffffff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sc) 25%, transparent); }
.tag-due { font-weight: 500; color: var(--ink-2); background: var(--color-neutral-100); box-shadow: inset 0 0 0 1px var(--line); }
.tag-due.soon { color: #92400e; background: #fffbeb; box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.25); }
.tag-due.late { color: #b91c1c; background: #fef2f2; box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.15); }
.src { font-size: 12px; color: var(--ink-4); white-space: nowrap; }
.meta-r { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
.cnt { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.new-pill { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--color-accent-100); color: var(--brand); font-size: 11px; font-weight: 600; }
.viewers { position: absolute; top: -6px; right: 8px; display: flex; }
.viewers .av { box-shadow: 0 0 0 2px var(--bg); margin-left: -4px; }

/* drag */
.task.ghost {
  position: fixed; z-index: 80; margin: 0; pointer-events: none;
  transform: rotate(1.5deg); box-shadow: var(--shadow-pop); background: var(--raised); transition: none;
}
.drop-ph { flex: none; border-radius: var(--r-md); background: var(--color-accent-50); box-shadow: inset 0 0 0 1px var(--color-accent-200); }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
body.dragging .task:not(.ghost) { transition: none; }
.col.drop-target { background: var(--color-accent-50); }
body.ro .grip, body.ro .add-wrap, body.ro .add-col, body.ro .col-del { display: none !important; }

/* inputs */
.in {
  width: 100%; padding: 7px 10px; border-radius: var(--r-sm); border: 0; background: var(--raised); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-xs); transition: box-shadow 0.15s;
}
.in::placeholder { color: var(--ink-4); }
.in:focus { box-shadow: inset 0 0 0 2px var(--brand); }
textarea.in { resize: vertical; line-height: 1.5; min-height: 64px; }
select.in { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.btn {
  display: inline-flex; align-items: center; justify-content: flex-start; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 0; background: var(--raised); color: var(--ink); font-size: 14px; font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-xs); transition: background 0.15s, box-shadow 0.15s;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:active:not(:disabled) { background: var(--color-neutral-100); }
.btn:disabled { opacity: 0.45; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-xs); }
.btn.primary:hover:not(:disabled) { background: var(--color-accent-600); }
.btn.primary:active:not(:disabled) { background: var(--color-accent-700); }
.btn.ghost { background: none; color: var(--ink-3); box-shadow: none; font-weight: 500; }
.btn.ghost:hover:not(:disabled) { background: var(--color-neutral-100); color: var(--ink); }
.btn.danger { background: var(--red); color: #fff; box-shadow: var(--shadow-xs); }
.btn.danger:hover:not(:disabled) { background: #b91c1c; }
.text-btn { border: 0; background: none; padding: 2px 4px; border-radius: 4px; color: var(--brand); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.text-btn:hover { color: var(--color-accent-700); background: var(--color-accent-50); }

/* ---------- notices ---------- */
.notice { max-width: 520px; margin: 48px auto; padding: 28px; border-radius: var(--r-lg); text-align: left; }
.notice h3 { margin: 0 0 6px; font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.notice p { margin: 0; color: var(--ink-3); }
.spinner { width: 24px; height: 24px; margin: 0 0 14px; border-radius: 999px; border: 3px solid var(--color-neutral-200); border-top-color: var(--brand); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- map ---------- */
.graph-panel { position: relative; border-radius: var(--r-lg); overflow: hidden; background: var(--sunken); box-shadow: none; }
.g-stage { position: relative; height: clamp(520px, calc(100vh - 220px), 980px); }
#graph-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#graph-canvas.over { cursor: pointer; }
#graph-canvas.grabbing { cursor: grabbing; }
.g-ui { position: absolute; z-index: 2; display: flex; gap: 8px; }
.g-tl { top: 16px; left: 16px; flex-direction: column; align-items: flex-start; max-width: calc(100% - 220px); }
.g-tr { top: 16px; right: 16px; padding: 3px; border-radius: var(--r-md); background: var(--raised); box-shadow: var(--shadow-card); gap: 2px; }
.g-bl { left: 16px; bottom: 16px; right: 16px; justify-content: space-between; align-items: flex-end; pointer-events: none; }
.g-title .eyebrow { color: var(--brand); }
.g-title strong { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.g-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.g-legend .chip { height: 28px; padding: 0 10px; font-size: 12px; background: var(--raised); color: var(--ink-2); box-shadow: var(--shadow-card); }
.g-legend .chip[aria-pressed="false"] { color: var(--ink-4); background: rgba(255, 255, 255, 0.6); }
.g-legend .chip[aria-pressed="false"] .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); }
.g-legend .chip[aria-pressed="true"] { color: var(--ink); }
.g-hint { font-size: 12px; color: var(--ink-3); background: rgba(255, 255, 255, 0.85); padding: 5px 10px; border-radius: 999px; box-shadow: var(--shadow-card); }
.g-tip { position: absolute; z-index: 3; pointer-events: none; max-width: 300px; padding: 8px 12px; border-radius: var(--r-md); background: var(--color-neutral-900); color: #fff; border: 0; box-shadow: var(--shadow-pop); }
.g-tip .t { font-weight: 600; font-size: 13px; line-height: 1.35; }
.g-tip .s { font-size: 12px; color: var(--color-neutral-300); margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.g-panel { position: absolute; z-index: 3; right: 16px; top: 64px; width: min(320px, calc(100% - 32px)); max-height: calc(100% - 130px); overflow: auto; border-radius: var(--r-lg); padding: 14px; background: var(--raised); border: 0; box-shadow: var(--shadow-pop); }
.g-panel h3 { margin: 2px 0 2px; font-family: var(--font-display); font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.g-panel .sub { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.g-panel-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.ref-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.ref-list > li { min-width: 0; display: flex; }
.st-pill:disabled:not([aria-pressed="true"]), .flag:disabled:not([aria-pressed="true"]) { opacity: 0.45; }
body.ro .drawer .in[readonly], body.ro .drawer .in:disabled, body.ro .d-title { background: transparent; box-shadow: none; padding-left: 0; resize: none; }
body.ro .d-answer .in[readonly] { padding-left: 10px; }
body.ro .owner-btn:disabled { background: transparent; padding-left: 0; }

/* reference chips */
.ref {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 5px 8px; border-radius: var(--r-sm); border: 0;
  background: none; color: var(--ink); font-size: 14px; text-align: left; line-height: 1.3; transition: background 0.15s;
}
.ref:hover { background: var(--color-neutral-100); }
.ref .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref.done .lbl { text-decoration: line-through; color: var(--ink-4); }
.ref-list .ref { width: 100%; }
.wl { display: inline; padding: 0; border: 0; background: none; color: var(--brand); font: inherit; font-weight: 500; text-decoration: underline; text-decoration-color: var(--color-accent-300); text-underline-offset: 3px; }
.wl:hover { text-decoration-color: var(--brand); }
.wl-miss { color: var(--ink-4); border-bottom: 1px dashed var(--ink-4); }

/* ---------- activity ---------- */
.act-panel { border-radius: var(--r-lg); padding: 24px; max-width: 920px; }
.act-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 2px solid var(--ink); }
.act-head .eyebrow { color: var(--brand); }
.act-head h2 { margin: 4px 0 0; font-family: var(--font-display); font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.act-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.act-list { list-style: none; margin: 0; padding: 0; position: relative; }
.act-day { margin: 24px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-4); }
.act-day:first-child { margin-top: 0; }
.act-item { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px; border-radius: var(--r-md); align-items: start; }
.act-item:hover { background: var(--hover); }
.act-item.unread { background: var(--color-accent-50); }
.act-item.unread::before { content: ""; position: absolute; left: -10px; top: 20px; width: 6px; height: 6px; border-radius: 999px; background: var(--brand); }
.act-line { font-size: 14px; line-height: 1.55; color: var(--ink-3); }
.act-line strong { color: var(--ink); font-weight: 600; }
.act-line .ref { padding: 0; margin: 0; vertical-align: baseline; font-size: 14px; font-weight: 500; max-width: 360px; color: var(--brand); }
.act-line .ref:hover { background: none; text-decoration: underline; }
.act-line .ref .dot { display: none; }
.act-time { font-size: 12px; color: var(--ink-4); white-space: nowrap; padding-top: 2px; font-variant-numeric: tabular-nums; }
.act-quote { grid-column: 2 / 4; margin: 6px 0 0; padding: 10px 14px; border-radius: var(--r-md); background: var(--color-neutral-50); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { padding: 32px 10px; text-align: center; color: var(--ink-4); }

/* ---------- side panel ---------- */
.drawer {
  position: fixed; z-index: 50; top: calc(env(safe-area-inset-top, 0px) + var(--top-h, 57px)); bottom: 0;
  right: 0; width: min(480px, 100vw); border-radius: 0;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--raised); border-left: 1px solid var(--line); box-shadow: var(--shadow-panel);
  transform: translateX(16px); opacity: 0; transition: transform 0.2s ease, opacity 0.15s;
}
.drawer.open { transform: none; opacity: 1; }
.drawer:focus { outline: none; }
.d-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 24px; border-bottom: 1px solid var(--line); }
.d-crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.d-crumbs .in { height: 32px; padding: 0 28px 0 10px; font-size: 13px; font-weight: 500; width: auto; max-width: 100%; min-width: 0; flex: 1; box-shadow: none; background-color: var(--color-neutral-100); }
.d-crumbs .in:hover:not(:disabled) { background-color: var(--color-neutral-200); }
.d-group { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand); white-space: nowrap; }
.d-actions { display: flex; gap: 2px; }
.d-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 20px 24px 32px; display: flex; flex-direction: column; gap: 24px; scrollbar-width: thin; scrollbar-color: var(--color-neutral-300) transparent; }
.d-viewers { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r-md); font-size: 13px; color: var(--color-accent-800); background: var(--color-accent-50); box-shadow: inset 0 0 0 1px var(--color-accent-200); }
.d-title {
  width: 100%; resize: none; overflow: hidden; border: 0; border-radius: var(--r-sm); padding: 4px 6px; margin: -4px -6px 0;
  background: transparent; color: var(--ink); font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance;
}
.d-title:hover:not([readonly]) { background: var(--hover); }
.d-title:focus { background: var(--raised); box-shadow: inset 0 0 0 2px var(--brand); }
.d-status { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--color-neutral-100); justify-self: start; align-self: flex-start; }
.st-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: calc(var(--r-md) - 2px); border: 0;
  background: none; color: var(--ink-3); font-size: 13px; font-weight: 500; transition: background 0.15s, color 0.15s;
}
.st-pill:hover:not(:disabled) { color: var(--ink); }
.st-pill[aria-pressed="true"] { color: var(--ink); font-weight: 600; background: var(--raised); box-shadow: var(--shadow-card); }
.st-pill .sdot { width: 8px; height: 8px; border-radius: 999px; background: var(--sc); }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.d-field { display: grid; gap: 6px; min-width: 0; }
.d-k { font-size: 13px; font-weight: 600; color: var(--ink); }
.d-k-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.owner-btn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 6px; border-radius: var(--r-sm); border: 0; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-2), var(--shadow-xs); text-align: left; min-width: 0; }
.owner-btn:hover:not(:disabled) { background: var(--hover); }
.owner-btn .av { width: 24px; height: 24px; font-size: 10px; }
.owner-btn .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.owner-btn .ph { width: 24px; height: 24px; border-radius: 999px; background: var(--color-neutral-100); display: grid; place-items: center; color: var(--ink-3); flex: none; }
input[type="date"].in { height: 36px; color-scheme: light; }
.d-flags { grid-column: 1 / -1; }
.flag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.flag {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; border: 0;
  background: var(--raised); color: var(--ink-3); font-size: 12px; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line-2);
  transition: background 0.15s, color 0.15s;
}
.flag:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.flag[aria-pressed="true"] { color: var(--fc); background: color-mix(in srgb, var(--fc) 7%, #ffffff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fc) 30%, transparent); }
.d-block { display: grid; gap: 8px; }
.d-answer .in { background: #f0fdf4; box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.3); }
.d-answer .in:focus { box-shadow: inset 0 0 0 2px var(--green); }
.d-answer .d-k { color: #15803d; }
.mini-stage { position: relative; height: 200px; border-radius: var(--r-md); overflow: hidden; background: var(--sunken); }
#mini-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
#mini-canvas.over { cursor: pointer; }
#mini-canvas.grabbing { cursor: grabbing; }
.mini-cap { position: absolute; left: 12px; top: 10px; font-size: 12px; font-weight: 600; color: var(--ink-3); pointer-events: none; }
.mini-open { position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 0; background: var(--raised); box-shadow: var(--shadow-card); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.mini-open:hover { color: var(--brand); }
.link-groups { display: grid; gap: 12px; }
.link-group { display: grid; gap: 6px; }
.link-group h4 { margin: 0; font-size: 12px; font-weight: 600; color: var(--ink-4); }
.link-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.link-chip { display: inline-flex; align-items: center; max-width: 100%; border-radius: var(--r-sm); background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-2); }
.link-chip .ref { max-width: 340px; font-size: 13px; }
.link-chip .x { width: 24px; height: 24px; margin-right: 3px; display: grid; place-items: center; border: 0; border-radius: 4px; background: none; color: var(--ink-4); }
.link-chip .x:hover { color: #b91c1c; background: #fef2f2; }
.concept-chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; border: 0; background: var(--color-accent-2-100); color: var(--color-accent-2-700); font-size: 12px; font-weight: 600; }
.concept-chip:hover { background: #c8e9ff; }
.picker { position: relative; display: grid; gap: 8px; }
.pick-list { list-style: none; margin: 0; padding: 4px; max-height: 240px; overflow: auto; border-radius: var(--r-md); border: 0; background: var(--raised); box-shadow: var(--shadow-pop); }
.pick-list li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--r-sm); font-size: 14px; cursor: pointer; }
.pick-list li:hover { background: var(--color-neutral-100); }
.pick-list li[aria-selected="true"] { background: var(--brand); color: #fff; }
.pick-list li[aria-selected="true"] .sub { color: var(--color-accent-200); }
.pick-list .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.pick-list .sub { font-size: 12px; color: var(--ink-4); white-space: nowrap; }
.muted { color: var(--ink-4); font-size: 14px; margin: 0; }

.c-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.c-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 2px 10px; }
.c-item .av { width: 32px; height: 32px; }
.c-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.c-name { font-weight: 600; font-size: 14px; }
.c-time { font-size: 12px; color: var(--ink-4); }
.c-del { margin-left: auto; font-size: 12px; color: var(--ink-4); }
.c-body { grid-column: 2; margin: 0; padding: 0; font-size: 14px; line-height: 1.6; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: grid; gap: 8px; position: relative; }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hint { font-size: 12px; color: var(--ink-4); }
.h-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.h-list li { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-3); }
.h-list .act-time { padding: 0; }
.d-danger { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 20px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-3); }
.d-meta { margin: 0; font-size: 12px; color: var(--ink-4); }

/* [[ mention list and popovers */
.float-list { position: fixed; z-index: 95; width: min(380px, calc(100vw - 32px)); }
.float-list::before { content: "Link a card"; display: block; padding: 6px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-4); }
.pop {
  position: fixed; z-index: 90; width: min(380px, calc(100vw - 24px)); max-height: min(70vh, 560px); overflow: auto; border-radius: var(--r-lg); padding: 14px;
  background: var(--raised); border: 0; box-shadow: var(--shadow-pop);
}
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 10px; }
.pop-head h3 { margin: 0; font-family: var(--font-display); font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.pop-list { list-style: none; margin: 0 -6px; padding: 0; display: grid; gap: 2px; }
.pop-list li > button { width: 100%; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px; border: 0; border-radius: var(--r-md); background: none; text-align: left; color: var(--ink-3); font-size: 14px; line-height: 1.45; }
.pop-list li > button:hover { background: var(--color-neutral-100); }
.pop-list strong { color: var(--ink); font-weight: 600; }
.pop-list .t { display: block; font-size: 12px; color: var(--ink-4); margin-top: 2px; }

/* search dialog */
.pal-back { position: fixed; inset: 0; z-index: 100; background: rgba(31, 35, 42, 0.4); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: grid; justify-items: center; align-items: start; padding: 12vh 16px 16px; }
.palette { width: min(620px, 100%); border-radius: var(--r-lg); overflow: hidden; background: var(--raised); border: 0; box-shadow: var(--shadow-panel); animation: palIn 0.15s ease-out; }
@keyframes palIn { from { opacity: 0; transform: scale(0.98); } }
.pal-in { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--ink-4); }
.pal-in input { flex: 1; border: 0; outline: none; background: none; font-size: 16px; color: var(--ink); min-width: 0; }
.pal-list { list-style: none; margin: 0; padding: 6px; max-height: min(52vh, 460px); overflow: auto; }
.pal-sec { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-4); }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--r-md); cursor: pointer; }
.pal-item:hover { background: var(--color-neutral-100); }
.pal-item[aria-selected="true"] { background: var(--brand); color: #fff; }
.pal-item[aria-selected="true"] .sub { color: var(--color-accent-200); }
.pal-item[aria-selected="true"] .gi { background: rgba(255, 255, 255, 0.15); color: #fff !important; }
.pal-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.pal-item .sub { font-size: 12px; color: var(--ink-4); white-space: nowrap; }
.pal-item .gi { width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--color-neutral-100); color: var(--ink-3); flex: none; }
.pal-foot { display: flex; gap: 16px; flex-wrap: wrap; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-4); background: var(--color-neutral-50); }

/* toast */
.toast {
  position: fixed; z-index: 120; left: 24px; bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  max-width: min(420px, calc(100vw - 48px)); padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; font-weight: 500;
  background: var(--color-neutral-900); color: #fff; border: 0; box-shadow: var(--shadow-pop); animation: toastIn 0.2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.toast { display: flex; align-items: center; gap: 16px; }
.toast[hidden] { display: none; }
.toast-act { font-size: 14px; padding: 0; color: var(--color-accent-300); background: none; }
.toast-act:hover { color: #fff; background: none; }
.share { width: min(640px, 100%); padding: 0; }
.share-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 10px; }
.share-head .eyebrow { color: var(--brand); }
.share-head h3 { margin: 4px 0 0; font-family: var(--font-display); font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.share textarea { display: block; width: calc(100% - 40px); margin: 0 20px; min-height: 300px; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; }
.share-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 20px 18px; }
.typing { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }
.typing i { display: inline-flex; gap: 3px; }
.typing i b { width: 4px; height: 4px; border-radius: 999px; background: var(--ink-4); animation: bounce 1.2s infinite ease-in-out; }
.typing i b:nth-child(2) { animation-delay: 0.15s; } .typing i b:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* ---------- responsive ---------- */
@container main (max-width: 1240px) {
  .hero { grid-template-columns: 1fr; align-items: start; gap: 20px; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.4fr); }
}
@container main (max-width: 1040px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .note { grid-column: 1 / -1; }
}
@container main (max-width: 700px) {
  .banner { display: grid; grid-template-columns: auto auto 1fr; row-gap: 10px; }
  .banner p { min-width: 0; grid-column: 2 / -1; }
  .banner .btn.primary { grid-column: 2; }
  .banner .btn.ghost { grid-column: 3; justify-self: start; }
  .kpis { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: minmax(160px, 44%); overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 6px; }
  .kpis > * { scroll-snap-align: start; }
  .note { grid-column: auto; min-width: 260px; }
  .status-line { margin-left: 0; width: 100%; }
  .hero h1 { font-size: 28px; }
}
@media (max-width: 860px) {
  .app { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .topbar { margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))); padding: 0 16px; }
  .brand-text .eyebrow { display: none; }
  .search-btn { min-width: 0; width: 36px; padding: 0; justify-content: center; background: none; }
  .search-btn .lbl, .search-btn kbd { display: none; }
  .tab .lbl { display: none; }
  .tabs { gap: 16px; }
  :root { --col-w: min(86vw, 304px); }
  .g-tl { max-width: calc(100% - 32px); }
  .g-tr { top: auto; bottom: 52px; }
  .g-stage { height: clamp(480px, 66vh, 760px); }
  .g-hint { display: none; }
}
@media (max-width: 640px) {
  .drawer { top: calc(env(safe-area-inset-top, 0px) + 40px); left: 0; width: auto; border-left: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .d-grid { grid-template-columns: 1fr; }
  .act-panel { padding: 16px; }
  .act-item { grid-template-columns: 28px minmax(0, 1fr); }
  .act-time { grid-column: 2; padding-top: 0; }
  .act-quote { grid-column: 2; }
  .toast { left: 16px; right: 16px; max-width: none; }
}
/* ---------- workflow planner ---------- */
body.tab-flows .hero, body.tab-flows .banner, body.tab-flows .toolbar { display: none; }
.fl-view { margin-top: 16px; }
.fl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.fl-pick { width: auto; min-width: 200px; max-width: 280px; height: 36px; font-weight: 600; }
.fl-name { flex: 1 1 220px; max-width: 420px; height: 36px; font-family: var(--font-display); font-weight: 700; font-size: 15px; box-shadow: none; background: transparent; }
.fl-name:hover:not([readonly]) { box-shadow: inset 0 0 0 1px var(--line-2); }
.fl-name:focus { box-shadow: inset 0 0 0 2px var(--brand); background: var(--raised); }
#fl-new { margin-left: auto; }
#fl-del.danger { background: var(--red); color: #fff; }
.fl-stage {
  position: relative; height: calc(100vh - var(--top-h, 57px) - 120px); min-height: 460px; border-radius: var(--r-lg); overflow: hidden;
  background-color: var(--color-neutral-50); background-image: radial-gradient(circle, var(--color-neutral-300) 1px, transparent 1.3px);
  box-shadow: inset 0 0 0 1px var(--line);
}
.fl-stage.is-panning, .fl-stage.is-panning .fl-svg { cursor: grabbing; }
.fl-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: default; user-select: none; -webkit-user-select: none; }
.fl-node { cursor: grab; }
.fl-shape { stroke-width: 1.5; transition: stroke-width 0.1s; }
.fl-note .fl-shape { filter: drop-shadow(0 2px 3px rgba(19, 23, 31, 0.15)); }
.fl-node:hover .fl-shape { stroke-width: 2; }
.fl-node.is-sel .fl-shape { stroke: var(--brand); stroke-width: 2.5; }
.fl-note.is-sel .fl-shape { stroke: var(--brand); stroke-width: 2; }
.fl-text { font-family: var(--font-body); pointer-events: none; }
.fl-text.is-empty { font-style: italic; font-weight: 400; }
.fl-handle { fill: #ffffff; stroke: var(--brand); pointer-events: none; }
.fl-handle-hit { fill: transparent; cursor: crosshair; }
.fl-handle-hit:hover + .fl-handle { fill: var(--brand); }
.fl-edge { cursor: pointer; }
.fl-edge-hit { fill: none; stroke: transparent; stroke-width: 16; }
.fl-edge-line { fill: none; stroke: var(--color-neutral-600); stroke-width: 1.75; }
.fl-edge:hover .fl-edge-line { stroke: var(--color-neutral-800); }
.fl-edge.is-sel .fl-edge-line { stroke: var(--brand); stroke-width: 2.25; }
.fl-edge-label rect { fill: #ffffff; stroke: var(--line-2); }
.fl-edge-label text { font-family: var(--font-body); font-size: 12px; font-weight: 500; fill: var(--ink-2); }
.fl-edge-label.is-sel rect { stroke: var(--brand); }
.fl-temp { fill: none; stroke: var(--brand); stroke-width: 2; stroke-dasharray: 6 5; pointer-events: none; }

.fl-tools {
  position: absolute; z-index: 2; left: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 2px; padding: 4px;
  border-radius: var(--r-md); background: var(--raised); box-shadow: var(--shadow-pop);
}
.fl-tool { display: grid; justify-items: center; gap: 2px; width: 64px; padding: 8px 4px 6px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); font-size: 11px; font-weight: 500; }
.fl-tool:hover { background: var(--color-accent-50); color: var(--brand); }
.fl-zoom { position: absolute; z-index: 2; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--raised); box-shadow: var(--shadow-card); }
.fl-zoom-pct { min-width: 56px; height: 36px; border: 0; border-radius: var(--r-sm); background: none; font-size: 13px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fl-zoom-pct:hover { background: var(--color-neutral-100); color: var(--ink); }
.fl-hint { position: absolute; z-index: 1; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: calc(100% - 260px); padding: 5px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.9); box-shadow: var(--shadow-card); font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.fl-pop { position: absolute; z-index: 3; display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: var(--r-md); background: var(--raised); box-shadow: var(--shadow-pop); }
.fl-swatch { width: 26px; height: 26px; border: 0; border-radius: 999px; background: none; display: grid; place-items: center; }
.fl-swatch::before { content: ""; width: 16px; height: 16px; border-radius: 999px; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(19, 23, 31, 0.12); }
.fl-swatch:hover, .fl-swatch.is-on { background: var(--color-neutral-100); }
.fl-swatch.is-on::before { box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--brand); }
.fl-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--line-2); }
.fl-pbtn { display: inline-flex; align-items: center; gap: 6px; height: 30px; min-width: 30px; justify-content: center; padding: 0 6px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.fl-pbtn:hover { background: var(--color-neutral-100); color: var(--ink); }
.fl-pbtn.is-on { background: var(--color-accent-100); color: var(--brand); }
.fl-pbtn.fl-wide { padding: 0 10px; }
.fl-danger:hover { background: #fef2f2; color: #b91c1c; }
.fl-edit {
  position: absolute; z-index: 4; padding: 6px; border: 0; border-radius: var(--r-sm); resize: none; overflow: auto;
  background: rgba(255, 255, 255, 0.96); box-shadow: 0 0 0 2px var(--brand), var(--shadow-pop); color: var(--ink);
  font-family: var(--font-body); font-weight: 600; line-height: 1.3; display: flex;
}
.fl-empty { position: absolute; inset: 0; z-index: 2; display: grid; align-content: center; justify-items: start; gap: 10px; max-width: 420px; margin: 0 auto; padding: 24px; }
.fl-empty h3 { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.fl-empty p { margin: 0 0 6px; color: var(--ink-3); }

/* ---------- hub: brand link, project pages, home ---------- */
a.brand { color: inherit; text-decoration: none; border-radius: var(--r-sm); }
a.brand:hover .project { color: var(--brand); }
body.tab-page .hero, body.tab-page .toolbar { display: none; }
.pg-view { margin-top: 24px; }
.pg-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; padding-bottom: 20px; margin-bottom: 24px; border-bottom: 2px solid var(--ink); }
.pg-head-main { display: grid; gap: 4px; min-width: 0; flex: 1 1 420px; }
.pg-client, .pg-name { border: 0; background: transparent; padding: 2px 6px; margin-left: -6px; border-radius: var(--r-sm); width: 100%; max-width: 720px; }
.pg-client { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand); }
.pg-name { font-family: var(--font-display); font-weight: 800; font-size: 32px; line-height: 1.15; letter-spacing: -0.025em; color: var(--ink); }
.pg-client:hover:not([readonly]), .pg-name:hover:not([readonly]) { background: var(--hover); }
.pg-client:focus, .pg-name:focus { background: var(--raised); box-shadow: inset 0 0 0 2px var(--brand); }
.pg-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.pg-status { appearance: none; -webkit-appearance: none; height: 28px; padding: 0 12px; border: 0; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer; background: var(--color-neutral-100); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.pg-status[data-st="Planning"] { background: var(--color-accent-2-100); color: var(--color-accent-2-700); }
.pg-status[data-st="Active"] { background: #f0fdf4; color: #15803d; box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.25); }
.pg-status[data-st="On hold"] { background: #fffbeb; color: #92400e; box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.25); }
.pg-status:disabled { cursor: default; opacity: 1; }
.pg-eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand); }
.pg-h1 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: -0.025em; }
.pg-lede { margin: 2px 0 0; color: var(--ink-3); max-width: 60ch; }
.pg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 20px; align-items: start; }
.pg-main, .pg-side { display: grid; gap: 16px; min-width: 0; }
.pg-card { background: var(--raised); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-card); min-width: 0; }
.pg-card h2 { margin: 0 0 12px; font-family: var(--font-display); font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.pg-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.pg-card-head h2 { margin: 0; }
.pg-summary { width: 100%; border: 0; resize: vertical; padding: 8px 10px; margin: -8px -10px; border-radius: var(--r-sm); background: transparent; font-size: 15px; line-height: 1.6; color: var(--ink-2); min-height: 72px; }
.pg-summary:hover:not([readonly]) { background: var(--hover); }
.pg-summary:focus { background: var(--raised); box-shadow: inset 0 0 0 2px var(--brand); }
.pg-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pg-actions .hint { margin-right: auto; }
.pg-toolbar { display: flex; gap: 2px; margin-bottom: 6px; }
.pg-tb { width: 32px; height: 30px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-3); font-weight: 700; font-size: 13px; }
.pg-tb:hover { background: var(--color-neutral-100); color: var(--ink); }
.pg-md-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pg-md-input { min-height: 320px; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; }
.pg-md-preview { min-height: 320px; max-height: 60vh; overflow: auto; padding: 10px 14px; border-radius: var(--r-sm); background: var(--color-neutral-50); box-shadow: inset 0 0 0 1px var(--line); }
.md { font-size: 15px; line-height: 1.65; color: var(--ink-2); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { font-family: var(--font-display); color: var(--ink); letter-spacing: -0.015em; margin: 1.2em 0 0.4em; line-height: 1.25; }
.md h1 { font-size: 22px; font-weight: 800; } .md h2 { font-size: 18px; font-weight: 700; } .md h3 { font-size: 15px; font-weight: 700; }
.md p { margin: 0 0 0.8em; }
.md ul, .md ol { margin: 0 0 0.8em; padding-left: 1.4em; }
.md li { margin: 0.2em 0; }
.md li input[type="checkbox"] { margin: 0 6px 0 -1.2em; accent-color: var(--brand); }
.md a { color: var(--brand); font-weight: 500; text-decoration: underline; text-decoration-color: var(--color-accent-300); text-underline-offset: 3px; }
.md a:hover { text-decoration-color: var(--brand); }
.md blockquote { margin: 0 0 0.8em; padding: 4px 14px; border-left: 3px solid var(--color-accent-300); color: var(--ink-3); }
.md code { font-family: var(--font-mono); font-size: 0.88em; padding: 1px 5px; border-radius: 4px; background: var(--color-neutral-100); }
.md pre { padding: 12px; border-radius: var(--r-sm); background: var(--color-neutral-100); overflow: auto; }
.md table { border-collapse: collapse; margin: 0 0 0.8em; font-size: 14px; }
.md th, .md td { padding: 6px 10px; border: 1px solid var(--line-2); text-align: left; }
.md hr { border: 0; border-top: 2px solid var(--ink); margin: 1.2em 0; }
.pg-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.pg-file { display: flex; align-items: center; gap: 10px; padding: 6px; margin: 0 -6px; border-radius: var(--r-md); }
.pg-file:hover { background: var(--hover); }
.pg-kind { flex: none; width: 48px; height: 28px; display: grid; place-items: center; border-radius: var(--r-sm); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; background: var(--color-neutral-100); color: var(--ink-2); }
.pg-kind-doc, .pg-kind-drive { background: var(--color-accent-100); color: var(--color-accent-700); }
.pg-kind-sheet { background: #f0fdf4; color: #15803d; }
.pg-kind-slides { background: #fffbeb; color: #92400e; }
.pg-kind-figma, .pg-kind-canva { background: #f5f3ff; color: #6d28d9; }
.pg-kind-app { background: var(--color-accent-2-100); color: var(--color-accent-2-700); }
.pg-file-main { flex: 1; min-width: 0; display: grid; color: inherit; text-decoration: none; }
.pg-file-title { font-weight: 600; font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-file-main:hover .pg-file-title { color: var(--brand); text-decoration: underline; }
.pg-file-sub { font-size: 12px; color: var(--ink-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-file-acts { display: flex; opacity: 0; transition: opacity 0.15s; }
.pg-file:hover .pg-file-acts, .pg-file:focus-within .pg-file-acts { opacity: 1; }
.pg-file-acts .icon-btn { width: 30px; height: 30px; }
.pg-file-form { display: grid; gap: 8px; margin-bottom: 12px; }
.pg-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pg-stat { display: grid; gap: 2px; padding: 10px; border: 0; border-radius: var(--r-md); background: var(--color-neutral-50); text-align: left; box-shadow: inset 0 0 0 1px var(--line); }
.pg-stat:hover { box-shadow: inset 0 0 0 1px var(--color-accent-300); }
.pg-stat b { font-family: var(--font-display); font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.pg-stat span { font-size: 12px; color: var(--ink-3); }
.pg-latest { display: grid; gap: 4px; width: 100%; margin-top: 12px; padding: 12px; border: 0; border-radius: var(--r-md); background: var(--color-accent-50); text-align: left; box-shadow: inset 0 0 0 1px var(--color-accent-200); }
.pg-latest:hover { box-shadow: inset 0 0 0 1px var(--color-accent-400); }
.pg-latest-k { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--brand); }
.pg-latest-t { font-size: 13px; color: var(--color-accent-800); line-height: 1.5; }
.pg-compose { max-width: 760px; margin-bottom: 20px; }
.pg-compose-row { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; }
.pg-compose-row > .av { width: 32px; height: 32px; }
.pg-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; max-width: 760px; }
.pg-post { display: grid; gap: 12px; }
.pg-post-head { display: flex; align-items: center; gap: 10px; }
.pg-post-head > .av { width: 32px; height: 32px; }
.pg-post-who { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; font-size: 13px; }
.pg-post-who b { font-weight: 600; color: var(--ink); }
.pg-post-who span { color: var(--ink-4); font-size: 12px; }
.pg-post-acts { display: flex; gap: 4px; }
.pg-danger:hover { color: #b91c1c; background: #fef2f2; }
.pg-replies { list-style: none; margin: 0; padding: 12px 0 0; display: grid; gap: 12px; border-top: 1px solid var(--line); }
.pg-reply { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; }
.pg-reply .md { font-size: 14px; }
.pg-reply-box { display: flex; gap: 8px; align-items: flex-end; }
.pg-reply-box textarea { min-height: 36px; resize: none; }

.pg-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 2px solid var(--ink); }
.pg-page-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pg-page-tab { height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--raised); color: var(--ink-2); font-size: 13px; font-weight: 500; box-shadow: inset 0 0 0 1px var(--line-2); }
.pg-page-tab[aria-selected="true"] { background: var(--color-accent-50); color: var(--brand); box-shadow: inset 0 0 0 1px var(--color-accent-300); }
.pg-frame { display: block; width: 100%; height: calc(100dvh - var(--top-h, 57px) - 150px); min-height: 520px; border: 0; border-radius: var(--r-lg); background: #ffffff; box-shadow: var(--shadow-card); }

.hub-main { padding-top: 32px; }
.hub-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 2px solid var(--ink); }
.hub-hero h1 { margin: 6px 0 8px; font-family: var(--font-display); font-weight: 800; font-size: 36px; line-height: 1.05; letter-spacing: -0.03em; }
.hub-hero p { margin: 0; color: var(--ink-3); max-width: 56ch; font-size: 15px; }
.hub-new-form { display: grid; gap: 6px; max-width: 520px; margin-bottom: 24px; }
.hub-new-form h2 { margin-bottom: 6px; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.hub-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: var(--r-lg); background: var(--raised); box-shadow: var(--shadow-card); color: inherit; text-decoration: none; overflow: hidden; transition: box-shadow 0.15s; }
.hub-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--brand); }
.hub-card:hover { box-shadow: var(--shadow-card-hover); }
.hub-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hub-client { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--brand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hub-status { flex: none; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 22px; background: var(--color-neutral-100); color: var(--ink-2); }
.hub-st-planning { background: var(--color-accent-2-100); color: var(--color-accent-2-700); }
.hub-st-active { background: #f0fdf4; color: #15803d; }
.hub-st-hold { background: #fffbeb; color: #92400e; }
.hub-card-name { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.hub-card-sum { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hub-card-update { display: grid; gap: 3px; padding: 10px 12px; border-radius: var(--r-md); background: var(--color-accent-50); font-size: 13px; color: var(--color-accent-800); line-height: 1.45; }
.hub-card-update span:last-child { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hub-k { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--brand); }
.hub-card-foot { margin-top: auto; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-4); padding-top: 4px; }
.hub-open { font-weight: 600; color: var(--brand); }
.hub-recent { margin-top: 36px; }
.hub-recent h2 { margin: 0 0 12px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); font-family: var(--font-display); font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.hub-recent-list { list-style: none; margin: 0; padding: 0; }
.hub-recent-list a { display: grid; grid-template-columns: minmax(120px, 220px) minmax(0, 1fr) auto; gap: 16px; align-items: baseline; padding: 12px 8px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.hub-recent-list a:hover { background: var(--hover); }
.hub-recent-p { font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hub-recent-t { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hub-recent-when { font-size: 12px; color: var(--ink-4); white-space: nowrap; }

@media (max-width: 860px) {
  .pg-grid { grid-template-columns: 1fr; }
  .pg-md-edit { grid-template-columns: 1fr; }
  .pg-md-input, .pg-md-preview { min-height: 200px; }
}
@media (max-width: 640px) {
  #tab-activity { display: none; }
  .pg-frame { height: calc(100dvh - var(--top-h, 57px) - 190px - env(safe-area-inset-bottom, 0px)); min-height: 420px; margin: 0 -16px; width: calc(100% + 32px); border-radius: 0; }
  .tab { font-size: 10px; }
  .pg-view { margin-top: 16px; }
  .pg-name { font-size: 26px; }
  .pg-card { padding: 16px; }
  .pg-file-acts { opacity: 1; }
  .hub-main { padding-top: 20px; }
  .hub-hero h1 { font-size: 30px; }
  .hub-grid { grid-template-columns: 1fr; }
  .hub-recent-list a { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .hub-recent-t { grid-column: 1 / -1; grid-row: 2; white-space: normal; }
  body.hub-home .app { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 32px); }
}

/* ---------- touch devices ---------- */
@media (hover: none) and (pointer: coarse) {
  html { -webkit-tap-highlight-color: transparent; }
  button, .task, .chip, .tab { touch-action: manipulation; }
  /* 16px stops iOS Safari zooming the page when a field gets focus */
  .in, .filter input, .note textarea, .pal-in input, .d-crumbs .in, select.in { font-size: 16px; }
  .grip { width: 36px; height: 36px; margin: -8px -8px -8px 0; opacity: 0.6; }
  .st-btn { position: relative; width: 22px; height: 22px; margin-top: -1px; }
  .st-btn::after { content: ""; position: absolute; inset: -11px; }
  .task-text, .task-answer, .task-meta { margin-left: 32px; }
  .col-del, .link-chip .x { opacity: 1; width: 36px; height: 36px; }
  .chip, .flag, .st-pill { min-height: 36px; }
}

/* ---------- phones (iPhone 16 Pro is 402 x 874) ---------- */
@media (max-width: 640px) {
  .app { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); }

  /* compact one-row header; the tabs move to a bottom bar */
  .topbar { flex-wrap: nowrap; gap: 4px; align-items: center; background: #ffffff; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .brand { padding: 8px 0; gap: 10px; }
  .mark { width: 28px; height: 28px; }
  .brand-text .project { font-size: 15px; }
  .top-actions { padding: 8px 0; gap: 2px; }
  .search-btn, .icon-btn { width: 40px; height: 40px; }
  .tabs {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; gap: 0;
    padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 6px);
    background: rgba(255, 255, 255, 0.92); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--line);
  }
  .tab { flex: 1; flex-direction: column; justify-content: center; gap: 3px; height: 50px; padding: 0; border-radius: var(--r-md); font-size: 11px; font-weight: 600; }
  .tab .lbl { display: block; }
  .tab::after { display: none; }
  .tab:hover { background: none; }
  .tab[aria-current="page"] { background: var(--color-accent-50); }
  .tab .ico svg { width: 22px; height: 22px; }
  .tab .badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; box-shadow: 0 0 0 2px #ffffff; }

  /* page header */
  .hero { margin: 20px 0 16px; padding-bottom: 16px; gap: 16px; }
  .hero h1 { font-size: 26px; margin: 4px 0 6px; }
  .hero p { font-size: 14px; }
  .kpis { margin: 0 -16px; padding: 2px 16px 6px; scroll-padding: 0 16px; grid-auto-columns: minmax(150px, 46%); gap: 10px; scrollbar-width: none; }
  .kpis { align-items: start; }
  .kpi { padding: 12px 14px; }
  .kpi-fig { font-size: 24px; }
  .note { min-width: 82%; }

  /* toolbar: full-width search, filters scroll sideways */
  .toolbar { gap: 10px; }
  .seg { width: 100%; }
  .seg button { flex: 1; justify-content: center; padding: 0 8px; height: 34px; }
  .filter { flex: 1 1 100%; height: 40px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; width: calc(100% + 32px); scrollbar-width: none; }
  .chips::-webkit-scrollbar, .kpis::-webkit-scrollbar, .seg::-webkit-scrollbar { display: none; }
  .chip { flex: none; height: 36px; }

  /* board: one column per screen, swipe between them */
  .board { margin: 0 -16px; padding: 2px 16px 16px; gap: 10px; scroll-snap-type: x mandatory; scroll-padding: 0 16px; }
  :root { --col-w: calc(100vw - 48px); }
  .col { scroll-snap-align: start; }
  .add-col { height: 44px; }

  /* map fills the visible screen between the header and the tab bar */
  body.tab-graph .g-stage, .g-stage { height: calc(100dvh - var(--top-h, 57px) - 150px - env(safe-area-inset-bottom, 0px)); min-height: 420px; }
  .g-tl { top: 12px; left: 12px; }
  .g-title strong { font-size: 15px; }
  .g-tl { right: 12px; max-width: none; }
  .g-legend { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; padding: 2px; margin: -2px; }
  .g-legend::-webkit-scrollbar { display: none; }
  .g-legend .chip { flex: none; height: 30px; font-size: 12px; padding: 0 10px; }
  .g-tr { right: 12px; bottom: 12px; top: auto; }
  .g-tr .icon-btn { width: 40px; height: 40px; }
  .g-panel { left: 12px; right: 12px; width: auto; top: auto; bottom: 68px; max-height: 45%; }

  /* side panel becomes a full sheet */
  .drawer { top: calc(env(safe-area-inset-top, 0px) + 12px); z-index: 60; box-shadow: 0 -8px 30px rgba(19, 23, 31, 0.18); }
  .d-top { padding: 8px 8px 8px 16px; }
  .d-top::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 999px; background: var(--color-neutral-300); }
  .d-top { position: relative; padding-top: 18px; }
  .d-actions .icon-btn { width: 40px; height: 40px; }
  .d-scroll { padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 32px); gap: 20px; }
  .d-title { font-size: 20px; }
  .d-status { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .st-pill { justify-content: center; padding: 0 8px; white-space: nowrap; }
  .composer-row .btn { height: 40px; }

  /* overlays clear the tab bar and the home indicator */
  .toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 80px); }
  .pal-back { padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px 12px; }
  .palette { max-height: calc(100dvh - 120px); display: flex; flex-direction: column; }
  .pal-list { max-height: none; flex: 1; }
  .pal-foot { display: none; }
  .pop { left: 12px !important; right: 12px; width: auto; }
  .act-panel { margin: 0 -4px; }
}

@media (max-width: 640px) {
  .fl-view { margin-top: 12px; }
  .fl-bar { gap: 6px; margin-bottom: 8px; }
  .fl-pick { flex: 1 1 0; min-width: 0; max-width: none; }
  .fl-name { order: 5; flex: 1 1 100%; max-width: none; }
  #fl-new { margin-left: 0; padding: 0 12px; }
  #fl-del .lbl { display: none; }
  .fl-stage { height: calc(100dvh - var(--top-h, 57px) - 200px - env(safe-area-inset-bottom, 0px)); min-height: 380px; margin: 0 -16px; border-radius: 0; box-shadow: none; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .fl-tools { top: 10px; left: 10px; transform: none; flex-direction: row; }
  .fl-tool { width: 44px; height: 44px; padding: 0; place-items: center; }
  .fl-tool span { display: none; }
  .fl-hint { display: none; }
  .fl-zoom { right: 10px; bottom: 10px; }
  .fl-zoom .icon-btn { width: 40px; height: 40px; }
  .fl-pbtn, .fl-swatch { min-width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .st-btn.tick-pop, .palette { animation: none !important; }
  .drawer { transition: opacity 0.15s; transform: none; }
}
