/* ==========================================================================
   PrivCrew Mobile H5 Prototype — Linear-inspired Design System
   ========================================================================== */

/* ---- Design Tokens ---- */
:root {
  /* Neutral / background surfaces (dark-first) */
  --bg-canvas: #08090a;          /* app background */
  --bg-surface: #101113;         /* cards, panels */
  --bg-surface-2: #18191c;       /* raised surface (hover, nested) */
  --bg-elevated: #1f2024;        /* modals, popovers */
  --bg-input: #161719;

  /* Foreground */
  --fg-primary: #f7f8f8;         /* high-emphasis text */
  --fg-secondary: #b4bbc0;       /* medium-emphasis text */
  --fg-tertiary: #8a8f98;        /* low-emphasis text / labels */
  --fg-quaternary: #62666d;      /* placeholders, disabled */

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-focus: #5e6ad2;

  /* Accent — Linear signature indigo/violet */
  --accent: #5e6ad2;
  --accent-hover: #6b77e0;
  --accent-soft: rgba(94, 106, 210, 0.14);
  --accent-fg: #ffffff;

  /* Status palette */
  --status-pending: #8a8f98;        /* 待确认 */
  --status-queued: #f2c94c;         /* 排队 */
  --status-running: #5e6ad2;        /* 执行中 */
  --status-ask: #e5484d;            /* Stop & Ask / 等待反馈 */
  --status-done: #4cb782;           /* 已完成 / merged */
  --status-phase: #57abde;          /* phase 进行中 */
  --status-warn: #f2c94c;           /* 预警 */

  --status-pending-bg: rgba(138, 143, 152, 0.14);
  --status-queued-bg: rgba(242, 201, 76, 0.14);
  --status-running-bg: rgba(94, 106, 210, 0.16);
  --status-ask-bg: rgba(229, 72, 77, 0.14);
  --status-done-bg: rgba(76, 183, 130, 0.14);
  --status-phase-bg: rgba(87, 171, 222, 0.14);

  /* Effects */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--border-strong);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", Consolas, monospace;
}

/* ---- Reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--fg-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

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

a {
  color: inherit;
  text-decoration: none;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ==========================================================================
   Phone Frame — simulates a mobile viewport on desktop preview
   ========================================================================== */
.desktop-stage {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 32px;
  background:
    radial-gradient(1200px 600px at 20% 0%, rgba(94, 106, 210, 0.10), transparent 60%),
    radial-gradient(1000px 500px at 90% 100%, rgba(87, 171, 222, 0.06), transparent 55%),
    var(--bg-canvas);
}

.device {
  position: relative;
  width: 390px;
  height: 844px;
  background: var(--bg-canvas);
  border-radius: 44px;
  box-shadow:
    0 0 0 11px #1c1d20,
    0 0 0 12px #2a2b30,
    var(--shadow-lg);
  overflow: hidden;
  flex-shrink: 0;
}

/* notch */
.device::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 30px;
  background: #000;
  border-radius: 18px;
  z-index: 200;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-canvas);
  overflow: hidden;
}

/* ==========================================================================
   Status bar
   ========================================================================== */
.status-bar {
  position: relative;
  z-index: 150;
  height: 50px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 28px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-primary);
  flex-shrink: 0;
}
.status-bar .sb-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-bar svg {
  display: block;
}

/* ==========================================================================
   App header
   ========================================================================== */
.app-header {
  flex-shrink: 0;
  padding: 6px 16px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
}
.app-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #6b77e0, #8b5cf6);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 8px rgba(94, 106, 210, 0.4);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--fg-secondary);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  position: relative;
}
.icon-btn:hover {
  background: var(--bg-surface-2);
  color: var(--fg-primary);
}
.icon-btn .dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-ask);
  border: 2px solid var(--bg-canvas);
}

/* page title + meta */
.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 2px 0 0;
}
.page-title h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-title .count {
  font-size: 12px;
  color: var(--fg-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Tabs / filter chips
   ========================================================================== */
.tab-bar {
  display: flex;
  gap: 2px;
  padding: 8px 0 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar {
  display: none;
}
.tab {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--fg-tertiary);
  white-space: nowrap;
  transition: all 0.15s var(--ease);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab:hover {
  color: var(--fg-secondary);
  background: var(--bg-surface-2);
}
.tab.active {
  color: var(--fg-primary);
  background: var(--bg-surface-2);
}
.tab .badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  font-size: 11px;
  font-weight: 500;
  display: grid;
  place-items: center;
  color: var(--fg-tertiary);
}
.tab.active .badge {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* ==========================================================================
   Scroll area
   ========================================================================== */
.scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 96px;
}

/* ==========================================================================
   Task card
   ========================================================================== */
.task-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 13px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease),
    transform 0.15s var(--ease);
  position: relative;
  overflow: hidden;
}
.task-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-2);
}
.task-card:active {
  transform: scale(0.99);
}
.task-card.is-ask {
  border-color: rgba(229, 72, 77, 0.4);
  box-shadow: 0 0 0 1px rgba(229, 72, 77, 0.2);
}
.task-card.is-running {
  border-color: rgba(94, 106, 210, 0.35);
}

