/* =====================================================================
   樂積 AI 辦公室 · AI Brick Office
   原創積木玩具風 2.5D 等角辦公室 — 樣式表
   ===================================================================== */

:root {
  /* 基礎色板：溫暖積木盒感 */
  --bg-1: #fdf6ec;
  --bg-2: #f4e9d8;
  --ink-1: #33313b;
  --ink-2: #6b6776;
  --ink-3: #98939f;
  --card: #fffcf6;
  --line: #e7dccb;
  --line-2: #d8cbb5;
  --shadow: 0 10px 24px rgba(97, 78, 50, .12);
  --shadow-soft: 0 4px 12px rgba(97, 78, 50, .08);
  --radius: 16px;
  --radius-s: 10px;

  /* 部門色 */
  --c-product: #ff7a59;
  --c-dev: #3f8cff;
  --c-design: #ffc53d;
  --c-ops: #3cbf7c;
  --c-research: #9b6bff;
  --c-it: #536bdf;
  --c-sales: #ee6c8a;
  --c-finance: #d69b22;
  --c-support: #28a7a1;

  /* 狀態色 */
  --s-idle: #9aa7b5;
  --s-working: #2fae6e;
  --s-meeting: #e9a23b;
  --s-blocked: #e5484d;

  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink-1);
  background:
    radial-gradient(circle at 15% 8%, rgba(255, 197, 61, .16), transparent 42%),
    radial-gradient(circle at 85% 12%, rgba(63, 140, 255, .12), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(60, 191, 124, .10), transparent 45%),
    linear-gradient(170deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  min-height: 100vh;
}

/* 積木顆粒背景 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(120, 96, 60, .07) 1.6px, transparent 1.8px);
  background-size: 26px 26px;
  z-index: 0;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- 無障礙工具類 ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 99;
  background: var(--ink-1); color: #fff;
  padding: 10px 16px; border-radius: 0 0 12px 12px;
  text-decoration: none; transition: top .18s ease;
}
.skip-link:focus { top: 0; }

:focus-visible { outline: 3px solid #2f6fed; outline-offset: 2px; border-radius: 6px; }

/* =====================================================================
   整體骨架
   ===================================================================== */
.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 18px 20px 120px;
  gap: 16px;
  max-width: 1560px;
  margin: 0 auto;
}

/* =====================================================================
   頂部列
   ===================================================================== */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 14px 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 14px);
  gap: 3px;
  padding: 6px;
  background: var(--ink-1);
  border-radius: 10px;
}
.brick { width: 14px; height: 14px; border-radius: 4px; }
.brick-a { background: var(--c-dev); }
.brick-b { background: var(--c-design); }
.brick-c { background: var(--c-product); grid-column: span 2; height: 10px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 17px; letter-spacing: .5px; }
.brand-text small { color: var(--ink-3); font-size: 11.5px; }

