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

:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --header:    #0f172a;
  --primary:   #6366f1;
  --primary-h: #4f46e5;
  --text:      #1e293b;
  --muted:     #64748b;
  --border:    #e2e8f0;
  --radius:    10px;
  --sh:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --sh-md:     0 4px 12px rgba(0,0,0,.10);
  --sh-lg:     0 12px 32px rgba(0,0,0,.15);

  --c-ns:  #94a3b8;  /* not_started     */
  --c-ip:  #3b82f6;  /* in_progress     */
  --c-na:  #f59e0b;  /* needs_attention */
  --c-bl:  #ef4444;  /* blocked         */
  --c-cp:  #10b981;  /* complete        */

  --c-low:  #94a3b8;
  --c-med:  #3b82f6;
  --c-hi:   #f59e0b;
  --c-crit: #ef4444;

  --panel-w: 460px;
  --header-h: 60px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Toasts ──────────────────────────────────────────────────────────────── */
#toasts {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: 8px; font-size: 13px; font-weight: 500;
  box-shadow: var(--sh-md); animation: slideIn .2s ease;
  max-width: 300px;
}
.toast-success { background: #10b981; color: white; }
.toast-error   { background: #ef4444; color: white; }
.toast-info    { background: #3b82f6; color: white; }
@keyframes slideIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--header);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.header-left { display: flex; align-items: center; gap: 14px; }
.logo { display: flex; align-items: center; gap: 10px; color: #f8fafc; font-size: 17px; font-weight: 700; letter-spacing: -.3px; }

.live-indicator {
  width: 8px; height: 8px; border-radius: 50%; background: #64748b;
  transition: background .3s;
}
.live-indicator.connected { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.25); }
.live-indicator.error     { background: #ef4444; }

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

.search-wrap {
  position: relative; display: flex; align-items: center;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; padding: 0 10px; gap: 8px; width: 220px;
  transition: background .2s, width .3s;
}
.search-wrap:focus-within { background: rgba(255,255,255,.18); width: 280px; }
.search-icon { color: #94a3b8; flex-shrink: 0; }
.search-wrap input {
  background: none; border: none; outline: none; color: #f8fafc;
  font-size: 13px; width: 100%; padding: 7px 0;
}
.search-wrap input::placeholder { color: #94a3b8; }
.search-clear {
  background: none; border: none; color: #94a3b8; cursor: pointer;
  font-size: 11px; padding: 2px 4px; display: none;
}
.search-clear.visible { display: block; }

.user-info { display: flex; align-items: center; gap: 10px; }
.user-name  { font-size: 13px; color: #94a3b8; font-weight: 500; }
.btn-logout {
  padding: 6px 12px; border-radius: 7px;
  border: 1px solid rgba(255,255,255,.12);
  background: transparent; color: #94a3b8; font-size: 12px;
  cursor: pointer; transition: all .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.08); color: #f8fafc; }

.btn-primary {
  background: var(--primary); color: white; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--primary-h); }
.btn-primary:active { transform: scale(.97); }

/* ── Stats Bar ───────────────────────────────────────────────────────────── */
.stats-bar {
  display: flex; gap: 0; background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; overflow-x: auto;
}
.stat-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 16px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: border-color .15s;
  font-size: 13px;
}
.stat-chip:hover { border-bottom-color: var(--border); }
.stat-chip.active { border-bottom-color: var(--primary); }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; }
.stat-count { font-weight: 700; font-size: 15px; color: var(--text); }
.stat-label { color: var(--muted); }

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  padding: 5px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.pill:hover { background: var(--bg); color: var(--text); }
.pill.active { background: var(--primary); color: white; border-color: var(--primary); }

.sort-wrap { display: flex; align-items: center; gap: 8px; }
.sort-wrap label { font-size: 12px; color: var(--muted); font-weight: 500; }
.sort-wrap select {
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px;
  font-size: 12px; background: var(--surface); color: var(--text); cursor: pointer; outline: none;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.empty {
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 80px 24px; text-align: center;
}
.empty.visible { display: flex; }
.empty-icon { font-size: 48px; }
.empty h3 { font-size: 18px; color: var(--text); }
.empty p  { color: var(--muted); font-size: 14px; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--sh); border: 1px solid var(--border);
  border-left: 4px solid var(--c-ns);
  display: flex; flex-direction: column;
  cursor: pointer; transition: transform .15s, box-shadow .15s;
  overflow: hidden;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }

.card[data-status="not_started"]    { border-left-color: var(--c-ns); }
.card[data-status="in_progress"]    { border-left-color: var(--c-ip); }
.card[data-status="needs_attention"]{ border-left-color: var(--c-na); }
.card[data-status="blocked"]        { border-left-color: var(--c-bl); }
.card[data-status="complete"]       { border-left-color: var(--c-cp); }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; padding: 14px 14px 0; gap: 8px; }
.card-badges { display: flex; gap: 6px; flex-shrink: 0; }

.card-name { font-size: 15px; font-weight: 700; color: var(--text); padding: 6px 14px 0; line-height: 1.3; }
.card-desc {
  font-size: 12px; color: var(--muted); padding: 4px 14px 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.card-progress { padding: 10px 14px 0; }
.card-prog-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.card-prog-label { font-size: 11px; color: var(--muted); }

.prog-track { height: 5px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.prog-fill  { height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s ease; }
.prog-fill.done { background: var(--c-cp); }

.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 12px; margin-top: auto; gap: 8px;
}
.card-due { font-size: 11px; color: var(--muted); }
.card-due.overdue { color: var(--c-bl); font-weight: 600; }
.card-updated { font-size: 11px; color: var(--muted); }

.card-status-sel {
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px;
  font-size: 11px; font-weight: 600; cursor: pointer; outline: none;
  background: var(--surface); transition: border-color .15s;
}
.card-status-sel:hover { border-color: var(--primary); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.sbadge, .pbadge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  white-space: nowrap; letter-spacing: .2px;
}
.sbadge[data-v="not_started"]    { background: #f1f5f9; color: var(--c-ns); }
.sbadge[data-v="in_progress"]    { background: #eff6ff; color: var(--c-ip); }
.sbadge[data-v="needs_attention"]{ background: #fffbeb; color: #b45309; }
.sbadge[data-v="blocked"]        { background: #fef2f2; color: var(--c-bl); }
.sbadge[data-v="complete"]       { background: #f0fdf4; color: var(--c-cp); }

.pbadge[data-v="low"]    { background: #f1f5f9; color: var(--c-low); }
.pbadge[data-v="medium"] { background: #eff6ff; color: var(--c-med); }
.pbadge[data-v="high"]   { background: #fffbeb; color: #b45309; }
.pbadge[data-v="critical"]{ background: #fef2f2; color: var(--c-crit); }

.due-badge {
  display: none; align-items: center;
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: #fef2f2; color: var(--c-bl);
}
.due-badge.visible { display: inline-flex; }

/* ── Detail Panel ────────────────────────────────────────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 200; backdrop-filter: blur(2px);
}
.overlay.visible { display: block; }

.panel {
  position: fixed; top: 0; right: -520px; width: var(--panel-w);
  height: 100vh; background: var(--surface); z-index: 201;
  display: flex; flex-direction: column;
  box-shadow: var(--sh-lg);
  transition: right .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.panel.open { right: 0; }

.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 20px 14px; gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.panel-title-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.panel-title-group h2 { font-size: 18px; font-weight: 800; color: var(--text); line-height: 1.3; }
.panel-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.panel-actions {
  display: flex; gap: 8px; padding: 12px 20px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}

.panel-body { flex: 1; overflow-y: auto; padding: 0 20px 24px; }

.psec { padding: 16px 0; border-bottom: 1px solid var(--border); }
.psec:last-child { border-bottom: none; }
.psec-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 8px; }
.psec-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.task-meta { font-size: 12px; color: var(--muted); }

.panel-desc { font-size: 14px; color: var(--text); line-height: 1.6; white-space: pre-wrap; }
.panel-due  { font-size: 14px; color: var(--text); }
.panel-due.overdue { color: var(--c-bl); font-weight: 600; }

/* ── Task List ───────────────────────────────────────────────────────────── */
.task-list { list-style: none; display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px; background: var(--bg);
  transition: background .15s;
}
.task-item:hover { background: #e9eef5; }
.task-item input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); flex-shrink: 0; }
.task-text { flex: 1; font-size: 13px; color: var(--text); }
.task-text.done { text-decoration: line-through; color: var(--muted); }
.task-del {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 13px; padding: 2px 5px; border-radius: 4px; opacity: 0;
  transition: opacity .15s, color .15s;
}
.task-item:hover .task-del { opacity: 1; }
.task-del:hover { color: var(--c-bl); }

/* ── Activity ────────────────────────────────────────────────────────────── */
.activity { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.act-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 10px; border-radius: 7px; background: var(--bg);
}
.act-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 4px;
}
.act-dot.created  { background: var(--c-cp); }
.act-dot.update   { background: var(--c-ip); }
.act-dot.task     { background: var(--primary); }
.act-dot.note     { background: var(--c-na); }
.act-dot.webhook  { background: #8b5cf6; }
.act-dot.default  { background: var(--muted); }
.act-body { flex: 1; min-width: 0; }
.act-msg  { font-size: 12px; color: var(--text); line-height: 1.4; }
.act-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Shared inputs/buttons ───────────────────────────────────────────────── */
.input-row {
  display: flex; gap: 8px;
  margin-top: 6px;
}
.input-row input, .input-row textarea {
  flex: 1; border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 10px; font-size: 13px; outline: none; background: var(--surface);
  transition: border-color .15s;
}
.input-row input:focus, .input-row textarea:focus { border-color: var(--primary); }

textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 7px;
  padding: 8px 10px; font-size: 13px; resize: vertical; outline: none;
  font-family: inherit; background: var(--surface); color: var(--text);
  transition: border-color .15s;
}
textarea:focus { border-color: var(--primary); }

.btn-sm {
  padding: 7px 14px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all .15s;
}
.btn-sm:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }

.btn-sec {
  padding: 7px 14px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.btn-sec:hover { background: var(--bg); }

.btn-danger {
  padding: 7px 14px; border-radius: 7px; border: 1px solid #fecaca;
  background: #fef2f2; color: var(--c-bl); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.btn-danger:hover { background: #fee2e2; }

.btn-icon {
  width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.close-btn { font-size: 16px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-bg {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 300; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal-bg.open { display: flex; }

.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--sh-lg);
  width: 100%; max-width: 520px; max-height: 90vh;
  display: flex; flex-direction: column;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(.96) translateY(8px); } to { opacity:1; transform:none; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; font-weight: 700; }

.modal-body { padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: 7px;
  padding: 8px 10px; font-size: 13px; outline: none; background: var(--surface);
  font-family: inherit; color: var(--text); transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.req { color: var(--c-bl); }

.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 20px 18px; border-top: 1px solid var(--border);
}

/* ── Phase Tracker ───────────────────────────────────────────────────────── */
.phase-tracker {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.phase-tracker-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.phase-advance-btn {
  font-size: 11px; font-weight: 600; color: var(--primary);
  background: none; border: 1px solid var(--primary);
  border-radius: 5px; padding: 3px 8px; cursor: pointer;
  transition: all .15s;
}
.phase-advance-btn:hover { background: var(--primary); color: white; }
.phase-steps {
  display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px;
}
.phase-step {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  flex: 1; min-width: 48px; cursor: pointer;
  padding: 6px 4px; border-radius: 8px; transition: background .15s;
  position: relative;
}
.phase-step:hover { background: #e2e8f0; }
.phase-step.active { background: #eef2ff; }
.phase-step.done   { opacity: .7; }
.phase-step-icon {
  font-size: 16px; line-height: 1;
}
.phase-step-num {
  font-size: 9px; font-weight: 700; color: var(--muted);
}
.phase-step-name {
  font-size: 9px; color: var(--muted); text-align: center;
  line-height: 1.2; white-space: normal;
}
.phase-step.active .phase-step-num,
.phase-step.active .phase-step-name { color: var(--primary); }
.phase-step.active .phase-step-icon { filter: none; }
.phase-step::after {
  content: '';
  position: absolute; bottom: -2px; left: 50%; transform: translateX(-50%);
  width: 0; height: 2px; background: var(--primary); border-radius: 99px;
  transition: width .2s;
}
.phase-step.active::after { width: 70%; }

/* ── Phase Modal ─────────────────────────────────────────────────────────── */
.phase-modal-context {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px;
  font-size: 12px; color: var(--muted); line-height: 1.5;
  margin-bottom: 14px;
}
.phase-result {
  display: none; margin-top: 14px;
  border: 1px solid #c7d2fe; border-radius: 8px;
  background: #eef2ff; padding: 14px;
}
.phase-result.visible { display: block; }
.phase-result h4 {
  font-size: 12px; font-weight: 700; color: var(--primary);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px;
}
.phase-result-item {
  display: flex; gap: 8px; margin-bottom: 6px; font-size: 13px;
}
.phase-result-key {
  font-weight: 600; color: var(--text); min-width: 120px; flex-shrink: 0;
}
.phase-result-val { color: var(--muted); line-height: 1.6; }
.phase-nested-list {
  list-style: none; padding: 0; margin: 4px 0 0 0;
  display: flex; flex-direction: column; gap: 6px;
}
.phase-nested-list li {
  padding: 6px 10px; background: rgba(99,102,241,.06);
  border-left: 2px solid #c7d2fe; border-radius: 0 6px 6px 0;
  font-size: 12px; line-height: 1.5;
}
.phase-nested-key { font-weight: 600; color: var(--text); }

/* ── AI Intake Button ────────────────────────────────────────────────────── */
.btn-intake {
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid rgba(139,92,246,.4);
  background: rgba(139,92,246,.1); color: #c4b5fd;
  font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: all .15s;
}
.btn-intake:hover { background: rgba(139,92,246,.2); color: #ddd6fe; }

.intake-mic-row {
  display: flex; align-items: center; gap: 10px; margin-top: 4px;
}
.intake-mic-label { font-size: 12px; color: var(--muted); }

.intake-loading {
  display: none; align-items: center; gap: 10px;
  margin-top: 12px; font-size: 13px; color: var(--muted);
}
.intake-loading.visible { display: flex; }

/* ── Delete Confirm ─────────────────────────────────────────────────────── */
.delete-files-check {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 14px; cursor: pointer;
  font-size: 13px; color: var(--text); line-height: 1.5;
}
.delete-files-check input[type=checkbox] {
  margin-top: 2px; width: 15px; height: 15px; flex-shrink: 0;
  accent-color: #ef4444; cursor: pointer;
}
.delete-files-warn {
  margin-top: 10px; padding: 10px 12px;
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 8px; font-size: 12px; color: #dc2626; line-height: 1.5;
}
.delete-files-warn code {
  font-family: 'SF Mono','Consolas',monospace; font-size: 11px;
  background: rgba(220,38,38,.1); padding: 1px 5px; border-radius: 4px;
}

/* ── Project Files ───────────────────────────────────────────────────────── */
.folder-path {
  font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
  font-size: 12px; color: var(--primary);
  background: #eef2ff; border: 1px solid #c7d2fe;
  border-radius: 6px; padding: 6px 10px; margin-bottom: 8px;
  word-break: break-all; line-height: 1.4;
}
.file-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.file-chip {
  font-size: 12px; padding: 4px 10px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--muted); font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
}

/* ── Claude Button ───────────────────────────────────────────────────────── */
.btn-claude {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 8px;
  border: 1px solid rgba(99,102,241,.4);
  background: rgba(99,102,241,.12); color: #a5b4fc;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s; white-space: nowrap; position: relative;
}
.btn-claude:hover { background: rgba(99,102,241,.22); color: #c7d2fe; }
.claude-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #475569; transition: background .3s;
}
.claude-dot.active {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,.25);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16,185,129,.25); }
  50%       { box-shadow: 0 0 0 6px rgba(16,185,129,.08); }
}

/* ── Claude Status Bar ────────────────────────────────────────────────────── */
.claude-status-bar {
  display: none; align-items: center; gap: 10px;
  background: linear-gradient(90deg, #1e1b4b, #1e293b);
  border-bottom: 1px solid rgba(99,102,241,.3);
  padding: 7px 24px; font-size: 12px; color: #a5b4fc; font-weight: 500;
}
.claude-status-bar.visible { display: flex; }
.claude-spinner {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(99,102,241,.3);
  border-top-color: #6366f1;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Claude Panel ─────────────────────────────────────────────────────────── */
.claude-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 200; backdrop-filter: blur(2px);
}
.claude-overlay.visible { display: block; }

.claude-panel {
  position: fixed; top: 0; left: -500px; width: 460px;
  height: 100vh; background: var(--surface); z-index: 201;
  display: flex; flex-direction: column;
  box-shadow: var(--sh-lg);
  transition: left .28s cubic-bezier(.4,0,.2,1);
}
.claude-panel.open { left: 0; }

.claude-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; gap: 12px;
  border-bottom: 1px solid var(--border);
  background: #0f172a; flex-shrink: 0;
}
.claude-panel-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; color: #f8fafc;
}
.claude-panel-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #475569; transition: background .3s; margin-left: 2px;
}
.claude-panel-dot.active {
  background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.25);
  animation: pulse 1.5s infinite;
}
.claude-panel-controls {
  display: flex; align-items: center; gap: 8px;
}
.claude-panel-controls select {
  font-size: 12px; border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px; background: rgba(255,255,255,.08);
  color: #94a3b8; padding: 5px 8px; outline: none; max-width: 160px;
}
.claude-panel-controls select:focus { border-color: #6366f1; }

.claude-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.claude-welcome {
  text-align: center; padding: 32px 16px; color: var(--muted);
  font-size: 13px; line-height: 1.6;
}

.claude-msg { display: flex; flex-direction: column; gap: 4px; }
.claude-msg.user { align-items: flex-end; }
.claude-msg.assistant { align-items: flex-start; }

.claude-bubble {
  max-width: 88%; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.claude-msg.user .claude-bubble {
  background: var(--primary); color: white;
  border-bottom-right-radius: 4px;
}
.claude-msg.assistant .claude-bubble {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-bottom-left-radius: 4px; font-family: 'SF Mono','Consolas',monospace; font-size: 12px;
}
.claude-bubble.streaming::after {
  content: '▋'; animation: blink .7s step-end infinite; color: var(--primary);
}
@keyframes blink { 50% { opacity: 0; } }

.claude-msg-time { font-size: 10px; color: var(--muted); padding: 0 4px; }

.claude-error {
  background: #fef2f2; border: 1px solid #fecaca;
  color: #dc2626; border-radius: 8px; padding: 10px 14px;
  font-size: 12px; line-height: 1.5;
}

.claude-input-area {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px; border-top: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.claude-input-area textarea {
  resize: none; font-size: 13px; min-height: 72px;
}
.claude-input-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.claude-input-area .btn-primary {
  padding: 8px 20px;
}
.claude-input-area .btn-primary:disabled {
  background: #334155; color: #64748b; cursor: not-allowed; transform: none;
}
.btn-mic {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.btn-mic:hover { background: var(--bg); color: var(--text); border-color: var(--primary); }
.btn-mic.listening {
  background: #fef2f2; border-color: #ef4444; color: #ef4444;
  animation: mic-pulse 1s ease-in-out infinite;
}
.btn-mic:disabled { opacity: .4; cursor: not-allowed; }
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.3); }
  50%       { box-shadow: 0 0 0 6px rgba(239,68,68,.0); }
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  header { padding: 0 14px; }
  main   { padding: 14px; }
  .search-wrap { width: 160px; }
  .search-wrap:focus-within { width: 190px; }
  .toolbar { padding: 8px 14px; }
  .stats-bar { padding: 0 14px; }
  .panel { width: 100%; }
  --panel-w: 100%;
  .claude-panel { width: 100%; }
  .btn-claude span:first-of-type { display: none; }
}