/* left status rail */
.task-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--status-pending);
  opacity: 0.5;
}
.task-card[data-status="queued"]::before { background: var(--status-queued); opacity: 0.9; }
.task-card[data-status="running"]::before { background: var(--status-running); }
.task-card[data-status="ask"]::before { background: var(--status-ask); }
.task-card[data-status="done"]::before { background: var(--status-done); }

.tc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.tc-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-tertiary);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.tc-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-primary);
  letter-spacing: -0.01em;
  line-height: 1.35;
  margin-bottom: 10px;
  /* clamp 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--fg-tertiary);
}
.tc-meta .sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--fg-quaternary);
}
.tc-agent {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
  color: var(--fg-secondary);
}
.tc-agent .agent-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* status pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}
.pill .pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pill-pending { background: var(--status-pending-bg); color: var(--status-pending); }
.pill-pending .pill-dot { background: var(--status-pending); }
.pill-queued  { background: var(--status-queued-bg);  color: var(--status-queued); }
.pill-queued  .pill-dot { background: var(--status-queued); }
.pill-running { background: var(--status-running-bg); color: var(--accent-hover); }
.pill-running .pill-dot { background: var(--status-running); animation: pulse 1.6s var(--ease) infinite; }
.pill-ask     { background: var(--status-ask-bg);     color: #ff6b70; }
.pill-ask     .pill-dot { background: var(--status-ask); animation: pulse 1.2s var(--ease) infinite; }
.pill-done    { background: var(--status-done-bg);    color: var(--status-done); }
.pill-done    .pill-dot { background: var(--status-done); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  70%  { box-shadow: 0 0 0 4px transparent; opacity: 0.6; }
  100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}

/* phase progress (mini) */
.tc-phase {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.phase-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-input);
  overflow: hidden;
  position: relative;
}
.phase-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  transition: width 0.5s var(--ease-out);
}
.phase-fill.is-ask { background: var(--status-ask); }
.phase-fill.is-done { background: var(--status-done); }
.phase-label {
  font-size: 10.5px;
  color: var(--fg-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* token mini */
.tc-token {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.tc-token.warn { color: var(--status-warn); }

/* ==========================================================================
   Bottom tab navigation
   ========================================================================== */
.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 62px;
  padding-bottom: 12px;
  background: rgba(16, 17, 19, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border-default);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--fg-quaternary);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s var(--ease);
  position: relative;
}
.nav-item svg {
  width: 22px;
  height: 22px;
}
.nav-item.active {
  color: var(--accent-hover);
}
.nav-item .nav-badge {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(8px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--status-ask);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: grid;
  place-items: center;
  border: 2px solid rgba(16, 17, 19, 0.9);
}

/* FAB */
.fab {
  position: absolute;
  right: 16px;
  bottom: 76px;
  z-index: 90;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(94, 106, 210, 0.45);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(94, 106, 210, 0.55); }
.fab:active { transform: scale(0.95); }
.fab svg { width: 22px; height: 22px; }

/* ==========================================================================
   Pages / views
   ========================================================================== */
.view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.view.active {
  display: flex;
  animation: viewIn 0.28s var(--ease-out);
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Detail page
   ========================================================================== */
.detail-header {
  flex-shrink: 0;
  padding: 8px 8px 12px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
}
.back-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--fg-secondary);
}
.back-btn:hover { background: var(--bg-surface-2); color: var(--fg-primary); }
.detail-crumb {
  font-size: 13px;
  color: var(--fg-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Section card */
.section {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  overflow: hidden;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
}
.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.section-body { padding: 4px 14px 12px; }

/* Key-value row */
.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--fg-tertiary); }
.kv .v { color: var(--fg-primary); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kv .v.mono { font-family: var(--font-mono); font-size: 12px; }

/* dependency chips */
.dep-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-secondary);
  margin-right: 4px;
}
.dep-chip.ok { color: var(--status-done); }
.dep-chip.wait { color: var(--status-warn); }