/* ---------- KPI ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}
.kpi {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label value" "hint value";
  align-items: center;
  column-gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--card) 76%, #fff);
  border: 1px solid var(--line);
  border-top: 3px solid var(--kpi-accent, var(--line-2));
}
.kpi-run   { --kpi-accent: var(--s-working); }
.kpi-task  { --kpi-accent: var(--c-dev); }
.kpi-done  { --kpi-accent: var(--c-design); }
.kpi-alert { --kpi-accent: var(--s-blocked); }

.kpi-label { grid-area: label; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.kpi-hint  { grid-area: hint; font-size: 10.5px; color: var(--ink-3); }
.kpi-value {
  grid-area: value;
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--kpi-accent);
  min-width: 2ch;
  text-align: right;
}
.kpi-alert.has-alert .kpi-value { animation: pulse-num 1.6s ease-in-out infinite; }

.topbar-actions { display: flex; gap: 10px; }

/* ---------- 算力控制台 ---------- */
.compute-console, .governance, .meeting-center {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-soft); padding: 16px 18px;
}
.compute-heading, .governance-head, .meeting-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.compute-heading h2, .governance-head h2, .meeting-head h2 { margin: 2px 0 0; font-size: 16px; }
.eyebrow { margin: 0; color: var(--c-dev); font-size: 10.5px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.connection-badge, .owner-badge { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 7px 11px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.connection-badge { color: #8a5b00; background: #fff5d8; border: 1px solid #edcf7c; }
.connection-badge i, .runtime-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--s-meeting); display: inline-block; }
.owner-badge { color: #fff; background: var(--ink-1); }
.compute-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; margin-top: 12px; }
.compute-stat { display: grid; gap: 2px; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf8; }
.compute-stat span, .compute-stat small { color: var(--ink-3); font-size: 10.5px; }
.compute-stat strong { overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.truth-note { margin: 10px 0 0; color: var(--ink-2); font-size: 11px; line-height: 1.6; }

/* ---------- 會議室與記錄 ---------- */
.meeting-count { color: var(--ink-2); font-size: 11.5px; }
.meeting-count strong { color: var(--ink-1); font-size: 16px; }
.meeting-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.room-grid { display: grid; align-content: start; gap: 9px; }
.room-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 11px; padding: 11px; background: #fffdf8; }
.room-floor { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; color: #fff; background: var(--ink-1); font-size: 11px; font-weight: 900; }
.room-card div { display: grid; gap: 2px; min-width: 0; }
.room-card strong { font-size: 12px; }
.room-card small { color: var(--ink-3); font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-state { color: var(--s-working); font-size: 10px; font-style: normal; font-weight: 800; white-space: nowrap; }
.meeting-records { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; max-height: 430px; overflow-y: auto; padding-right: 3px; }
.meeting-record { border: 1px solid var(--line); border-left: 4px solid var(--meeting-color); border-radius: 11px; padding: 11px 12px; background: #fffdf8; }
.meeting-record.is-live { box-shadow: 0 0 0 2px color-mix(in srgb, var(--meeting-color) 18%, transparent); }
.meeting-record-head { display: flex; justify-content: space-between; gap: 8px; }
.meeting-dept { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); font-size: 10px; font-weight: 800; }
.meeting-dept i { width: 7px; height: 7px; border-radius: 2px; }
.meeting-status { color: var(--s-working); font-size: 10px; font-weight: 800; }
.meeting-record.is-live .meeting-status { color: var(--s-meeting); }
.meeting-record h3 { margin: 6px 0 3px; font-size: 13px; }
.meeting-meta { margin: 0 0 8px; color: var(--ink-3); font-size: 10px; line-height: 1.5; }
.meeting-record dl { display: grid; gap: 4px; margin: 0; }
.meeting-record dl > div { display: grid; grid-template-columns: 34px 1fr; gap: 6px; font-size: 10.5px; line-height: 1.45; }
.meeting-record dt { color: var(--ink-3); }
.meeting-record dd { margin: 0; }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-2);
  background: var(--card);
  border-radius: 12px;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(97, 78, 50, .14);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn-primary {
  background: linear-gradient(180deg, #4d90ff, #2f6fed);
  border-color: #2a5fc9;
  color: #fff;
}
.btn-ghost[aria-pressed="false"] { background: #fff3e0; border-color: #e5c795; }
.btn-icon { font-size: 12px; }
.btn-badge {
  min-width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--s-blocked);
  color: #fff;
  font-size: 11px;
  padding: 0 5px;
}
.btn-badge:empty, .btn-badge[data-zero="true"] { display: none; }

.btn-danger {
  background: color-mix(in srgb, var(--s-blocked) 12%, #fff);
  border-color: color-mix(in srgb, var(--s-blocked) 45%, #fff);
  color: #b3262c;
}
.btn-mini {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 9px;
}
.btn-close {
  border: 1px solid var(--line);
  background: var(--card);
  width: 32px; height: 32px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-2);
  transition: background .15s ease;
}
.btn-close:hover { background: #f6ede0; }

/* =====================================================================
   主區：地圖 + 面板
   ===================================================================== */
.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
  flex: 1;
}

.stage {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px 18px 12px;
  min-width: 0;
}

.stage-head { margin-bottom: 6px; }
.stage-title { margin: 0 0 4px; font-size: 19px; }
.stage-sub { margin: 0; font-size: 13px; color: var(--ink-2); }
.stage-sub em { font-style: normal; color: #2f6fed; font-weight: 700; }

.map-wrap { overflow: hidden; border-radius: 12px; }

#office-map {
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
}

/* ---------- 地圖內 SVG 元素 ---------- */
.tile-top { stroke: rgba(90, 70, 40, .14); stroke-width: 1; }

.desk-shadow, .prop-shadow, .emp-shadow { fill: rgba(80, 60, 35, .16); }

.zone-label {
  font-family: var(--font);
  font-weight: 800;
  font-size: 15px;
  fill: var(--ink-2);
  letter-spacing: 2px;
  pointer-events: none;
}
.zone-label-bg { fill: rgba(255, 252, 246, .82); stroke: var(--line); }

/* 員工群組 */
.emp { cursor: pointer; }
.emp .emp-name {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  fill: var(--ink-1);
  paint-order: stroke;
  stroke: rgba(255, 252, 246, .9);
  stroke-width: 3px;
  pointer-events: none;
}
.emp .focus-ring {
  fill: none;
  stroke: #2f6fed;
  stroke-width: 3;
  stroke-dasharray: 6 5;
  opacity: 0;
  transition: opacity .15s ease;
}
.emp:focus { outline: none; }
.emp:focus .focus-ring { opacity: 1; }
.emp.is-selected .focus-ring {
  opacity: 1;
  stroke: var(--ink-1);
  stroke-dasharray: none;
  stroke-width: 2.5;
}

.emp-fig { transform-box: fill-box; transform-origin: 50% 100%; }

/* 狀態徽章 */
.badge-bg { stroke: #fff; stroke-width: 1.6; }
.badge-glyph { fill: #fff; font-family: var(--font); font-size: 11px; font-weight: 800; text-anchor: middle; }

/* 進度環 */
.ring-bg { fill: none; stroke: rgba(60, 45, 25, .18); stroke-width: 4; }
.ring-fg { fill: none; stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }

/* 狀態動畫（克制） */
.emp-state-idle .emp-fig { animation: bob 3.4s ease-in-out infinite; }
.emp-state-working .emp-fig { animation: work-nod 1.7s ease-in-out infinite; }
.emp-state-meeting .emp-fig { animation: bob 2.8s ease-in-out infinite .3s; }
.emp-state-blocked .badge-wrap { animation: wiggle 2.2s ease-in-out infinite; }
.emp-state-blocked .emp-fig { animation: slump 3s ease-in-out infinite; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2.4px); } }
@keyframes work-nod { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(1.2px) rotate(-1.2deg); } }
@keyframes slump { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(1.6px); } }
@keyframes wiggle { 0%, 92%, 100% { transform: rotate(0); } 94% { transform: rotate(-7deg); } 96% { transform: rotate(6deg); } 98% { transform: rotate(-3deg); } }
@keyframes pulse-num { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* 會議中的氣泡 */
.chat-bubble { fill: #fff; stroke: var(--line-2); }
.chat-tail { fill: #fff; stroke: var(--line-2); }

/* ---------- 圖例 ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  border-top: 1px dashed var(--line-2);
  margin-top: 10px;
  padding-top: 10px;
  font-size: 12px;
  color: var(--ink-2);
}
.legend-title { font-weight: 800; color: var(--ink-1); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-sep { width: 1px; height: 16px; background: var(--line-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-idle { background: var(--s-idle); }
.dot-working { background: var(--s-working); }
.dot-meeting { background: var(--s-meeting); }
.dot-blocked { background: var(--s-blocked); }
.swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.swatch-product { background: var(--c-product); }
.swatch-dev { background: var(--c-dev); }
.swatch-design { background: var(--c-design); }
.swatch-ops { background: var(--c-ops); }
.swatch-research { background: var(--c-research); }
.swatch-it { background: var(--c-it); }
.swatch-sales { background: var(--c-sales); }
.swatch-finance { background: var(--c-finance); }
.swatch-support { background: var(--c-support); }

/* =====================================================================
   3D 場景檢視器（Three.js · WebGL，失敗一律降級回 SVG 地圖）
   ===================================================================== */
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.view-bar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 12px; margin: 10px 0;
}

/* 3D / SVG 切換的積木感分段控件 */
.view-switch {
  display: inline-flex; gap: 4px; padding: 4px;
  background: #f3ead9; border: 1px solid var(--line); border-radius: 13px;
}
.view-switch .btn {
  border: none; background: transparent; box-shadow: none;
  padding: 7px 16px; border-radius: 9px; color: var(--ink-2);
}
.view-switch .btn:hover { transform: none; background: #ece0c9; color: var(--ink-1); }
.view-switch .btn.is-active,
.view-switch .btn.is-active:hover { background: var(--ink-1); color: #fff; }
.view-switch .btn:disabled { opacity: .45; }

/* 舞台顯示規則：SVG 預設、WebGL 可用時才由 scene3d.js 切到 3D */
.stage[data-view="svg"] .office-3d { display: none; }
.stage[data-view="3d"] .map-wrap { display: none; }

.office-3d {
  position: relative;
  height: clamp(300px, 56vh, 540px);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(rgba(120, 96, 60, .06) 1.6px, transparent 1.8px) 0 0 / 26px 26px,
    linear-gradient(165deg, #f8eedb, #efe1c6);
  cursor: grab;
}
.office-3d:active { cursor: grabbing; }
.office-3d canvas { display: block; width: 100%; height: 100%; }
.office-3d:focus-visible { outline: 3px solid #2f6fed; outline-offset: 2px; border-radius: 12px; }

.office-3d-status {
  display: none; align-items: center; gap: 8px;
  margin: 0 0 8px; font-size: 12.5px; line-height: 1.6; color: var(--ink-2);
}
.stage[data-view="3d"] .office-3d-status { display: flex; }
.office-3d-status[data-state="error"] { display: flex; color: #b3262c; }
.office-3d-status:empty { display: none; }
.office-3d-status[data-state="loading"]::before {
  content: ""; flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line-2); border-top-color: var(--c-dev);
  animation: scene3d-spin .9s linear infinite;
}
.office-3d-status[data-state="ready"] { color: var(--ink-3); }
.office-3d-status[data-state="ready"]::before { content: "✓"; color: var(--s-working); }
.office-3d-status[data-state="error"]::before { content: "⚠"; }
@keyframes scene3d-spin { to { transform: rotate(360deg); } }

/* 小螢幕：3D 視窗矮一點，讓地圖與任務抽屜仍可滑動 */
@media (max-width: 720px) {
  .view-bar { gap: 6px 8px; }
  .view-switch { width: 100%; }
  .view-switch .btn { flex: 1; justify-content: center; }
  .office-3d { height: clamp(240px, 46vh, 430px); border-radius: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .office-3d-status[data-state="loading"]::before { animation: none; }
  .office-3d, .view-switch .btn { transition: none; }
}

/* =====================================================================
   右側詳情面板
   ===================================================================== */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
}
.panel:focus { outline: none; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-title { margin: 0; font-size: 16px; }

.panel-body { padding: 16px; overflow-y: auto; }
.panel-empty { color: var(--ink-3); font-size: 13px; line-height: 1.7; margin: 0; }

.emp-card { display: grid; gap: 14px; }

.emp-id-row { display: flex; align-items: center; gap: 12px; }
.emp-avatar { flex: 0 0 auto; border-radius: 12px; background: #fbf3e3; }
.emp-id-text { min-width: 0; }
.emp-name-lg { margin: 0; font-size: 17px; font-weight: 800; }
.emp-role { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-2); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 800; color: #fff;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; opacity: .9; }
.pill-idle { background: var(--s-idle); }
.pill-working { background: var(--s-working); }
.pill-meeting { background: var(--s-meeting); }
.pill-blocked { background: var(--s-blocked); }

.dept-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-2);
  background: #fff;
}
.dept-chip i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.panel-section { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fffdf8; }
.panel-section h3 { margin: 0 0 8px; font-size: 13px; color: var(--ink-2); }
.agent-runtime dl { display: grid; gap: 6px; margin: 0; }
.agent-runtime dl > div { display: grid; grid-template-columns: 82px 1fr; gap: 8px; font-size: 11.5px; }
.agent-runtime dt { color: var(--ink-3); }
.agent-runtime dd { margin: 0; font-weight: 700; }
.agent-runtime .runtime-dot { margin-right: 6px; }
.access-note { margin: 10px 0 0; padding-top: 9px; border-top: 1px dashed var(--line-2); color: var(--ink-2); font-size: 11.5px; line-height: 1.55; }
.access-note strong { display: block; color: var(--ink-1); margin-bottom: 2px; }

/* ---------- 權限矩陣 ---------- */
.governance { margin-bottom: 8px; }
.permission-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 12px; }
.permission-grid article { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fffdf8; }
.permission-grid strong { font-size: 12.5px; }
.permission-grid p { margin: 4px 0; color: var(--ink-2); font-size: 11.5px; }
.permission-grid small { color: #9a5c22; font-size: 10.5px; }

.task-now { font-size: 14px; font-weight: 700; margin: 0 0 8px; }
.task-now.is-none { color: var(--ink-3); font-weight: 500; }
.block-reason { margin: 8px 0 0; font-size: 12px; color: #b3262c; background: color-mix(in srgb, var(--s-blocked) 10%, #fff); border: 1px dashed color-mix(in srgb, var(--s-blocked) 40%, #fff); border-radius: 8px; padding: 8px 10px; }

/* 進度條 */
.progress { display: flex; align-items: center; gap: 10px; }
.progress-track {
  flex: 1; height: 12px; border-radius: 6px;
  background: #ece1cd;
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 6px;
  background: repeating-linear-gradient(45deg, var(--pf, #2fae6e), var(--pf, #2fae6e) 8px, color-mix(in srgb, var(--pf, #2fae6e) 78%, #fff) 8px, color-mix(in srgb, var(--pf, #2fae6e) 78%, #fff) 16px);
  transition: width .6s ease;
}
.progress-num { font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 4ch; text-align: right; }

/* 面板內活動紀錄 */
.mini-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 220px; overflow-y: auto; }
.mini-log li { display: grid; grid-template-columns: 58px 1fr; gap: 8px; font-size: 12px; line-height: 1.55; }
.mini-log time { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.mini-log .kind { font-weight: 700; }
.kind-task { color: #2f6fed; }
.kind-status { color: var(--s-meeting); }
.kind-done { color: var(--s-working); }
.kind-alert { color: var(--s-blocked); }
.kind-user { color: var(--c-research); }

/* 派工表單 */
.assign-form { display: grid; gap: 8px; }
.assign-form textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  line-height: 1.6;
}
.assign-form textarea:focus { outline: 3px solid #2f6fed33; border-color: #2f6fed; }
.assign-form .row { display: flex; gap: 8px; justify-content: flex-end; }

/* =====================================================================
   任務抽屜 / 看板
   ===================================================================== */
.drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  margin: 0 auto;
  max-width: 1560px;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 30px rgba(97, 78, 50, .16);
  transform: translateY(calc(100% - 52px));
  transition: transform .28s cubic-bezier(.2, .8, .3, 1);
  display: flex;
  flex-direction: column;
  max-height: min(62vh, 560px);
}
.drawer[data-open="true"] { transform: translateY(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
  flex: 0 0 auto;
}
.drawer.is-dragging, .drawer-head { cursor: default; }
.drawer-title { margin: 0; font-size: 15.5px; display: flex; align-items: baseline; gap: 10px; }
.drawer-sub { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.drawer-toggle { flex: 0 0 auto; }
.drawer[data-open="false"] .drawer-toggle { transform: rotate(180deg); }

.drawer-body {
  padding: 14px 18px 18px;
  display: grid;
  gap: 12px;
  overflow: hidden;
  min-height: 0;
}

.task-form { display: flex; gap: 10px; flex-wrap: wrap; }
.task-form input[type="text"] {
  flex: 1 1 260px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 10px 13px;
  background: #fff;
}
.task-form input[type="text"]:focus { outline: 3px solid #2f6fed33; border-color: #2f6fed; }
.task-form select {
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-2);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.tab:hover { background: #f7efdf; }
.tab.is-active { background: var(--ink-1); border-color: var(--ink-1); color: #fff; }
.tab-count {
  background: #ece1cd; color: var(--ink-2);
  border-radius: 999px; padding: 1px 8px;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.tab.is-active .tab-count { background: rgba(255, 255, 255, .22); color: #fff; }

.drawer-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr);
  gap: 16px;
  min-height: 0;
  flex: 1;
}

.task-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  overflow-y: auto;
  align-content: start;
  padding: 2px;
}

.task-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--tc, var(--line-2));
  border-radius: 12px;
  background: #fffdf8;
  padding: 12px 13px;
  display: grid;
  gap: 8px;
  box-shadow: var(--shadow-soft);
}
.task-card.is-new { animation: card-in .35s ease; }
@keyframes card-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.task-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-status {
  font-size: 10.5px; font-weight: 800;
  padding: 3px 8px; border-radius: 999px; color: #fff;
  white-space: nowrap;
}
.ts-pending { background: var(--s-idle); }
.ts-running { background: var(--s-working); }
.ts-blocked { background: var(--s-blocked); }
.ts-done { background: #8a8f98; }
.task-owner { font-size: 11px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.task-owner i { width: 8px; height: 8px; border-radius: 2.5px; display: inline-block; }
.task-name { margin: 0; font-size: 13.5px; font-weight: 700; line-height: 1.5; word-break: break-word; }
.task-meta { font-size: 11px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.badge-mine {
  background: color-mix(in srgb, var(--c-research) 14%, #fff);
  color: #6b3fd4;
  border: 1px solid color-mix(in srgb, var(--c-research) 40%, #fff);
  border-radius: 999px; padding: 1px 8px; font-weight: 700;
}
.task-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.task-empty { color: var(--ink-3); font-size: 13px; padding: 18px 6px; grid-column: 1 / -1; }

/* ---------- 活動時間軸 ---------- */
.col-title { margin: 0 0 8px; font-size: 13.5px; }
.timeline {
  list-style: none;
  margin: 0; padding: 2px 10px 2px 2px;
  overflow-y: auto;
  border-left: 3px solid var(--line);
  display: grid; gap: 12px;
  min-height: 0;
}
.timeline li { position: relative; font-size: 12.5px; line-height: 1.6; padding-left: 16px; animation: fade-in .35s ease; }
.timeline li::before {
  content: "";
  position: absolute; left: -11px; top: 7px;
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--tl, var(--s-idle));
  border: 2px solid var(--card);
}
.timeline time { display: block; color: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.timeline .tl-kind { font-weight: 800; margin-right: 6px; }
@keyframes fade-in { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }

/* =====================================================================
   Toast 通知
   ===================================================================== */
.toasts {
  position: fixed;
  right: 18px; bottom: 96px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(330px, calc(100vw - 36px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--ink-1);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  box-shadow: var(--shadow);
  animation: toast-in .3s cubic-bezier(.2, .8, .3, 1);
  font-size: 13px;
  line-height: 1.55;
}
.toast.leaving { animation: toast-out .3s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
.toast-icon { font-size: 15px; line-height: 1.4; }
.toast-ok .toast-icon { color: #7de2ab; }
.toast-warn .toast-icon { color: #ffcf6e; }
.toast-alert .toast-icon { color: #ff9296; }
.toast-info .toast-icon { color: #9cc4ff; }
.toast .toast-close {
  background: none; border: none; color: #ffffff99;
  cursor: pointer; font-size: 13px; padding: 0;
}
.toast .toast-close:hover { color: #fff; }

/* =====================================================================
   響應式
   ===================================================================== */
@media (max-width: 1120px) {
  .topbar { grid-template-columns: 1fr auto; grid-template-rows: auto auto; }
  .kpis { grid-column: 1 / -1; grid-row: 2; }
  .compute-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 960px) {
  .app-shell { padding: 12px 12px 130px; }

  .main { grid-template-columns: 1fr; }

  .panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    z-index: 50;
    width: min(380px, 92vw);
    max-height: none;
    border-radius: 18px 0 0 18px;
    transform: translateX(105%);
    transition: transform .28s cubic-bezier(.2, .8, .3, 1);
    box-shadow: -14px 0 34px rgba(97, 78, 50, .22);
    border-right: none;
  }
  .panel.is-open { transform: translateX(0); }

  .drawer { max-height: min(74vh, 620px); }
  .drawer-columns { grid-template-columns: 1fr; }
  .timeline { max-height: 160px; }
  .permission-grid { grid-template-columns: repeat(2, 1fr); }
  .meeting-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .brand { justify-content: space-between; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .topbar-actions .btn { flex: 1; justify-content: center; }
  .compute-heading, .governance-head, .meeting-head { align-items: flex-start; flex-direction: column; }
  .compute-grid, .permission-grid { grid-template-columns: 1fr; }
  .meeting-records { grid-template-columns: 1fr; max-height: none; }

  .stage { padding: 12px 10px 8px; }
  .stage-title { font-size: 16px; }
  .stage-sub { font-size: 12px; }

  .legend { font-size: 11px; gap: 4px 10px; }

  .task-form { flex-direction: column; }
  .task-form select { width: 100%; }
  .task-form .btn { width: 100%; justify-content: center; }

  .toasts { bottom: 110px; }
}

@media (max-width: 420px) {
  .kpi-value { font-size: 21px; }
  .kpi { padding: 8px 10px; }
  .brand-text small { display: none; }
}

/* =====================================================================
   減少動態偏好
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .emp-fig, .badge-wrap { animation: none !important; }
  .drawer { transition: none; }
  .panel { transition: none; }
}