/* ==========================================================================
   6-Phase lifecycle timeline
   ========================================================================== */
.lifecycle {
  position: relative;
  padding: 4px 0 4px 4px;
}
.lc-step {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 16px;
}
.lc-step:last-child { padding-bottom: 4px; }
/* connector */
.lc-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 24px;
  bottom: -4px;
  width: 2px;
  background: var(--border-default);
}
.lc-step.done:not(:last-child)::before { background: var(--status-done); opacity: 0.5; }
.lc-step.active:not(:last-child)::before {
  background: linear-gradient(var(--accent), var(--border-default));
}

.lc-node {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--fg-tertiary);
  border: 2px solid var(--border-default);
  position: relative;
  z-index: 1;
}
.lc-step.done .lc-node {
  background: var(--status-done);
  border-color: var(--status-done);
  color: #04130c;
}
.lc-step.active .lc-node {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulseRing 2s var(--ease) infinite;
}
.lc-step.ask .lc-node {
  background: var(--status-ask);
  border-color: var(--status-ask);
  color: #fff;
}
@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 var(--accent-soft); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.lc-body { flex: 1; min-width: 0; padding-top: 1px; }
.lc-name {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.lc-step.todo .lc-name { color: var(--fg-tertiary); }
.lc-desc {
  font-size: 11.5px;
  color: var(--fg-tertiary);
  margin-top: 2px;
  line-height: 1.45;
}
.lc-meta {
  font-size: 11px;
  color: var(--fg-quaternary);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.lc-step.active .lc-meta { color: var(--accent-hover); }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 1px 2px rgba(94, 106, 210, 0.3);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(94, 106, 210, 0.45); }
.btn-primary:active { transform: translateY(0.5px); }
.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--fg-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover { background: var(--bg-elevated); border-color: var(--border-strong); }
.btn-danger {
  background: rgba(229, 72, 77, 0.14);
  color: #ff6b70;
  border-color: rgba(229, 72, 77, 0.25);
}
.btn-danger:hover { background: rgba(229, 72, 77, 0.22); }
.btn-ghost { color: var(--fg-secondary); }
.btn-ghost:hover { background: var(--bg-surface-2); color: var(--fg-primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* action bar (detail footer) */
.action-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  display: flex;
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(16, 17, 19, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border-default);
}
.action-bar .btn { flex: 1; }

/* ==========================================================================
   Chat / session
   ========================================================================== */
.chat-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 8px;
}
.msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}
.avatar.agent-opencode { background: linear-gradient(135deg, #2d9cdb, #5e6ad2); }
.avatar.agent-cca { background: linear-gradient(135deg, #8b5cf6, #d946ef); }
.avatar.agent-privcrew { background: linear-gradient(135deg, #4cb782, #2d9cdb); }
.avatar.user { background: var(--bg-elevated); color: var(--fg-secondary); border: 1px solid var(--border-strong); }
.bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-primary);
}
.msg.user .bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.bubble .meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--fg-tertiary);
  margin-bottom: 3px;
}
.msg.user .bubble .meta { color: rgba(255,255,255,0.8); }
.bubble .meta .name { font-weight: 600; color: var(--fg-secondary); }
.msg.user .bubble .meta .name { color: #fff; }
.bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 4px;
}
.bubble pre {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: rgba(0,0,0,0.3);
  padding: 8px 10px;
  border-radius: 6px;
  margin: 6px 0;
  overflow-x: auto;
  color: var(--fg-secondary);
  border: 1px solid var(--border-subtle);
}

/* ask banner */
.ask-banner {
  background: linear-gradient(135deg, rgba(229,72,77,0.12), rgba(229,72,77,0.04));
  border: 1px solid rgba(229,72,77,0.3);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.ask-banner-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: #ff6b70;
  margin-bottom: 6px;
}
.ask-banner-head svg { width: 15px; height: 15px; }
.ask-banner-body {
  font-size: 13px;
  color: var(--fg-secondary);
  line-height: 1.5;
}
.ask-hardstop {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: #ff6b70;
  background: rgba(229,72,77,0.16);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* composer */
.composer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  padding: 10px 12px 12px;
  background: rgba(16,17,19,0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border-default);
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 6px 6px 6px 12px;
  transition: border-color 0.15s var(--ease);
}
.composer-row:focus-within { border-color: var(--border-focus); }
.composer textarea {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  color: var(--fg-primary);
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  max-height: 96px;
  padding: 5px 0;
}
.composer textarea::placeholder { color: var(--fg-quaternary); }
.send-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s var(--ease), opacity 0.15s;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: var(--bg-elevated); color: var(--fg-quaternary); cursor: not-allowed; }
.send-btn svg { width: 16px; height: 16px; }
.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  font-size: 11px;
  color: var(--fg-tertiary);
}
.composer-tools .ct-tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
}
.composer-tools svg { width: 12px; height: 12px; }

/* ==========================================================================
   Stop & Ask panel
   ========================================================================== */
.ask-hero {
  margin: 4px 12px 10px;
  background: var(--bg-surface);
  border: 1px solid rgba(229,72,77,0.35);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.ask-hero::after {
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(229,72,77,0.18), transparent 70%);
  pointer-events: none;
}
.ask-hero-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(229,72,77,0.16);
  display: grid;
  place-items: center;
  color: #ff6b70;
  margin-bottom: 10px;
}
.ask-hero-icon svg { width: 22px; height: 22px; }
.ask-hero h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.ask-hero p {
  font-size: 12.5px;
  color: var(--fg-secondary);
  line-height: 1.5;
}
.ask-hero .task-ref {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-secondary);
}

/* quick-reply suggestions */
.suggest-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.suggest {
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  font-size: 13px;
  color: var(--fg-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s var(--ease);
}
.suggest:hover { border-color: var(--accent); background: var(--bg-surface-2); color: var(--fg-primary); }
.suggest svg { width: 15px; height: 15px; color: var(--accent-hover); flex-shrink: 0; }

/* ==========================================================================
   Modal / sheet
   ========================================================================== */
.sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.sheet-overlay.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 310;
  background: var(--bg-surface);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border: 1px solid var(--border-strong);
  border-bottom: none;
  padding: 8px 16px 20px;
  transform: translateY(100%);
  transition: transform 0.3s var(--ease-out);
  max-height: 80%;
  overflow-y: auto;
}
.sheet.show { transform: translateY(0); }
.sheet-grip {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  margin: 4px auto 12px;
}
.sheet-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  text-align: center;
}

/* option list (select) */
.opt-list { display: flex; flex-direction: column; gap: 4px; }
.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  transition: all 0.15s var(--ease);
}
.opt:hover { border-color: var(--border-strong); }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt-main { display: flex; align-items: center; gap: 10px; }
.opt-icon {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.opt-text .opt-name { font-size: 13px; font-weight: 500; }
.opt-text .opt-sub { font-size: 11px; color: var(--fg-tertiary); margin-top: 1px; }
.opt-check {
  width: 18px; height: 18px;
  color: var(--accent-hover);
}
.opt-check.hidden { visibility: hidden; }

/* form field */
.field { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-secondary);
  margin-bottom: 6px;
}
.field-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--fg-primary);
  outline: none;
  transition: border-color 0.15s var(--ease);
}
.field-control:focus { border-color: var(--border-focus); }
.field-control::placeholder { color: var(--fg-quaternary); }
textarea.field-control { resize: vertical; min-height: 72px; line-height: 1.5; }

/* segmented control */
.segment {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.segment button {
  flex: 1;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-tertiary);
  transition: all 0.15s var(--ease);
}
.segment button.active {
  background: var(--bg-elevated);
  color: var(--fg-primary);
  box-shadow: var(--shadow-sm);
}

/* import dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 16px;
  text-align: center;
  background: var(--bg-surface);
  transition: all 0.15s var(--ease);
}
.dropzone:hover { border-color: var(--accent); background: var(--bg-surface-2); }
.dropzone-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent-hover);
  display: grid; place-items: center;
  margin: 0 auto 10px;
}
.dropzone-icon svg { width: 22px; height: 22px; }
.dropzone-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.dropzone-sub { font-size: 12px; color: var(--fg-tertiary); }

/* stats / overview blocks */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.stat {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 12px;
}
.stat .stat-label {
  font-size: 11px;
  color: var(--fg-tertiary);
  margin-bottom: 4px;
}
.stat .stat-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .stat-trend {
  font-size: 11px;
  color: var(--fg-tertiary);
  margin-top: 2px;
}

/* progress bar (budget) */
.budget {
  margin-top: 4px;
}
.budget-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--fg-tertiary);
  margin-bottom: 5px;
}
.budget-row .used.warn { color: var(--status-warn); }
.budget-row .used.over { color: #ff6b70; }
.budget-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-input);
  overflow: hidden;
}
.budget-bar > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--status-done);
  transition: width 0.5s var(--ease-out);
}
.budget-bar > span.warn { background: var(--status-warn); }
.budget-bar > span.over { background: var(--status-ask); }

/* empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--fg-tertiary);
}
.empty-icon {
  width: 56px; height: 56px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  display: grid; place-items: center;
  margin: 0 auto 14px;
  color: var(--fg-quaternary);
}
.empty h3 { font-size: 15px; color: var(--fg-secondary); margin-bottom: 4px; font-weight: 500; }
.empty p { font-size: 13px; }

/* toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  z-index: 400;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--fg-primary);
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s var(--ease-out);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 14px; height: 14px; color: var(--status-done); }

/* preview sidebar (desktop) */
.preview-meta {
  width: 280px;
  color: var(--fg-secondary);
  font-size: 13px;
}
.preview-meta h2 {
  font-size: 18px;
  color: var(--fg-primary);
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.preview-meta p { line-height: 1.6; color: var(--fg-tertiary); margin-bottom: 18px; }
.preview-meta .pm-list { list-style: none; }
.preview-meta .pm-list li {
  padding: 8px 0;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--fg-tertiary);
}
.preview-meta .pm-list li:first-child { border-top: none; }
.preview-meta .pm-list b { color: var(--fg-primary); font-weight: 500; }
.preview-meta .pm-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
}

/* hide-on-mobile bits */
.desktop-only { display: block; }

/* ==========================================================================
   CD-G · Project switcher (header)
   ========================================================================== */
.project-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
  max-width: 200px;
}
.project-switcher:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}
.ps-mark {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
}
.ps-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  overflow: hidden;
}
.ps-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ps-sub {
  font-size: 10px;
  color: var(--fg-tertiary);
  font-family: var(--font-mono);
}
.ps-chev { color: var(--fg-tertiary); flex-shrink: 0; }

/* avatar chip in header */
.avatar-btn { width: auto; padding: 3px; }
.avatar-chip {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
}

/* ==========================================================================
   CD-G · Login view
   ========================================================================== */
.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 28px 120px;
  background:
    radial-gradient(400px 300px at 50% 0%, rgba(94, 106, 210, 0.18), transparent 70%),
    var(--bg-canvas);
}
.login-hero {
  text-align: center;
  margin-bottom: 32px;
}
.login-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #5e6ad2, #8b5cf6);
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 14px;
  box-shadow: 0 8px 24px rgba(94, 106, 210, 0.45);
}
.login-hero h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.login-hero p {
  font-size: 13px;
  color: var(--fg-tertiary);
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.login-error {
  font-size: 12px;
  color: #ff6b70;
  min-height: 16px;
  margin-top: 2px;
}
.login-hint {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--fg-tertiary);
}

/* ==========================================================================
   CD-G · Profile view
   ========================================================================== */
.profile-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 16px 16px;
  text-align: center;
}
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  margin-bottom: 12px;
  box-shadow: 0 6px 18px rgba(94, 106, 210, 0.4);
}
.profile-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.profile-handle {
  font-size: 13px;
  color: var(--fg-tertiary);
  margin-top: 2px;
  font-family: var(--font-mono);
}

/* ==========================================================================
   CD-G · Project list items (in sheet / profile)
   ========================================================================== */
.proj-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-default);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  width: 100%;
  text-align: left;
}
.proj-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}
.proj-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.proj-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.proj-body { flex: 1; min-width: 0; }
.proj-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.proj-path {
  font-size: 11px;
  color: var(--fg-tertiary);
  font-family: var(--font-mono);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proj-meta {
  font-size: 11px;
  color: var(--fg-quaternary);
  margin-top: 3px;
}
.proj-check {
  width: 18px;
  height: 18px;
  color: var(--accent-hover);
  flex-shrink: 0;
}

/* path input (add project = bind folder) */
.path-input-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}
.path-input-wrap .field-control { flex: 1; }
.browse-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  display: grid;
  place-items: center;
  color: var(--fg-secondary);
  transition: all 0.15s var(--ease);
}
.browse-btn:hover { border-color: var(--accent); color: var(--accent-hover); }

@media (max-width: 720px) {
  .desktop-stage {
    display: block;
    padding: 0;
    background: var(--bg-canvas);
  }
  .device {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .device::before { display: none; }
  .status-bar { padding-top: env(safe-area-inset-top); height: calc(50px + env(safe-area-inset-top)); }
  .preview-meta { display: none; }
  .desktop-only { display: none; }
}
