/* ── Andy Chat – Styles ── */

/* ── Self-hosted Inter font ── */
@font-face { font-family: 'Inter'; src: url('/fonts/inter-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

/* ── Boot stagger ── */
@keyframes bootFadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
#app.app-boot #header { animation: bootFadeUp 0.28s var(--ease-out); }
#app.app-boot #tab-bar { animation: bootFadeUp 0.28s var(--ease-out) 0.12s both; }

/* ── View fade-in on tab switch ── */
@keyframes viewFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes viewEnterFromRight {
  from { opacity: 0; transform: translateX(3%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes viewEnterFromLeft {
  from { opacity: 0; transform: translateX(-3%); }
  to   { opacity: 1; transform: translateX(0); }
}
.view-enter-right {
  animation: viewEnterFromRight 0.2s var(--ease-out) both !important;
}
.view-enter-left {
  animation: viewEnterFromLeft 0.2s var(--ease-out) both !important;
}
#app.command-mode #command-view:not(.view-enter-left):not(.view-enter-right)  { animation: viewFadeIn 0.18s ease-out; }
#app.finance-mode #finance-view:not(.view-enter-left):not(.view-enter-right)  { animation: viewFadeIn 0.18s ease-out; }
#app.marketing-mode #marketing-view:not(.view-enter-left):not(.view-enter-right) { animation: viewFadeIn 0.18s ease-out; }
#app.more-mode #more-view:not(.view-enter-left):not(.view-enter-right)        { animation: viewFadeIn 0.18s ease-out; }

/* ── Code block language label ── */
.code-lang-label {
  position: absolute;
  top: 10px;
  right: 44px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  font-family: var(--font-mono);
  user-select: none;
  pointer-events: none;
  opacity: 0.7;
}

/* ── Sonar ping on CC badge ── */
@keyframes sonarPing {
  0%   { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0.7); }
  70%  { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0); }
}
.tab-bar-badge.sonar-ping {
  animation: sonarPing 0.6s ease-out;
}

/* ── Command Palette ── */
.cmd-palette {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: max(80px, calc(env(safe-area-inset-top) + 60px));
}
.cmd-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.cmd-palette-modal {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 16px;
  background: #1f1f23;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
  overflow: hidden;
  animation: cmdPaletteIn 0.18s var(--ease-out);
}
@keyframes cmdPaletteIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.cmd-palette-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cmd-palette-search-icon { color: var(--text-dim); flex-shrink: 0; }
#cmd-palette-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}
#cmd-palette-input::placeholder { color: var(--text-dim); }
.cmd-palette-esc {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}
.cmd-palette-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}
.cmd-palette-results::-webkit-scrollbar { display: none; }
.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.cmd-palette-item:hover,
.cmd-palette-item.cmd-selected {
  background: var(--bg-surface);
}
.cmd-palette-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.cmd-palette-item-text { flex: 1; min-width: 0; }
.cmd-palette-item-label { font-size: 15px; font-weight: 500; color: var(--text); }
.cmd-palette-item-desc  { font-size: 13px; color: var(--text-muted); margin-top: 1px; }
.cmd-palette-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Tokens ── */
:root {
  --bg:             #09090b;
  --bg-secondary:   #111113;
  --bg-tertiary:    #18181b;
  --bg-surface:     #111113;
  --bg-elevated:    #1f1f23;
  --text:           #e8eaed;
  --text-secondary: #b8bcc4;
  --text-muted:     #8a8f98;
  --text-dim:       #6b7280;
  --accent:         #3b82f6;
  --accent-hover:   #60a5fa;
  --accent-muted:   rgba(59, 130, 246, 0.5);
  --accent-subtle:  rgba(59, 130, 246, 0.08);
  --accent-glow:    rgba(59, 130, 246, 0.15);
  --success:        #22c55e;
  --error:          #ef4444;
  --care-blue:      #2693D1;
  --border:         rgba(255, 255, 255, 0.07);
  --border-subtle:  rgba(255, 255, 255, 0.04);
  --border-focus:   rgba(59, 130, 246, 0.4);
  --tool-bg:        rgba(255, 255, 255, 0.02);
  --tool-border:    rgba(255, 255, 255, 0.06);
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --shadow-lg:      0 8px 32px rgba(0, 0, 0, 0.4);
  --duration-fast:   0.15s;
  --duration-normal: 0.25s;
  --ease-out:       cubic-bezier(0.32, 0.72, 0, 1);
  --font-mono:      'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

/* ── Global resets ── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: rgba(59, 130, 246, 0.12);
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

/* ── Login ── */
#login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
}

#login .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

#login .brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

#login h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

#login .subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 32px;
}

#login input {
  width: 100%;
  max-width: 320px;
  padding: 14px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 16px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color var(--duration-normal);
}

#login input:focus {
  border-color: var(--border-focus);
}

#login button {
  padding: 12px 32px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

#login button:hover {
  background: var(--accent-hover);
}

#login button:active {
  transform: scale(0.97);
}

#login .error {
  color: var(--error);
  font-size: 14px;
  margin-top: 12px;
  min-height: 20px;
}

/* ── App layout ── */
#app {
  display: none;
  flex-direction: column;
  height: 100%;
  position: relative;
  touch-action: pan-y; /* allow vertical scroll, prevent browser horizontal pan so swipe gestures get user activation */
  background-image: radial-gradient(ellipse 900px 500px at 50% 0%, rgba(59, 130, 246, 0.04), transparent);
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(9, 9, 11, 0.88);
  backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  min-height: 48px;
}

@supports (padding-top: env(safe-area-inset-top)) {
  #header {
    padding-top: calc(8px + env(safe-area-inset-top));
  }
}

#dual-clock {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  padding: 0 4px;
  line-height: 1.3;
  text-align: right;
  font-weight: 500;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

.header-view-title {
  flex: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  padding: 0 8px;
}

.header-menu {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.header-menu:hover { color: var(--text); background: var(--bg-tertiary); }

#header .header-title {
  display: none;
}

/* ── Bottom actions toolbar ── */
#bottom-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px 0;
}

#bottom-actions button {
  padding: 10px 14px;
  min-height: 44px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#bottom-actions button:hover {
  color: var(--text);
  background: var(--bg-tertiary);
  border-color: rgba(255, 255, 255, 0.12);
}

#bottom-actions button:active {
  transform: scale(0.97);
  transition-duration: 0.06s;
  background: var(--bg-surface);
}

#bottom-actions button.active {
  color: var(--accent);
  border-color: var(--accent-muted);
  background: var(--accent-subtle);
}

/* ── Chat area ── */
#chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px;
  scroll-behavior: smooth;
  background: var(--bg);
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-y: contain;
}

#chat::-webkit-scrollbar {
  display: none;
}

@media (min-width: 768px) {
  #chat { padding: 24px 10%; }
}

@media (min-width: 1200px) {
  #chat { padding: 24px 18%; }
}

.message {
  max-width: 88%;
  margin-bottom: 24px;
  animation: messageIn var(--duration-normal) var(--ease-out);
}

.message.assistant {
  max-width: 100%;
}

.message.assistant + .message.user {
  margin-top: 32px;
}

.message.user + .message.assistant {
  margin-top: 12px;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(4px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.user {
  margin-left: auto;
}

.message .bubble {
  padding: 14px 18px;
  border-radius: 20px 20px 6px 20px;
  background: var(--bg-surface);
  font-size: 16px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.assistant .bubble {
  background: var(--bg-secondary);
  border: none;
  padding: 14px 18px;
  border-radius: 16px 16px 16px 4px;
}

.message .time {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.message:hover .time,
.message.time-visible .time {
  opacity: 1;
}

.message.user .time {
  text-align: right;
  justify-content: flex-end;
}

/* ── BTW message styling ── */
.message.user.btw .bubble {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.btw-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(59, 130, 246, 0.7);
  margin-right: 8px;
  vertical-align: middle;
}

/* BTW mode send button */
#send-btn.btw-mode {
  opacity: 0.7;
  position: relative;
}

/* ── Message copy button ── */
.msg-copy-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast);
  opacity: 0;
}

.message:hover .msg-copy-btn,
.msg-copy-btn.copied {
  opacity: 1;
}

.msg-copy-btn:hover {
  color: var(--accent);
  background: var(--accent-subtle);
}

.msg-copy-btn:active {
  transform: scale(0.9);
}

.msg-copy-btn.copied {
  color: var(--success, #4ade80);
}

/* ── TTS button ── */
.tts-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 32px;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast);
}

.tts-btn:hover {
  color: var(--accent);
  background: var(--accent-subtle);
}

.tts-btn:active {
  transform: scale(0.93);
}

.tts-btn.playing {
  color: var(--accent);
}

/* ── Bubble typography ── */
.bubble h1 { font-size: 1.4em; font-weight: 700; margin: 18px 0 10px; letter-spacing: -0.04em; }
.bubble h2 { font-size: 1.25em; font-weight: 650; margin: 16px 0 8px; letter-spacing: -0.03em; }
.bubble h3 { font-size: 1.12em; font-weight: 600; margin: 14px 0 6px; letter-spacing: -0.02em; }
.bubble h4 { font-size: 1em; font-weight: 600; margin: 12px 0 4px; letter-spacing: -0.01em; }
.bubble p { margin: 8px 0; }
.bubble ul, .bubble ol { padding-left: 20px; margin: 8px 0; }
.bubble li { margin: 3px 0; }
.bubble li[data-level="1"] { margin-left: 18px; }
.bubble li[data-level="2"] { margin-left: 36px; }
.bubble li[data-level="3"] { margin-left: 54px; }
.bubble pre {
  position: relative;
  background: rgba(0, 0, 0, 0.3);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.55;
  margin: 10px 0;
  border: 1px solid var(--border-subtle);
}
.bubble code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}
.bubble pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}
.bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 14px;
}
.bubble th, .bubble td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.bubble th {
  background: var(--bg-tertiary);
  font-weight: 600;
}
.bubble blockquote {
  border-left: 3px solid var(--accent-muted);
  padding: 6px 14px;
  margin: 10px 0;
  color: var(--text-secondary);
  background: var(--accent-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}
.bubble a {
  color: var(--accent);
  text-decoration: none;
}
.bubble a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ── Tool cards ── */
.tool-card {
  background: var(--tool-bg);
  border: 1px solid var(--tool-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 10px 0;
  font-size: 14px;
  transition: all var(--duration-fast) var(--ease-out);
}

.tool-card:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.05);
}

.tool-card:active {
  background: rgba(255, 255, 255, 0.06);
}

.tool-card .tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  min-height: 36px;
}

.tool-card .tool-header .tool-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.tool-card .tool-header .arrow {
  transition: transform var(--duration-fast) var(--ease-out);
  font-size: 12px;
  color: var(--text-muted);
}

.tool-card .tool-header .arrow.open {
  transform: rotate(90deg);
}

.tool-card .tool-summary {
  color: var(--text-muted);
  margin-left: 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

.tool-card .tool-detail {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.tool-card .tool-detail.open {
  display: block;
}

.tool-card.tool-result {
  border-color: rgba(92, 184, 122, 0.2);
  background: rgba(92, 184, 122, 0.03);
}

.tool-card.tool-result .tool-header {
  color: var(--success);
}

.tool-card.tool-error {
  border-color: rgba(224, 96, 96, 0.2);
  background: rgba(224, 96, 96, 0.03);
}

.tool-card.tool-error .tool-header {
  color: var(--error);
}

.tool-file-actions {
  display: flex;
  gap: 8px;
  margin: 8px 0 4px 18px;
}

.tool-file-actions button {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all var(--duration-fast) var(--ease-out);
  min-height: 36px;
}

.tool-file-actions button:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.tool-file-actions button:active {
  transform: scale(0.97);
}

.tool-file-actions button svg {
  width: 14px;
  height: 14px;
}

/* ── Tool group (collapsed tool cards) ── */
.tool-group {
  background: var(--tool-bg);
  border: 1px solid var(--tool-border);
  border-radius: var(--radius-sm);
  margin: 10px 0;
  overflow: hidden;
  transition: all var(--duration-fast) var(--ease-out);
}

.tool-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
  transition: background var(--duration-fast);
}

.tool-group-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tool-group-header:active {
  background: rgba(255, 255, 255, 0.05);
}

.tool-group-header .arrow {
  transition: transform var(--duration-fast) var(--ease-out);
  font-size: 12px;
  color: var(--text-muted);
}

.tool-group-header .arrow.open {
  transform: rotate(90deg);
}

.tool-group-header .tool-group-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.tool-group-header .tool-group-count {
  color: var(--text-muted);
  font-size: 13px;
}

.tool-group-body {
  display: none;
  padding: 0 8px 8px;
}

.tool-group-body.open {
  display: block;
}

.tool-group-body .tool-card {
  margin: 4px 0;
  border-color: var(--border-subtle);
}

/* ── Streaming indicator (thought-line waveform) ── */
.streaming-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 6px 0 2px;
  vertical-align: middle;
}

.streaming-indicator .tl-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  animation: thoughtPulse 1.2s ease-in-out infinite;
  transform-origin: center;
}

.streaming-indicator .tl-bar:nth-child(1) { height: 10px; animation-delay: 0s; }
.streaming-indicator .tl-bar:nth-child(2) { height: 18px; animation-delay: 0.1s; }
.streaming-indicator .tl-bar:nth-child(3) { height: 12px; animation-delay: 0.2s; }
.streaming-indicator .tl-bar:nth-child(4) { height: 22px; animation-delay: 0.3s; }
.streaming-indicator .tl-bar:nth-child(5) { height: 8px;  animation-delay: 0.4s; }
.streaming-indicator .tl-bar:nth-child(6) { height: 16px; animation-delay: 0.5s; }
.streaming-indicator .tl-bar:nth-child(7) { height: 10px; animation-delay: 0.6s; }

@keyframes thoughtPulse {
  0%, 100% { opacity: 0.25; transform: scaleY(0.5); }
  50% { opacity: 1; transform: scaleY(1); }
}

@keyframes streamWindDown {
  0%   { opacity: 1; transform: scaleY(1); }
  40%  { opacity: 0.6; transform: scaleY(0.4); }
  100% { opacity: 0; transform: scaleY(0.1); }
}
.streaming-indicator.wind-down {
  animation: streamWindDown 0.4s var(--ease-out) both;
}
.streaming-indicator.wind-down .tl-bar {
  animation: none;
}

/* Legacy single dot (keep for compatibility) */
.streaming-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: 6px;
  animation: streamPulse 1.5s var(--ease-out) infinite;
  vertical-align: middle;
}

@keyframes streamPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.85); }
}

/* ── Activity status bar ── */
.activity-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-top: 8px;
  background: var(--accent-subtle);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.activity-status .activity-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: activitySpin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes activitySpin {
  to { transform: rotate(360deg); }
}

.activity-status .activity-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-status .activity-timer {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

/* ── Input area ── */
#input-wrapper {
  flex-shrink: 0;
  background: rgba(9, 9, 11, 0.88);
  backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  border-top: 1px solid var(--border-subtle);
}

/* Safe area handled by #tab-bar below */

#file-preview {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 0;
}

#file-preview.has-files {
  display: flex;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  animation: messageIn var(--duration-fast) var(--ease-out);
}

.file-chip .file-icon {
  font-size: 15px;
  flex-shrink: 0;
}

.file-chip .file-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip .file-remove {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--duration-fast);
}

.file-chip .file-remove:hover {
  color: var(--error);
  background: rgba(224, 96, 96, 0.1);
}

.file-chip .file-remove:active {
  transform: scale(0.9);
}

.file-chip img.file-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
}

#input-area {
  padding: 10px 16px 12px;
}

#input-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  position: relative;
  transition: border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}

#input-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#input-area textarea {
  width: 100%;
  padding: 14px 18px 8px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 150px;
  min-height: 44px;
  display: block;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#input-area textarea::-webkit-scrollbar {
  display: none;
}

#input-area textarea::placeholder {
  color: var(--text-dim);
}

#input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 6px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

.attach-wrapper {
  position: relative;
  flex-shrink: 0;
}

#attach-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  transition: all var(--duration-fast) var(--ease-out);
  font-size: 22px;
  font-weight: 300;
}

#attach-btn:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}

#attach-btn:active {
  transform: scale(0.93);
}

.attach-menu {
  display: none;
  position: fixed;
  bottom: auto;
  left: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-width: 160px;
  z-index: 100;
  animation: menuIn var(--duration-fast) var(--ease-out);
}

.attach-menu.open {
  display: block;
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.attach-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: background var(--duration-fast);
  text-align: left;
  min-height: 48px;
}

.attach-menu button:hover {
  background: var(--bg-tertiary);
}

.attach-menu button:active {
  background: var(--bg-surface);
}

.attach-menu .menu-icon {
  display: flex;
  align-items: center;
  color: var(--text-muted);
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.msg-attachment {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
}

.msg-attachment .file-icon {
  font-size: 14px;
}

/* ── Send / Stop / Voice buttons ── */
#send-btn, #stop-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
}

#send-btn {
  background: var(--accent);
  color: white;
}

#send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

#send-btn:active:not(:disabled) {
  transform: scale(0.9);
}

#send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

#stop-btn {
  display: none;
  background: var(--error);
  color: white;
}

#stop-btn:hover {
  background: #d04040;
}

#stop-btn:active {
  transform: scale(0.9);
}

/* ── Empty state ── */
#empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  text-align: center;
  padding: 24px;
  position: relative;
}

#empty-state::before {
  content: '';
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

#empty-state .logo-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
  opacity: 0.9;
}

#empty-state .greeting {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

#empty-state .hint {
  font-size: 15px;
  color: var(--text-muted);
}

#empty-state .quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 28px;
  max-width: 480px;
  width: 100%;
}

#empty-state .quick-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  text-align: left;
  min-height: 52px;
}

#empty-state .quick-action:hover {
  background: var(--bg-tertiary);
  border-color: rgba(59, 130, 246, 0.35);
  color: var(--text);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.06);
  transform: translateY(-1px);
}

#empty-state .quick-action:active {
  transform: scale(0.97) translateY(0);
}

#empty-state .quick-action .qa-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.14); }

/* ── Code block copy button ── */
.code-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: all var(--duration-fast);
  z-index: 2;
  font-family: inherit;
  min-height: 32px;
  display: flex;
  align-items: center;
}

.bubble pre:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  color: var(--text);
  background: var(--bg-surface);
}

.code-copy-btn:active {
  transform: scale(0.95);
}

.code-copy-btn.copied {
  color: var(--success);
  border-color: rgba(92, 184, 122, 0.3);
}

/* ── Voice input button ── */
#voice-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
}

#voice-btn:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}

#voice-btn:active {
  transform: scale(0.93);
}

#voice-btn.recording {
  color: var(--error);
  background: rgba(224, 96, 96, 0.1);
  animation: recordPulse 1.5s ease-in-out infinite;
}

#voice-btn.transcribing {
  color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
  animation: transcribePulse 0.8s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes transcribePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.95); }
}

/* ── Conversation history drawer ── */
#history-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

#history-overlay.open {
  display: block;
  opacity: 1;
}

#history-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform var(--duration-normal) var(--ease-out);
  box-shadow: 8px 0 30px rgba(0, 0, 0, 0.4);
}

#history-drawer.open {
  transform: translateX(0);
}

#history-drawer .drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

@supports (padding-top: env(safe-area-inset-top)) {
  #history-drawer .drawer-header {
    padding-top: calc(16px + env(safe-area-inset-top));
  }
}

#history-drawer .drawer-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

#history-drawer .drawer-close {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}

#history-drawer .drawer-close:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

#history-drawer .drawer-close:active {
  transform: scale(0.93);
}

.history-date-group {
  padding: 12px 20px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: none;
}

#history-list::-webkit-scrollbar {
  display: none;
}

.history-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  transition: background var(--duration-fast);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 56px;
}

.history-item:hover {
  background: var(--bg-tertiary);
}

.history-item:active {
  background: var(--bg-surface);
}

.history-item.active {
  background: var(--accent-subtle);
  border-left: 3px solid var(--accent);
}

.history-item.processing .history-meta {
  color: var(--accent);
}

.processing-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: middle;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.history-item .history-content {
  flex: 1;
  min-width: 0;
}

.history-item .history-title {
  font-size: 15px;
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item .history-preview {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item .history-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.history-item .history-delete {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: all var(--duration-fast);
  flex-shrink: 0;
  margin-left: 4px;
}

.history-item .history-delete:hover {
  background: rgba(224, 96, 96, 0.15);
  color: var(--error);
  opacity: 1;
}

.history-item .history-delete:active {
  transform: scale(0.9);
}

.history-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 15px;
}

/* ── Search bar ── */
#search-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  animation: messageIn var(--duration-fast) var(--ease-out);
}

#search-bar.open {
  display: flex;
}

#search-bar input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  outline: none;
  min-height: 40px;
}

#search-bar input:focus {
  border-color: var(--border-focus);
}

#search-bar .search-count {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

#search-bar button {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}

#search-bar button:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}

#search-bar button:active {
  transform: scale(0.93);
}

.search-highlight {
  background: rgba(255, 200, 0, 0.25);
  color: inherit;
  border-radius: 2px;
}

.search-highlight.active {
  background: rgba(255, 200, 0, 0.5);
}

/* ── Files drawer ── */
/* ── Files view ── */
#files-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* Files tabs */
/* Files tabs */
.files-tabs {
  display: flex;
  padding: 4px;
  margin: 8px 12px 0;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  gap: 4px;
}

.files-tab {
  flex: 1;
  min-width: 0;
  padding: 7px 4px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast);
  min-height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  overflow: hidden;
}

.files-tab svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--duration-fast);
}

.files-tab:hover {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.files-tab:hover svg {
  opacity: 0.8;
}

.files-tab:active {
  transform: scale(0.98);
}

.files-tab.active {
  color: var(--text);
  background: var(--bg-tertiary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.files-tab.active svg {
  opacity: 1;
  color: var(--accent);
}

/* Files dropzone */
.files-dropzone {
  padding: 24px 20px;
  margin: 12px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  text-align: center;
  transition: all var(--duration-normal) var(--ease-out);
  cursor: pointer;
  background: var(--bg-secondary);
}

.files-dropzone:hover, .files-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-subtle);
  transform: scale(1.01);
}

.files-dropzone.dragover {
  border-style: solid;
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.files-dropzone-icon {
  margin-bottom: 8px;
  color: var(--text-dim);
  transition: color var(--duration-fast), transform var(--duration-normal) var(--ease-out);
}

.files-dropzone:hover .files-dropzone-icon,
.files-dropzone.dragover .files-dropzone-icon {
  color: var(--accent);
  transform: translateY(-2px);
}

.files-dropzone-label {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 12px;
}

.files-dropzone-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.files-dropzone-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--duration-fast);
  min-height: 40px;
  line-height: 1;
}

.files-dropzone-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.files-dropzone-btn:hover {
  background: var(--bg-surface);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.1);
}

.files-dropzone-btn:active {
  transform: scale(0.97);
}

/* Files upload progress */
.files-upload-progress {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-out);
}

.files-upload-progress.active {
  max-height: 50px;
  opacity: 1;
  padding: 10px 16px;
}

.files-upload-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.files-progress-bar {
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.files-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 2px;
  transition: width 0.3s var(--ease-out);
}

/* Files list */
.files-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
}

.files-list::-webkit-scrollbar {
  display: none;
}

/* Empty state */
.files-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 15px;
  gap: 8px;
}

.files-empty-icon {
  font-size: 32px;
  margin-bottom: 4px;
  opacity: 0.4;
  color: var(--text-dim);
}

.files-empty-hint {
  font-size: 13px;
  color: var(--text-dim);
  opacity: 0.7;
}

/* Clear row */
.files-clear-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.files-count {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.files-clear-btn {
  font-size: 12px;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  min-height: 28px;
  transition: all var(--duration-fast);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 500;
}

.files-clear-btn:hover {
  color: var(--error);
  border-color: rgba(224, 96, 96, 0.3);
  background: rgba(224, 96, 96, 0.06);
}

/* File row */
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--duration-fast);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 56px;
}

.file-row:last-child {
  border-bottom: none;
}

.file-row:hover {
  background: var(--bg-tertiary);
}

.file-row:active {
  background: var(--bg-surface);
}

.file-row-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.file-row-icon svg {
  width: 18px;
  height: 18px;
}

.file-row-icon.file-icon-image { background: rgba(66, 188, 221, 0.1); color: #42bcdd; }
.file-row-icon.file-icon-pdf { background: rgba(224, 96, 96, 0.1); color: #e06060; }
.file-row-icon.file-icon-doc { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.file-row-icon.file-icon-sheet { background: rgba(92, 184, 122, 0.1); color: #5cb87a; }
.file-row-icon.file-icon-code { background: rgba(168, 216, 216, 0.1); color: #a8d8d8; }
.file-row-icon.file-icon-video { background: rgba(200, 120, 220, 0.1); color: #c878dc; }
.file-row-icon.file-icon-audio { background: rgba(255, 180, 100, 0.1); color: #ffb464; }
.file-row-icon.file-icon-archive { background: rgba(180, 160, 120, 0.1); color: #b4a078; }
.file-row-icon.file-icon-folder { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }

.browse-breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  padding: 10px 16px 0; font-size: 13px;
}
.browse-bc-link {
  color: var(--accent, #3b82f6); cursor: pointer; padding: 2px 4px; border-radius: 4px;
}
.browse-bc-link:hover { text-decoration: underline; }
.browse-bc-active { color: var(--text-primary, #0f172a); font-weight: 500; padding: 2px 4px; }
.browse-bc-sep { color: var(--text-tertiary, #94a3b8); padding: 0 1px; }

.file-row-info {
  flex: 1;
  min-width: 0;
}

.file-row-name {
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.file-row-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.file-row-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.file-row:hover .file-row-actions {
  opacity: 1;
}

.file-row-actions button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
}

.file-row-actions button:hover {
  color: var(--text);
  background: var(--bg-surface);
}

.file-row-actions button:active {
  transform: scale(0.9);
}

.file-row-actions button.file-delete-btn:hover {
  color: var(--error);
  background: rgba(224, 96, 96, 0.1);
}

/* ── File preview modal ── */
#file-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) var(--ease-out), visibility var(--duration-normal);
  display: flex;
}

#file-preview-modal.open {
  opacity: 1;
  visibility: visible;
}

#file-preview-modal .preview-body img,
#file-preview-modal .preview-body video {
  animation: previewFadeIn var(--duration-normal) var(--ease-out);
}

@keyframes previewFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  min-height: 52px;
  gap: 12px;
}

@supports (padding-top: env(safe-area-inset-top)) {
  .preview-header {
    padding-top: calc(12px + env(safe-area-inset-top));
  }
}

.preview-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.preview-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.preview-actions button {
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--duration-fast);
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-actions button:hover {
  background: var(--bg-surface);
  color: var(--text);
}

.preview-actions button:active {
  transform: scale(0.97);
}

.preview-actions button svg {
  width: 14px;
  height: 14px;
}

.preview-close-btn {
  background: transparent !important;
  border: none !important;
  width: 40px;
  padding: 8px !important;
  justify-content: center;
}

.preview-close-btn:hover {
  background: rgba(255, 255, 255, 0.06) !important;
}

.preview-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 16px;
  touch-action: none;
}

.preview-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  touch-action: none;
}

.preview-body video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
}

.preview-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 4px;
}

.preview-body .preview-text {
  width: 100%;
  max-width: 800px;
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-y: auto;
  align-self: flex-start;
  border: 1px solid var(--border);
}

/* Loading skeleton for files list */
.files-skeleton {
  padding: 0;
}

.files-skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  min-height: 56px;
}

.files-skeleton-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

.files-skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.files-skeleton-line {
  height: 12px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

.files-skeleton-line:first-child { width: 60%; }
.files-skeleton-line:last-child { width: 35%; height: 10px; }

@keyframes skeletonPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}
/* ── Chat drag-and-drop overlay ── */
#chat-drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  align-items: center;
  justify-content: center;
  border: 3px dashed var(--accent);
  pointer-events: none;
}

#chat-drop-overlay.visible {
  display: flex;
}

/* ── Scroll-to-bottom button ── */
#scroll-bottom-btn {
  display: none;
  position: fixed;
  bottom: 180px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
  min-height: 36px;
  align-items: center;
  gap: 6px;
}

#scroll-bottom-btn:hover {
  background: var(--bg-surface);
  color: var(--text);
}

#scroll-bottom-btn:active {
  transform: translateX(-50%) scale(0.95);
}

#scroll-bottom-btn.visible {
  display: flex;
}

/* ── Prism.js overrides for dark theme ── */
.bubble pre[class*="language-"],
.bubble code[class*="language-"] {
  background: rgba(0, 0, 0, 0.3) !important;
  font-size: 14px !important;
}

.bubble pre[class*="language-"] {
  padding: 14px 16px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-subtle) !important;
  margin: 10px 0 !important;
}
/* ── Tools view ── */
#more-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#app.more-mode #more-view {
  display: flex;
}

#app.more-mode #chat,
#app.more-mode #input-wrapper,
#app.more-mode #scroll-bottom-btn,
#app.more-mode #command-view,
#app.more-mode #finance-view,
#app.more-mode #marketing-view {
  display: none !important;
}

#app.command-mode #more-view,
#app.command-mode #finance-view,
#app.command-mode #marketing-view {
  display: none !important;
}

/* ── Tools launcher grid ── */
#tools-launcher {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  overscroll-behavior-y: contain;
}

.tools-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 600px;
  margin: 0 auto;
}

.tool-launcher-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  min-height: 56px;
}

.tool-launcher-card:last-child {
  border-bottom: none;
}

.tool-launcher-card:hover {
  background: var(--bg-elevated);
}

.tool-launcher-card:active {
  background: var(--bg-tertiary);
  transition-duration: 0.06s;
}

.tool-launcher-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle);
  border-radius: var(--radius-sm);
  padding: 7px;
}

.tool-launcher-icon svg {
  width: 100%;
  height: 100%;
}

.tool-launcher-info {
  flex: 1;
  min-width: 0;
}

.tool-launcher-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.tool-launcher-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-launcher-badge {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-left: 8px;
}

.tool-launcher-badge--active {
  color: var(--accent);
  font-weight: 600;
}

.tool-launcher-chevron {
  color: var(--text-dim);
  font-size: 18px;
  flex-shrink: 0;
  margin-left: 4px;
}

/* ── More-tab dashboard (sectioned, live) ── */
.more-dashboard {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.more-stripe {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
  background: var(--accent-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  color: var(--text);
}

.more-stripe-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.more-stripe-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: morePulse 2s ease-in-out infinite;
}

.more-stripe-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.more-stripe-chip {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.more-stripe-chip:hover {
  background: var(--bg-tertiary);
}

.more-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.more-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.more-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  min-height: 140px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.more-tile:hover {
  background: var(--bg-tertiary);
  border-color: var(--border);
}

.more-tile:active {
  transform: scale(0.98);
}

.more-tile-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.more-tile-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  padding: 8px;
  flex-shrink: 0;
  background: var(--accent-subtle);
  color: var(--accent);
}

.more-tile-icon svg { width: 100%; height: 100%; }

.more-tile--primary    .more-tile-icon { background: var(--accent-subtle); color: var(--accent); }
.more-tile--secondary  .more-tile-icon { background: rgba(99, 102, 241, 0.12); color: #6366f1; }
.more-tile--tertiary   .more-tile-icon { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
.more-tile--warning    .more-tile-icon { background: rgba(234, 179, 8, 0.14); color: #ca8a04; }
.more-tile--critical   .more-tile-icon { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.more-tile--neutral    .more-tile-icon { background: var(--bg-tertiary); color: var(--text-muted); }

.more-tile-label {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.more-tile-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  margin-left: 6px;
}

.more-tile-metric {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  word-break: break-word;
}

.more-tile-metric--muted {
  color: var(--text-dim);
  font-weight: 400;
}

.more-tile-metric--skeleton { display: flex; }

.more-skeleton {
  display: inline-block;
  width: 60%;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-tertiary) 0%, var(--border-subtle) 50%, var(--bg-tertiary) 100%);
  background-size: 200% 100%;
  animation: moreSkeleton 1.4s ease-in-out infinite;
}

.more-tile-pulse {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: morePulse 2s ease-in-out infinite;
}

.more-tile-pulse--ok       { background: #22c55e; }
.more-tile-pulse--warning  { background: #eab308; }
.more-tile-pulse--critical { background: #ef4444; }

@keyframes morePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}

@keyframes moreSkeleton {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 600px) {
  .more-dashboard { gap: 18px; }
  .more-section-grid { grid-template-columns: 1fr; gap: 10px; }
  .more-tile { min-height: 120px; padding: 14px; }
  .more-tile-metric { font-size: 16px; }
}

/* ── Tool frame container ── */
#tool-frame-container {
  display: none;
  flex-direction: column;
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 5;
}

#tool-frame-container.open {
  display: flex;
  animation: toolSlideIn var(--duration-normal) var(--ease-out);
}

@keyframes toolSlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes toolSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0.5; }
}

#tool-back-bar {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: rgba(9, 9, 11, 0.88);
  backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#tool-back-bar button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 4px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast);
}

#tool-back-bar button:hover {
  color: var(--accent);
}

#tool-back-bar button:active {
  transform: scale(0.97);
}

#tool-back-bar svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

#tool-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: var(--bg);
}

/* ── Mobile-specific responsive ── */
@media (max-width: 600px) {
  /* Compact upload zone on mobile */
  .files-dropzone {
    border: 1.5px dashed var(--border);
    padding: 16px 12px;
    margin: 8px 12px;
  }
  .files-dropzone-icon { display: none; }
  .files-dropzone-label { display: none; }
  .files-dropzone-buttons { width: 100%; }
  .files-dropzone-btn { flex: 1; justify-content: center; }

  .message { max-width: 92%; }
  .message.assistant { max-width: 100%; }
  #chat { padding: 16px 12px; }
  #header { padding: 6px 8px; }
  #input-area { padding: 8px 12px 10px; }
  #file-preview { padding-left: 12px; padding-right: 12px; }
  #empty-state .greeting { font-size: 20px; }
  #empty-state .quick-actions { max-width: 100%; }
  #empty-state .quick-action { font-size: 14px; padding: 10px 14px; }

  /* Always show interactive elements (no hover on touch) */
  .code-copy-btn { opacity: 1; }
  .msg-copy-btn { opacity: 1; }
  .file-row-actions { opacity: 1; }

  /* Larger touch targets for tool cards */
  .tool-card .tool-header {
    min-height: 44px;
    font-size: 15px;
    padding: 8px 0;
  }
  .tool-card .tool-header .arrow { font-size: 13px; }
  .tool-card .tool-summary { font-size: 14px; }
  .tool-card .tool-detail { font-size: 14px; max-height: 200px; }
  .tool-group-header { min-height: 48px; font-size: 15px; }

  /* Smaller textarea on mobile with keyboard */
  #input-area textarea { max-height: 100px; }

  /* Search buttons bigger */
  #search-bar button { width: 40px; height: 40px; min-width: 40px; }

  /* Font size minimums */
  .message .time { font-size: 13px; }
  .history-item .history-meta { font-size: 13px; }
  .file-row-meta { font-size: 13px; }

  /* Tool file action buttons */
  .tool-file-actions button { padding: 8px 14px; font-size: 14px; min-height: 40px; }

  /* Code blocks */
  .bubble pre { font-size: 14px; padding: 12px; }
  .code-copy-btn { padding: 8px 12px; font-size: 13px; min-height: 36px; }
}

/* ── Landscape with keyboard ── */
@media (max-height: 500px) and (orientation: landscape) {
  #header { padding: 4px 8px; min-height: 36px; }
  #bottom-actions { display: none; }
  #input-area textarea { max-height: 60px; }
  .message { margin-bottom: 12px; }
}

/* ── Desktop-specific enhancements ── */
@media (min-width: 601px) {
  .history-item .history-delete { opacity: 0; }
  .history-item:hover .history-delete { opacity: 1; }
}

/* ── Conversation search in drawer ── */
.drawer-search {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-search input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.drawer-search input:focus { border-color: var(--border-focus); }

#convo-search-results {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}
.search-match-count {
  font-size: 13px;
  color: var(--accent);
  margin-top: 2px;
}
.search-snippet {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-snippet mark {
  background: rgba(59, 130, 246, 0.3);
  color: var(--text);
  padding: 0 2px;
  border-radius: 2px;
}
.search-snippet-role {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: capitalize;
}

/* ── Notification bell & dropdown ── */
#notif-bell {
  position: relative;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
#notif-bell:hover { color: var(--text); background: var(--bg-tertiary); }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--error);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
}

#notif-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 8px;
  width: min(360px, calc(100vw - 24px));
  max-height: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
#notif-dropdown.open { display: block; }

.notif-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}
.notif-dropdown-header button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
}

#notif-list {
  overflow-y: auto;
  max-height: 340px;
}
.notif-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.notif-item:hover { background: var(--bg-tertiary); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-item--critical { border-left-color: var(--error); }
.notif-item--health-alert { border-left-color: var(--error); }
.notif-item--health-resolved { border-left-color: var(--success); }
.notif-item--scheduler-alert { border-left-color: #e6b43c; }
.notif-item--pending { border-left-color: #e6b43c; background: rgba(230, 180, 60, 0.04); }
.notif-item-pending-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #e6b43c;
  background: rgba(230, 180, 60, 0.15);
  border-radius: 6px;
  padding: 1px 5px;
  vertical-align: middle;
}
.notif-item-content { flex: 1; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 2px; }
.notif-body { font-size: 14px; color: var(--text); line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 14px; }
.notif-type-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
}

/* ── Panel container ── */
#panel-container {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#panel-back-bar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
#panel-back-bar button {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 15px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  min-height: 36px;
}
#panel-back-bar button:hover { background: var(--bg-tertiary); }

#panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* ── Panel shared styles ── */
.panel-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  padding: 24px;
  font-size: 15px;
}
.panel-error { color: var(--error); padding: 16px; font-size: 15px; }
.panel-empty { color: var(--text-muted); padding: 24px; text-align: center; font-size: 15px; }

.panel-section { margin-bottom: 20px; }
.panel-heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.panel-search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.panel-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  outline: none;
  min-height: 44px;
}
.panel-input:focus { border-color: var(--border-focus); }
.panel-select {
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  min-height: 44px;
}

.panel-actions-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.panel-btn {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  min-height: 40px;
}
.panel-btn:hover { background: var(--accent-hover); }
.panel-btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.panel-btn-secondary:hover { background: var(--bg-elevated); }
.panel-btn-sm {
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  min-height: 32px;
}
.panel-btn-sm:hover { background: var(--bg-elevated); }
.panel-btn-danger { color: var(--error); }
.panel-btn-danger:hover { background: rgba(224, 96, 96, 0.1); }

.panel-raw {
  background: var(--bg-tertiary);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.panel-textarea {
  width: 100%;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-mono);
  resize: vertical;
  outline: none;
  min-height: 120px;
}
.panel-textarea:focus { border-color: var(--border-focus); }

.panel-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.panel-modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  width: min(500px, 100%);
  max-height: 80vh;
  overflow-y: auto;
}
.panel-modal-content h3 {
  margin-bottom: 12px;
  font-size: 16px;
}
.panel-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}

.panel-results { margin-top: 8px; }

/* ── Memory cards ── */
.memory-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.memory-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.memory-id { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.memory-type {
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.type-user { background: rgba(92, 184, 122, 0.15); color: var(--success); }
.type-feedback { background: rgba(59, 130, 246, 0.15); color: var(--accent); }
.type-project { background: rgba(209, 147, 38, 0.15); color: #d19326; }
.type-reference { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.type-unknown { background: var(--bg-tertiary); color: var(--text-muted); }
.memory-tags { font-size: 13px; color: var(--text-dim); }
.memory-score { font-size: 13px; font-weight: 600; color: var(--accent); margin-left: auto; }
.memory-card-body {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.memory-card-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}


/* ── Finance KPIs ── */
.finance-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}
.finance-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.finance-kpi {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.kpi-value { font-size: 18px; font-weight: 600; color: var(--text); }
.kpi-value.kpi-negative { color: var(--error); }
.kpi-delta { font-size: 12px; margin-top: 4px; font-weight: 500; }
.delta-good { color: var(--success); }
.delta-bad { color: var(--error); }
.kpi-lastmonth { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.finance-kpi.kpi-large { grid-column: span 2; }
.finance-kpi.kpi-large .kpi-value { font-size: 24px; }
.finance-kpi.kpi-alert { border: 1px solid rgba(224, 96, 96, 0.3); background: rgba(224, 96, 96, 0.05); }
.finance-kpi.kpi-stale .kpi-value { opacity: 0.45; }
.finance-kpi.kpi-stale .kpi-label::after { content: ' \21BB'; font-size: 12px; opacity: 0.5; }
.finance-alert-bar {
  background: rgba(224, 96, 96, 0.08);
  border: 1px solid rgba(224, 96, 96, 0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--error);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.alert-sep { color: rgba(224, 96, 96, 0.3); margin: 0 4px; }
.finance-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.kpi-sparkline-inline { margin: 4px 0 2px; opacity: 0.7; }
.kpi-comparison { margin-top: 4px; }
.kpi-delta.hidden { display: none; }
.finance-collapse-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
}
.finance-collapse-header:hover { opacity: 0.8; }
.finance-updated { font-size: 12px; color: var(--text-dim); margin-top: 12px; }
.finance-timestamp-hero { text-align: right; font-size: 11px; color: var(--text-dim); margin: -4px 0 8px; padding: 0 4px; }
.finance-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

/* ── Charts ── */
.chart-container { width: 100%; overflow: hidden; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-hover-target { cursor: crosshair; }
.chart-dot { transition: opacity 0.12s; }
.chart-tip { transition: opacity 0.12s; }

/* ── Marketing Dashboard ── */
.mkt-scoreboard { margin-bottom: 12px; }
.finance-scoreboard-hero { background: transparent; border: none; box-shadow: none; padding: 16px 0 8px; }
.mkt-period-toggle {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}
.mkt-notice {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin: -6px 0 10px;
  opacity: 0.7;
}
.mkt-period-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  min-height: 32px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.mkt-period-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.mkt-segment {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mkt-segment::-webkit-scrollbar { display: none; }
.mkt-segment-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 36px;
  white-space: nowrap;
}
.mkt-segment-btn.active {
  background: var(--accent);
  color: #fff;
}
.mkt-row {
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.mkt-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}
.mkt-row-query {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mkt-row-position {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  flex-shrink: 0;
}
.mkt-row-metrics {
  font-size: 14px;
  color: var(--text-muted);
}
.mkt-bar-container { margin-top: 8px; }
.mkt-bar-track {
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-tertiary);
}
.mkt-bar-fill { height: 100%; }
.mkt-bar-branded { background: var(--accent); }
.mkt-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}
.mkt-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.mkt-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 8px 0;
}
.mkt-compare-cell {
  text-align: center;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
}
.mkt-compare-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.mkt-compare-value {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
}
@media (max-width: 480px) {
  .mkt-compare-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Cohort retention table (C5) ── */
.cohort-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cohort-table th, .cohort-table td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.cohort-table th {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.cohort-table td:first-child { text-align: left; font-weight: 500; }
.ret-good { color: var(--success); font-weight: 600; }
.ret-ok { color: #d4a843; font-weight: 600; }
.ret-bad { color: var(--error); font-weight: 600; }
@media (max-width: 500px) {
  .cohort-col-optional { display: none; }
}

/* ── Data health indicator (C12) ── */
.data-health {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-top: 12px;
}
.data-health-ok {
  color: var(--success);
  background: rgba(92, 184, 122, 0.08);
  border: 1px solid rgba(92, 184, 122, 0.2);
}
.data-health-warn {
  color: #d4a843;
  background: rgba(212, 168, 67, 0.08);
  border: 1px solid rgba(212, 168, 67, 0.2);
}

/* ── Finance alert warning level ── */
.finance-alert-warning {
  background: rgba(212, 168, 67, 0.08);
  border-color: rgba(212, 168, 67, 0.2);
  color: #d4a843;
}

/* ── Email view ── */
/* Detail layout: sticky header + scrollable body + sticky footer */
.detail-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  margin: -16px;
}
.detail-top {
  flex-shrink: 0;
  padding: 16px 16px 0;
}
.detail-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 12px 16px;
  min-height: 0;
}
.detail-bottom {
  flex-shrink: 0;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.detail-bottom .email-actions {
  border: none;
  padding: 12px 0 0;
  background: none;
}

.email-view { display: flex; flex-direction: column; gap: 12px; }
.email-header {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.email-subject { font-size: 18px; font-weight: 600; margin-bottom: 10px; line-height: 1.35; }
.email-meta { font-size: 14px; color: var(--text-muted); line-height: 1.65; }
.email-body {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}
.email-actions {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.email-actions-label { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; color: var(--text-dim); }
.email-quick-actions { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.email-quick-actions .panel-btn { min-height: 44px; padding: 10px 16px; font-size: 15px; }
.email-custom-prompt { display: flex; gap: 8px; align-items: flex-end; }
.email-custom-prompt textarea { flex: 1; min-height: 44px; font-size: 16px; }
.email-custom-prompt .panel-btn { align-self: flex-end; }

/* ── Notification panel items ── */
/* Notification panel redesign */
.notif-panel-enter {
  animation: health-fade-in 0.25s var(--ease-out) both;
}
.notif-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(92, 184, 122, 0.08);
  border: 1px solid rgba(92, 184, 122, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.notif-banner--alert {
  background: rgba(224, 96, 96, 0.08);
  border-color: rgba(224, 96, 96, 0.25);
}
.notif-banner--pending {
  background: rgba(230, 180, 60, 0.08);
  border-color: rgba(230, 180, 60, 0.25);
}
.notif-banner-pending {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: #e6b43c;
  background: rgba(230, 180, 60, 0.12);
  padding: 2px 8px;
  border-radius: 8px;
}
.notif-banner-text { font-size: 15px; font-weight: 600; color: var(--text); }
.notif-banner-alert {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
  background: rgba(224, 96, 96, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
}
.notif-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.notif-filter-btn {
  font-size: 13px;
  padding: 5px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  min-height: 32px;
  transition: all var(--duration-fast) var(--ease-out);
}
.notif-filter-btn:hover { background: var(--bg-elevated); color: var(--text); }
.notif-filter-btn--active {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--accent);
}
.notif-filter-btn--urgent {
  background: rgba(230, 180, 60, 0.1);
  border-color: rgba(230, 180, 60, 0.3);
  color: #e6b43c;
}
.notif-filter-btn--urgent.notif-filter-btn--active {
  background: rgba(230, 180, 60, 0.2);
}
.notif-panel-list { display: flex; flex-direction: column; gap: 6px; }
.notif-panel-item {
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.notif-panel-item.unread { border-left: 3px solid var(--accent); }
.notif-panel-item--critical { border-left-color: var(--error); background: rgba(224, 96, 96, 0.03); }
.notif-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.notif-panel-title { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
.notif-panel-time { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.notif-panel-body { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }
.notif-panel-source { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.notif-panel-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.notif-priority {
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.notif-priority--critical { background: rgba(224, 96, 96, 0.15); color: var(--error); }
.notif-priority--high { background: rgba(230, 180, 60, 0.15); color: #e6b43c; }
.notif-priority--low { background: var(--bg-tertiary); color: var(--text-dim); }
.notif-approval-message {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-top: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
}
.notif-approval-bar {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.notif-btn-approve { background: rgba(52, 199, 89, 0.12) !important; color: #34c759 !important; border-color: rgba(52, 199, 89, 0.3) !important; }
.notif-btn-approve:hover { background: rgba(52, 199, 89, 0.22) !important; }
.notif-btn-reject { background: rgba(224, 96, 96, 0.12) !important; color: var(--error) !important; border-color: rgba(224, 96, 96, 0.3) !important; }
.notif-btn-reject:hover { background: rgba(224, 96, 96, 0.22) !important; }
.notif-btn-defer { background: rgba(230, 180, 60, 0.12) !important; color: #e6b43c !important; border-color: rgba(230, 180, 60, 0.3) !important; }
.notif-btn-defer:hover { background: rgba(230, 180, 60, 0.22) !important; }
.notif-approval-status {
  font-size: 12px;
  font-weight: 600;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 8px;
  display: inline-block;
}
.notif-approval-status--approved { background: rgba(52, 199, 89, 0.12); color: #34c759; }
.notif-approval-status--rejected { background: rgba(224, 96, 96, 0.12); color: var(--error); }
.notif-approval-status--deferred { background: rgba(230, 180, 60, 0.12); color: #e6b43c; }
@media (max-width: 400px) {
  .notif-panel-header { gap: 6px; }
  .notif-panel-actions { flex-wrap: wrap; }
  .notif-approval-bar { flex-wrap: wrap; }
}

/* ── Documents panel ── */
.docs-search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.docs-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  font-size: 15px;
  margin-bottom: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.docs-breadcrumb::-webkit-scrollbar { display: none; }
.docs-crumb {
  color: var(--accent);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  flex-shrink: 0;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.docs-crumb:active { background: var(--bg-elevated); }
.docs-crumb-sep { color: var(--text-dim); margin: 0 2px; flex-shrink: 0; }
.docs-crumb-current { color: var(--text-secondary); font-weight: 500; padding: 6px 10px; flex-shrink: 0; min-height: 36px; display: inline-flex; align-items: center; }

.docs-list { display: flex; flex-direction: column; gap: 6px; }

.docs-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 64px;
}
.docs-folder { cursor: pointer; }
.docs-folder:active { background: var(--bg-tertiary); }
.docs-icon { font-size: 22px; flex-shrink: 0; width: 30px; text-align: center; }
.docs-item-info { flex: 1; min-width: 0; }
.docs-name { font-size: 16px; color: var(--text); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.docs-meta { font-size: 14px; color: var(--text-dim); margin-top: 3px; line-height: 1.3; }
.docs-actions { display: flex; gap: 8px; flex-shrink: 0; }
.docs-actions .panel-btn-sm { min-height: 40px; min-width: 40px; padding: 6px 10px; font-size: 15px; display: flex; align-items: center; justify-content: center; }
.docs-chevron { color: var(--text-dim); font-size: 20px; flex-shrink: 0; padding: 0 4px; line-height: 1; }

/* ── Header adjustments for notif bell ── */
#header { position: relative; }

/* ── Health Dashboard ── */

/* Overall status banner */
.health-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  border: 1px solid;
  transition: background var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out);
}
.health-banner--ok {
  background: rgba(92, 184, 122, 0.08);
  border-color: rgba(92, 184, 122, 0.25);
}
.health-banner--warn {
  background: rgba(230, 180, 60, 0.08);
  border-color: rgba(230, 180, 60, 0.25);
}
.health-banner--down {
  background: rgba(224, 96, 96, 0.1);
  border-color: rgba(224, 96, 96, 0.3);
}
.health-banner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-banner--ok .health-banner-dot { background: var(--success); box-shadow: 0 0 6px rgba(92, 184, 122, 0.5); }
.health-banner--warn .health-banner-dot { background: #e6b43c; box-shadow: 0 0 6px rgba(230, 180, 60, 0.5); }
.health-banner--down .health-banner-dot { background: var(--error); box-shadow: 0 0 6px rgba(224, 96, 96, 0.5); }
.health-banner-dot--pulse {
  animation: health-pulse 2s ease-in-out infinite;
}
@keyframes health-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.health-banner-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.health-banner-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

/* Service cards */
.health-services {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.health-svc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 44px;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out);
}
.health-svc--down {
  border-color: rgba(224, 96, 96, 0.35);
  background: rgba(224, 96, 96, 0.04);
}
.health-svc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.health-svc-dot--ok {
  background: var(--success);
  box-shadow: 0 0 4px rgba(92, 184, 122, 0.4);
}
.health-svc-dot--down {
  background: var(--error);
  box-shadow: 0 0 4px rgba(224, 96, 96, 0.4);
  animation: health-pulse 1.5s ease-in-out infinite;
}
.health-svc-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}
.health-svc-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.health-svc-badge--ok {
  background: rgba(92, 184, 122, 0.15);
  color: var(--success);
}
.health-svc-badge--down {
  background: rgba(224, 96, 96, 0.15);
  color: var(--error);
}

/* Resource cards with progress bars */
.health-resources {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}
.health-res {
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-fast) var(--ease-out);
}
.health-res--alert {
  border-color: rgba(224, 96, 96, 0.3);
}
.health-res--warn {
  border-color: rgba(230, 180, 60, 0.25);
}
.health-res-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.health-res-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.health-res-detail {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 0;
}
.health-res--full {
  grid-column: 1 / -1;
}

/* Progress bar */
.health-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.health-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s var(--ease-out);
}
.health-bar-fill--ok { background: var(--success); }
.health-bar-fill--warn { background: #e6b43c; }
.health-bar-fill--alert { background: var(--error); }

/* Footer */
.health-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}
.health-updated {
  font-size: 12px;
  color: var(--text-dim);
}
.health-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  min-height: 32px;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.health-refresh-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
}
.health-refresh-btn:active {
  background: var(--bg-tertiary);
}
.health-refresh-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  transition: transform 0.4s var(--ease-out);
}
.health-refresh-btn:active .health-refresh-icon {
  transform: rotate(180deg);
}

.health-restart-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  min-height: 32px;
  width: 100%;
  justify-content: center;
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}
.health-restart-btn:hover {
  background: var(--bg-elevated);
  color: var(--accent);
  border-color: var(--accent);
}
.health-restart-btn:active {
  background: var(--bg-tertiary);
}
.health-restart-btn:disabled {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

/* Fade-in animation for panel content */
.health-panel-enter {
  animation: health-fade-in 0.25s var(--ease-out) both;
}
@keyframes health-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Service meta (response time, http code) */
.health-svc-meta {
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border-radius: 4px;
}
.health-svc-meta--warn {
  color: #e6b43c;
  background: rgba(230, 180, 60, 0.1);
}

/* SSL cert warn dot */
.health-svc-dot--warn {
  background: #e6b43c;
  box-shadow: 0 0 4px rgba(230, 180, 60, 0.4);
}

/* Error log rows */
.health-errors {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.health-error-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
}
.health-error-time {
  color: var(--text-dim);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.health-error-unit {
  color: var(--error);
  font-weight: 500;
  flex-shrink: 0;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.health-error-msg {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* Security details (collapsible sections) */
.health-details {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.health-details-summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85em;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  user-select: none;
  transition: background 0.15s;
}
.health-details-summary:hover {
  background: var(--bg-hover, var(--border));
}
.health-details[open] > .health-details-summary {
  border-bottom: 1px solid var(--border);
}
.health-details > .health-errors {
  padding: 8px 12px;
}
.health-res--warn {
  border-left: 2px solid #e6b43c;
}

/* Mobile: stack resources single column */
@media (max-width: 400px) {
  .health-resources {
    grid-template-columns: 1fr;
  }
  .health-error-row {
    flex-wrap: wrap;
  }
  .health-error-msg {
    white-space: normal;
    flex-basis: 100%;
  }
}





/* ── Command Center mode ── */
#command-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

#app.command-mode #command-view {
  display: flex;
}

#app.command-mode #chat,
#app.command-mode #input-wrapper,
#app.command-mode #scroll-bottom-btn {
  display: none !important;
}

/* Finance view */
#finance-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#finance-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  overscroll-behavior-y: contain;
}

#app.finance-mode #finance-view {
  display: flex;
}

#app.finance-mode #chat,
#app.finance-mode #input-wrapper,
#app.finance-mode #scroll-bottom-btn,
#app.finance-mode #command-view,
#app.finance-mode #more-view,
#app.finance-mode #marketing-view {
  display: none !important;
}

/* Marketing view */
#marketing-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#marketing-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  overscroll-behavior-y: contain;
}

#app.marketing-mode #marketing-view {
  display: flex;
}

#app.marketing-mode #chat,
#app.marketing-mode #input-wrapper,
#app.marketing-mode #scroll-bottom-btn,
#app.marketing-mode #command-view,
#app.marketing-mode #more-view,
#app.marketing-mode #finance-view {
  display: none !important;
}

/* ── Bottom Tab Bar ── */
#tab-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 56px;
  background: rgba(9, 9, 11, 0.94);
  backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #tab-bar {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(56px + env(safe-area-inset-bottom));
  }
}

.tab-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color var(--duration-fast) var(--ease-out);
  min-height: 48px;
  padding: 8px 0 6px;
}

.tab-bar-item span {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.tab-bar-item svg {
  transition: transform var(--duration-fast) var(--ease-out);
}

.tab-bar-item.active {
  color: var(--accent);
}

.tab-bar-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  width: 24px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}

.tab-bar-item:active svg {
  transform: scale(0.9);
}

.tab-bar-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  transform: translateX(24px);
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* Hide tab bar when keyboard is open on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  #tab-bar { display: none; }
}

/* ── Command Center Feed ── */
.cc-feed {
  position: relative;
  flex: 1;
  overflow-y: auto;
  background: linear-gradient(to bottom, rgba(239, 68, 68, 0.025) 0%, transparent 28%);
  padding: 12px;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
}

.cc-feed::-webkit-scrollbar { display: none; }

/* Toolbar (refresh button) */
.cc-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 0 0 8px;
}
.cc-refresh-btn {
  background: var(--bg-tertiary, rgba(255,255,255,0.06));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  transition: color 0.15s, background 0.15s;
}
.cc-refresh-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover, rgba(255,255,255,0.1));
}
.cc-refresh-btn--spinning svg {
  animation: cc-spin 0.6s ease-in-out;
}
@keyframes cc-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@media (max-width: 768px) {
  .cc-toolbar { display: none; }
}

/* Group headers */
.cc-group-header {
  position: sticky;
  top: -12px;
  z-index: 2;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  padding: 14px 4px 6px;
  margin: 0 -12px;
  padding-left: 16px;
  padding-right: 16px;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 7px;
}
.cc-group-header::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cc-group-header.cc-group-urgent::before  { background: var(--error); box-shadow: 0 0 6px rgba(239,68,68,0.5); }
.cc-group-header.cc-group-normal::before  { background: var(--accent); }
.cc-group-header.cc-group-later::before   { background: var(--text-dim); }
.cc-group-header.cc-group--completed::before { background: var(--success); }

/* Card */
.cc-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.cc-card:active {
  background: var(--bg-tertiary);
}

/* Priority left border */
.cc-card.cc-priority-critical,
.cc-card.cc-priority-high {
  border-left: 3px solid var(--error);
}

.cc-card.cc-priority-low .cc-card-title,
.cc-card.cc-priority-low .cc-card-preview {
  color: var(--text-secondary);
}

/* Source color strip */
.cc-card[data-source="email"] { border-left-color: #3b82f6; }
.cc-card[data-source="teams"] { border-left-color: #6264A7; }
.cc-card[data-source="calendar"] { border-left-color: #2E7D4F; }
.cc-card[data-source="tasks"] { border-left-color: #E07A00; }
.cc-card[data-source="financial"] { border-left-color: #C0392B; }
.cc-card[data-source="system"] { border-left-color: #C0392B; }

/* Override for high/critical priority cards */
.cc-card.cc-priority-critical[data-source],
.cc-card.cc-priority-high[data-source] {
  border-left-width: 3px;
  border-left-style: solid;
}

/* Card source row */
.cc-card-source {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.cc-source-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cc-source-icon svg {
  width: 16px;
  height: 16px;
}

.cc-source-icon.cc-src-email { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.cc-source-icon.cc-src-teams { background: rgba(98, 100, 167, 0.1); color: #6264A7; }
.cc-source-icon.cc-src-calendar { background: rgba(46, 125, 79, 0.1); color: #2E7D4F; }
.cc-source-icon.cc-src-tasks { background: rgba(224, 122, 0, 0.1); color: #E07A00; }
.cc-source-icon.cc-src-financial { background: rgba(192, 57, 43, 0.1); color: #C0392B; }
.cc-source-icon.cc-src-system { background: rgba(192, 57, 43, 0.1); color: #C0392B; }
.cc-source-icon.cc-src-approval { background: rgba(230, 126, 34, 0.15); color: #E67E22; }
.cc-source-icon.cc-src-health { background: rgba(192, 57, 43, 0.1); color: #C0392B; }
.cc-source-icon.cc-src-briefing { background: rgba(46, 125, 79, 0.1); color: #2E7D4F; }
.cc-source-icon.cc-src-ga4 { background: rgba(66, 133, 244, 0.1); color: #4285F4; }

.cc-source-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.cc-card-sender {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.cc-card-time {
  font-size: 13px;
  color: var(--text-dim);
  margin-left: auto;
  flex-shrink: 0;
}

/* Card content */
.cc-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.cc-card-preview {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.cc-card-summary {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Card actions */
.cc-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

.cc-action-btn {
  padding: 7px 14px;
  height: 36px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.cc-action-btn:active {
  transform: scale(0.95);
  background: var(--bg-tertiary);
}

.cc-action-btn.cc-action-andy {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent-muted);
  margin-left: auto;
}

.cc-action-btn.cc-action-andy:active {
  background: rgba(59, 130, 246, 0.15);
}

/* ── Card row (Track C, 2026-05-08) ── */
/* Active cards use cc-card-active and the new row layout. The completed
   archive section keeps the legacy compact markup, so legacy rules above
   continue to apply there. */
.cc-card.cc-card-active {
  padding: 12px 16px;
}

.cc-card-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.cc-card-body {
  flex: 1 1 auto;
  min-width: 0; /* allow flex children to truncate */
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Avatar — 36px circle, identity scent on the left of every active row. */
.cc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  position: relative;
  /* 1px ringless border by default so the circle reads on dark bg without
     adding visual noise. Core-team override below thickens it in Care& Blue. */
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.cc-avatar--ring-core {
  /* 2px ring outside the circle in Care& Blue, signals core team at a glance. */
  box-shadow: 0 0 0 2px var(--care-blue);
}

.cc-avatar-initials {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.cc-avatar-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.cc-avatar-glyph svg {
  width: 18px;
  height: 18px;
}

/* Headline row: primary label + spacer + status pill + time + stop button. */
.cc-card-headline {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cc-card-primary {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.cc-card-spacer {
  flex: 1 1 auto;
}

.cc-card-active .cc-card-time {
  font-size: 13px;
  color: var(--text-dim);
  margin-left: 0;
  flex-shrink: 0;
}

/* Subtitle: chat name · source · time. Single line, muted. */
.cc-card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.cc-card-subtitle:empty {
  display: none;
}

/* Title row inside body: 14px semibold, single line on dense rows.
   Override existing .cc-card-title rule when nested under cc-card-body. */
.cc-card-active .cc-card-body > .cc-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0;
}

/* Inline Andy reply preview in Care& Blue. Truncates to 1 line. */
.cc-andy-reply {
  font-size: 13px;
  color: var(--care-blue);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cc-andy-reply--working {
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Stop button — visible only while Andy is mid-flight on a card. */
.cc-stop-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.12);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}
.cc-stop-btn:hover { background: rgba(239, 68, 68, 0.2); }
.cc-stop-btn:active { transform: scale(0.92); }

/* Tighten the body's gap so the title sits close to the subtitle. */
.cc-card-active .cc-card-summary {
  margin-top: 2px;
}

/* Override the legacy preview hide on active cards (we don't render preview anymore). */
.cc-card-active .cc-card-preview { display: none; }

/* Action row: keep dismiss/snooze/Open visible on mobile, fade-in on desktop hover. */
.cc-card-active .cc-card-actions {
  margin-top: 8px;
}

@media (hover: hover) and (pointer: fine) {
  .cc-card-active .cc-card-actions {
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
  }
  .cc-card-active:hover .cc-card-actions {
    opacity: 1;
  }
  .cc-card-active:hover {
    background: var(--bg-tertiary);
  }
}

/* Card expand (inline detail) */
.cc-card-detail {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.cc-card.expanded .cc-card-detail {
  display: block;
}

.cc-card.expanded .cc-card-preview,
.cc-card.expanded .cc-card-summary {
  -webkit-line-clamp: unset;
  display: block;
}

.cc-card.expanded .cc-card-title {
  -webkit-line-clamp: unset;
}

.cc-detail-content {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
}

/* Andy instruction bar inside expanded card */
.cc-andy-bar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.cc-andy-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  min-height: 44px;
  max-height: 120px;
  overflow-y: auto;
  resize: none;
  line-height: 1.4;
}

.cc-andy-input:focus {
  border-color: var(--border-focus);
}

.cc-andy-input::placeholder {
  color: var(--text-dim);
}

.cc-andy-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--duration-fast);
}

.cc-andy-send:active {
  background: var(--accent-hover);
  transform: scale(0.95);
}

/* Confirmation preview */
.cc-confirm {
  background: var(--accent-subtle);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 10px;
}

.cc-confirm-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 6px;
}

.cc-confirm-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
}

.cc-confirm-actions {
  display: flex;
  gap: 8px;
}

.cc-confirm-btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  min-height: 40px;
  transition: all var(--duration-fast);
}

.cc-confirm-send {
  background: var(--accent);
  color: #fff;
}

.cc-confirm-send:active { background: var(--accent-hover); }

.cc-confirm-cancel {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Card states */
.cc-card.cc-actioned {
  background: rgba(92, 184, 122, 0.06);
  border-color: rgba(92, 184, 122, 0.2);
  opacity: 0.7;
}

.cc-card.cc-snoozed {
  opacity: 0.5;
}

.cc-card.cc-pending-action {
  background: var(--accent-subtle);
  border-color: rgba(59, 130, 246, 0.2);
}

/* Card animations */
@keyframes ccCardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ccCardOut {
  from { opacity: 1; transform: translateX(0); max-height: 200px; margin-bottom: 8px; padding: 14px 16px; }
  to { opacity: 0; transform: translateX(-100%); max-height: 0; margin-bottom: 0; padding: 0 16px; }
}

.cc-card-enter {
  animation: ccCardIn 0.25s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.cc-card-exit {
  animation: ccCardOut 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

/* Snooze time picker menu */
.cc-snooze-menu {
  z-index: 1000;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  overflow: hidden;
  min-width: 140px;
}
.cc-snooze-option {
  display: block;
  width: 100%;
  padding: 11px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}
.cc-snooze-option:active { background: var(--bg-tertiary); }
.cc-snooze-option + .cc-snooze-option { border-top: 1px solid var(--border); }

/* Working card status indicators */
.cc-status-badge {
  font-size: 0.72em;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cc-status-badge--review {
  background: rgba(46, 204, 113, 0.15);
  color: #2ecc71;
}
.cc-status-badge--working {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent);
}
.cc-status-badge--commit {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}
.cc-commitments {
  margin-top: 8px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(234, 179, 8, 0.06);
  border-left: 3px solid #eab308;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cc-commitment {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88em;
}
.cc-commitment-text { flex: 1; color: var(--text); }
.cc-commitment-backstop {
  font-size: 0.85em;
  color: #eab308;
  cursor: help;
}
.cc-commitment-done {
  padding: 3px 10px;
  font-size: 0.82em;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.cc-commitment-done:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}
.cc-mini-spinner {
  width: 10px; height: 10px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cc-unread-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(59, 130, 246, 0.5);
}
.cc-thread-count {
  font-size: 0.75em;
  color: var(--text-muted);
}

/* Working card left border accent */
.cc-card-working { border-left: 3px solid var(--accent); }
.cc-status-review { border-left-color: #2ecc71; }

/* Completed cards */
.cc-card-completed { opacity: 0.55; }
.cc-card-completed:active { opacity: 0.8; }
.cc-completed-section { margin-top: 12px; }
.cc-group-header--completed {
  cursor: pointer;
  list-style: none;
  color: var(--text-muted);
}
.cc-group-header--completed::marker { display: none; }
.cc-group-header--completed::-webkit-details-marker { display: none; }
.cc-day-label {
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 12px 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cc-done-icon {
  font-size: 13px;
  margin-right: 4px;
  font-weight: 600;
}
.cc-done-complete { color: #2ecc71; }
.cc-done-dismissed { color: var(--text-muted); opacity: 0.6; }

/* Badge review highlight */
.cc-badge--review { background: #2ecc71 !important; }

/* Context strip (provenance bar + expandable source) */
.cc-context-strip {
  flex-shrink: 0;
}
.cc-provenance-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cc-provenance-bar:active {
  background: rgba(22, 27, 36, 0.9);
}
.cc-provenance-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-dim);
}
.cc-provenance-icon svg {
  width: 20px;
  height: 20px;
}
.cc-provenance-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.cc-provenance-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.cc-provenance-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}
.cc-provenance-time {
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.cc-provenance-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-dim);
  transition: transform 0.25s ease;
}
.cc-provenance-chevron.expanded {
  transform: rotate(180deg);
}
.cc-context-expanded {
  max-height: 0;
  opacity: 0;
  overflow-y: auto;
  background: var(--bg);
  padding: 0 16px;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
  scrollbar-width: thin;
}
.cc-context-expanded.open {
  max-height: 35vh;
  opacity: 1;
  padding: 12px 16px;
}
/* Teams compact timeline in context strip */
.cc-ctx-msg {
  margin-bottom: 10px;
}
.cc-ctx-msg:last-child {
  margin-bottom: 0;
}
.cc-ctx-msg-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
}
.cc-ctx-msg-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.cc-ctx-msg-time {
  font-size: 11px;
  color: var(--text-dim);
}
.cc-ctx-msg-body {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cc-ctx-thread .cc-ctx-msg-body {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
  white-space: pre-line;
}
/* Email in context strip */
.cc-ctx-email-subject {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.cc-ctx-email-sender {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.cc-ctx-email-body {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
/* Calendar key-value in context strip */
.cc-ctx-kv {
  display: flex;
  gap: 8px;
  padding: 4px 0;
}
.cc-ctx-kv-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  width: 50px;
  flex-shrink: 0;
}
.cc-ctx-kv-value {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Turn Cards thread */
.cc-turns {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.cc-turn {
  padding-bottom: 20px;
  margin-bottom: 0;
}
.cc-turn + .cc-turn {
  border-top: 1px solid rgba(255,255,255,0.04);
  padding-top: 20px;
}
.cc-turn-instruction {
  background: rgba(59, 130, 246, 0.06);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
}
.cc-turn-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}
.cc-turn-label-you {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}
.cc-turn-label-andy {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.cc-turn-time {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: auto;
}
.cc-turn-instruction-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}
.cc-turn-response {
  padding: 12px 0 0 6px;
}
.cc-turn-response-text {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.6;
  word-break: break-word;
}
.cc-turn-response-text .cc-md {
  font-size: 14px;
}
/* Auto-collapse for long responses */
.cc-turn-response-wrap {
  position: relative;
  overflow: hidden;
}
.cc-turn-response-wrap.collapsed {
  max-height: 4.8em; /* ~3 lines at 1.6 line-height */
}
.cc-turn-response-wrap.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}
.cc-turn-expand {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-top: 8px;
  min-height: 44px;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.cc-turn-expand:active {
  opacity: 0.7;
}
/* File attachments within turn cards */
.cc-thread-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.cc-thread-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.15);
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
  font-size: 13px;
}
.cc-thread-file:active { opacity: 0.7; }
.cc-thread-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  color: var(--accent);
  font-size: 13px;
}

/* Progress log for working cards */
.cc-progress-log {
  padding: 10px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cc-progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  opacity: 0.5;
  font-size: 12px;
  color: var(--text-secondary);
  transition: opacity 0.2s;
}

.cc-progress-step-latest {
  opacity: 1;
  color: var(--accent);
}

.cc-progress-icon {
  width: 16px;
  flex-shrink: 0;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cc-progress-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.cc-progress-ts {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* Complete button row (above input bar in footer) */
.cc-detail-complete-row {
  padding: 0 0 10px;
}
.cc-detail-complete-btn {
  width: 100%;
  height: 48px;
  background: rgba(46, 204, 113, 0.08);
  border: none;
  border-radius: 10px;
  color: var(--success);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.cc-detail-complete-btn:active { background: rgba(46, 204, 113, 0.15); }

/* File attachment in detail view */
.cc-andy-attach {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.cc-andy-attach:active { background: var(--bg-tertiary); }

.cc-detail-attached {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px 0;
}
.cc-attached-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.cc-attached-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}

/* Quick action chips (suggested by Andy) */
.cc-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-top: 8px;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.cc-chips::-webkit-scrollbar { display: none; }

.cc-chip {
  flex-shrink: 0;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
  transition: all var(--duration-fast);
}

.cc-chip:active {
  background: var(--accent-subtle);
  border-color: var(--accent-muted);
  color: var(--accent);
}

/* Skeleton loading */
.cc-skeleton .cc-skeleton-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 8px;
}

.cc-skeleton-line {
  height: 12px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  animation: skeletonPulse 1.5s ease-in-out infinite;
  margin-bottom: 8px;
}

.cc-skeleton-line:nth-child(1) { width: 40%; height: 10px; }
.cc-skeleton-line:nth-child(2) { width: 75%; height: 14px; }
.cc-skeleton-line:nth-child(3) { width: 90%; }
.cc-skeleton-line:nth-child(4) { width: 60%; }

/* Empty state */
.cc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 24px;
  position: relative;
}

.cc-empty::before {
  content: '';
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(92, 184, 122, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

.cc-empty-icon {
  margin-bottom: 16px;
  opacity: 0.9;
}

.cc-empty-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.cc-empty-subtitle {
  font-size: 15px;
  color: var(--text-muted);
}

/* Pull to refresh indicator */
.cc-pull-indicator {
  text-align: center;
  padding: 12px;
  color: var(--text-dim);
  font-size: 13px;
  display: none;
}

.cc-pull-indicator.active {
  display: block;
}

.cc-pull-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: activitySpin 0.8s linear infinite;
  margin: 0 auto 6px;
}

/* ── Card Detail View (full-screen slide-in) ── */
#cc-detail-view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 15;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

#cc-detail-view.open {
  display: flex;
  animation: ccDetailSlideIn var(--duration-normal) var(--ease-out);
}

@keyframes ccDetailSlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.cc-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(9, 9, 11, 0.88);
  backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  min-height: 48px;
}

.cc-detail-back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  padding: 8px 4px;
  min-height: 44px;
  border-radius: var(--radius-sm);
}

.cc-detail-back:active {
  transform: scale(0.97);
}

.cc-detail-back svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.cc-detail-source {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.cc-detail-actions-top {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
}

.cc-detail-snooze-btn,
.cc-detail-dismiss-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  min-height: 36px;
  transition: all var(--duration-fast);
}

.cc-detail-snooze-btn:active,
.cc-detail-dismiss-btn:active {
  background: var(--bg-tertiary);
}

/* Stop button in the detail header. Surfaces only when the open card is
   actively working (Andy mid-flight). Mirrors the row stop affordance in red. */
.cc-detail-stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
  color: var(--error, #ef4444);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
  transition: background var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
}
.cc-detail-stop-btn:hover { background: rgba(239, 68, 68, 0.2); }
.cc-detail-stop-btn:active { transform: scale(0.97); }
.cc-detail-stop-btn[disabled] { opacity: 0.5; cursor: default; }
.cc-detail-stop-btn .cc-detail-stop-spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid rgba(239, 68, 68, 0.35);
  border-top-color: var(--error, #ef4444);
  border-radius: 50%;
  animation: ccDetailStopSpin 0.7s linear infinite;
}
@keyframes ccDetailStopSpin {
  to { transform: rotate(360deg); }
}

/* Financial detail: prominent dollar figure for the alert. */
.cc-financial-amount {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  margin: 4px 0 8px;
  letter-spacing: -0.01em;
}
.cc-financial-amount--negative { color: var(--error, #ef4444); }

.cc-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.cc-detail-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  padding: 24px;
  font-size: 15px;
}

.cc-detail-sender {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.cc-detail-sender-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.cc-detail-sender-info {
  flex: 1;
  min-width: 0;
}

.cc-detail-sender-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.cc-detail-sender-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 1px;
}

.cc-detail-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 12px;
  word-break: break-word;
  overflow-wrap: break-word;
}

.cc-detail-summary {
  font-size: 14px;
  color: var(--accent);
  font-style: italic;
  line-height: 1.4;
  margin-bottom: 14px;
  padding: 8px 12px;
  background: var(--accent-subtle);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-muted);
}

.cc-detail-full-content {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.cc-manual-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 13px;
}

.cc-manual-priority {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}

.cc-manual-date {
  color: var(--text-muted);
}

.cc-manual-body {
  padding-left: 12px;
  border-left: 2px solid var(--border, rgba(255, 255, 255, 0.06));
  margin-top: 4px;
}

/* Lightweight markdown rendering for card bodies */
.cc-md {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
  word-break: break-word;
}
.cc-md p {
  margin: 0 0 12px 0;
}
.cc-md p:last-child {
  margin-bottom: 0;
}
.cc-md ul, .cc-md ol {
  margin: 8px 0 12px 0;
  padding-left: 20px;
}
.cc-md ul {
  list-style: none;
}
.cc-md ul li {
  position: relative;
}
.cc-md ul li::before {
  content: "\00B7";
  position: absolute;
  left: -14px;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 16px;
}
.cc-md li {
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.5;
}
.cc-md li:last-child {
  margin-bottom: 0;
}
.cc-md strong {
  font-weight: 600;
  color: var(--text);
}
.cc-md code {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 0.87em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}
.cc-md a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}
.cc-md h1, .cc-md h2, .cc-md h3, .cc-md h4 {
  font-weight: 600;
  color: var(--text);
  margin: 16px 0 8px 0;
  line-height: 1.3;
}
.cc-md h1 { font-size: 1.25em; }
.cc-md h2 { font-size: 1.15em; }
.cc-md h3 { font-size: 1.05em; }
.cc-md h4 { font-size: 1em; }
.cc-md h1:first-child, .cc-md h2:first-child, .cc-md h3:first-child, .cc-md h4:first-child {
  margin-top: 0;
}
.cc-md pre {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0 12px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cc-md pre code {
  background: none;
  border-radius: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
}
.cc-md blockquote {
  border-left: 3px solid var(--accent-muted, rgba(255,255,255,0.15));
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-muted);
  font-style: italic;
}
.cc-md table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 12px 0;
  font-size: 13px;
}
.cc-md th, .cc-md td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-align: left;
}
.cc-md th {
  font-weight: 600;
  color: var(--text);
}
.cc-md hr {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin: 12px 0;
}
.cc-md em {
  font-style: italic;
}

/* Compact variant for context strip */
.cc-md--compact {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}
.cc-md--compact p {
  margin: 0 0 6px 0;
}
.cc-md--compact ul, .cc-md--compact ol {
  margin: 4px 0 6px 0;
  padding-left: 14px;
}
.cc-md--compact li {
  margin-bottom: 3px;
  font-size: 13px;
}
.cc-md--compact strong {
  color: var(--text-secondary);
}
.cc-md--compact code {
  font-size: 0.87em;
}

/* Teams messages in detail */
.cc-detail-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cc-detail-msg {
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.cc-detail-msg-from {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.cc-detail-msg-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.cc-detail-msg-time {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Teams message inline attachments */
.cc-msg-attachments {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.cc-msg-att-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary, rgba(0,0,0,0.05));
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  width: fit-content;
}
.cc-msg-att-file a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
}
.cc-msg-att-icon {
  font-size: 15px;
  flex-shrink: 0;
}
.cc-msg-att-name {
  word-break: break-all;
}
/* Email attachment section */
.cc-email-attachments {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}
.cc-email-att-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.cc-email-att-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
}
.cc-email-att-size {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Calendar event detail */
.cc-detail-event-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.cc-detail-event-row:last-child {
  border-bottom: none;
}

.cc-detail-event-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  width: 80px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cc-detail-event-value {
  font-size: 15px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Footer with chips + andy bar */
.cc-detail-footer {
  flex-shrink: 0;
  padding: 10px 14px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-subtle);
  background: rgba(9, 9, 11, 0.88);
  backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) brightness(1.05) saturate(1.4);
}

.cc-detail-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 8px;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.cc-detail-chips::-webkit-scrollbar { display: none; }

.cc-detail-chips:empty {
  display: none;
  margin-bottom: 0;
}

.cc-detail-andy-bar {
  display: flex;
  gap: 8px;
}

/* Ripple effect for Android (Material Design) */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.15) 10%, transparent 10%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.4s, opacity 0.8s;
}

.ripple:active::after {
  transform: scale(0, 0);
  opacity: 0.3;
  transition: 0s;
}

/* ── More view Files section ── */
#app.more-mode #more-view #files-view {
  display: none;
}

/* Hide input wrapper when not in chat mode */
#app.command-mode #input-wrapper,
#app.more-mode #input-wrapper,
#app.finance-mode #input-wrapper,
#app.marketing-mode #input-wrapper {
  display: none !important;
}

@media (max-width: 380px) {
  .tab-bar-item span {
    font-size: 10px;
  }
  .tab-bar-item svg {
    width: 20px;
    height: 20px;
  }
}

/* ── Morning Briefing Card ── */
.briefing-card { padding: 12px 8px; }

.briefing-headline {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  min-height: 24px;
}
.briefing-headline.briefing-skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary, rgba(255,255,255,0.08)) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: briefingSkeleton 1.5s ease-in-out infinite;
  border-radius: 6px;
  border-bottom: none;
}
@keyframes briefingSkeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Updated timestamp */
.briefing-updated {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: -14px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.briefing-section {
  margin-bottom: 18px;
  padding-top: 4px;
}
.briefing-section + .briefing-section {
  border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
  padding-top: 14px;
}
.briefing-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Action tier sections (Waiting on You, Alerts) */
.briefing-section--action .briefing-section-label {
  color: #ff9f43;
  letter-spacing: 1px;
}
.briefing-section--action .briefing-section-label::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff9f43;
  margin-right: 2px;
  animation: actionPulse 2s ease-in-out infinite;
}
@keyframes actionPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Count badge */
.briefing-section-count {
  font-size: 10px;
  font-weight: 700;
  background: #ff9f43;
  color: #09090b;
  border-radius: 10px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

/* Overnight messages */
.briefing-item {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 6px 0;
  line-height: 1.45;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
}
.briefing-item:last-child { border-bottom: none; }
.briefing-item-sender {
  font-weight: 600;
  color: var(--text);
}
.briefing-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Overflow toggle for capped sections */
.briefing-overflow-item { display: none; }
.briefing-overflow-expanded .briefing-overflow-item { display: block; }
.briefing-overflow-toggle {
  font-size: 13px;
  color: var(--accent);
  padding: 8px 0;
  cursor: pointer;
  font-weight: 500;
}

/* Waiting on You items */
.briefing-action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  margin: 2px -8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
}
.briefing-action-item:active,
.briefing-action-item:hover { background: var(--bg-secondary); }
.briefing-action-from {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.briefing-action-summary {
  font-size: 14px;
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.briefing-action-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Calendar items */
.briefing-cal-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 6px 0;
  line-height: 1.4;
}
.briefing-cal-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 90px;
  flex-shrink: 0;
}
.briefing-online-badge {
  font-size: 11px;
  color: #5cb87a;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Tech alerts */
.briefing-alert-item {
  font-size: 14px;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  line-height: 1.4;
}

/* Stat grid (Business Signals) */
.briefing-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.briefing-stat-cell {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.briefing-stat-cell--highlight {
  grid-column: 1 / -1;
}
.briefing-stat-cell--red {
  border-left: 3px solid #ff7b72;
  background: rgba(255, 123, 114, 0.06);
}
.briefing-stat-cell--yellow {
  border-left: 3px solid #f0c674;
  background: rgba(240, 198, 116, 0.04);
}
.briefing-stat-cell--green {
  border-left: 3px solid #5cb87a;
  background: rgba(92, 184, 122, 0.04);
}

.briefing-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.briefing-stat-value {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.briefing-stat-cell--highlight .briefing-stat-value {
  font-size: 22px;
}
.briefing-stat-context {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Business signals flag items */
.briefing-biz-item {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 5px 0;
}

/* Signal flags */
.briefing-signal-flag--red {
  color: #ff7b72;
  background: rgba(255, 123, 114, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  border-left: 2px solid rgba(255, 123, 114, 0.4);
}
.briefing-signal-flag--yellow {
  color: #f0c674;
  background: rgba(240, 198, 116, 0.08);
  padding: 4px 8px;
  border-radius: 6px;
  border-left: 2px solid rgba(240, 198, 116, 0.3);
}
.briefing-signal-flag--green {
  color: #5cb87a;
  background: rgba(92, 184, 122, 0.08);
  padding: 4px 8px;
  border-radius: 6px;
  border-left: 2px solid rgba(92, 184, 122, 0.3);
}

.briefing-unavailable {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
}

.briefing-all-clear {
  font-size: 15px;
  color: var(--text-secondary);
  text-align: center;
  padding: 20px 0;
}

.briefing-ask-andy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 14px;
  margin-top: 20px;
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.briefing-ask-andy:hover,
.briefing-ask-andy:active {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .briefing-section--action .briefing-section-label::before { animation: none; opacity: 1; }
  .briefing-headline.briefing-skeleton { animation: none; }
}


/* ══════════════════════════════════════════════════════════════════════════════
   Desktop Layout (1024px+)
   All rules below are scoped to @media (min-width: 1024px).
   Mobile styles are untouched.
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── 1. Tab bar → left sidebar rail ──
   Strategy: Keep #app as flex-column (don't fight JS inline style).
   Make #tab-bar a fixed left sidebar. Offset all content with margin-left.
   This avoids CSS Grid auto-placement issues with overlays/drawers. */
@media (min-width: 1024px) {
  #tab-bar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 72px;
    height: 100vh;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    justify-content: flex-start;
    padding: 60px 0 12px;
    gap: 4px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg, #09090b);
    z-index: 100;
  }

  .tab-bar-item {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    min-height: 56px;
    padding: 10px 0 8px;
    border-radius: 0;
  }

  /* Active indicator: left edge instead of top edge */
  .tab-bar-item.active::after {
    top: 50%;
    left: 0;
    right: auto;
    bottom: auto;
    width: 3px;
    height: 24px;
    border-radius: 0 2px 2px 0;
    transform: translateY(-50%);
  }

  .tab-bar-badge {
    top: 6px;
    right: 50%;
    transform: translateX(20px);
  }

  /* Offset everything else to make room for the sidebar */
  #header {
    margin-left: 72px;
  }

  #chat,
  #command-view,
  #finance-view,
  #marketing-view,
  #more-view,
  #files-view {
    margin-left: 72px;
  }

  #input-wrapper {
    margin-left: 72px;
  }

  #scroll-bottom-btn {
    margin-left: 72px;
  }

  /* Remove bottom padding that was for the mobile tab bar */
  #chat,
  #command-view,
  #finance-view,
  #marketing-view,
  #more-view,
  #files-view {
    padding-bottom: 0;
  }

  /* History drawer: offset by sidebar width */
  #history-overlay {
    left: 72px;
  }

  #history-drawer {
    left: 72px;
  }
}

/* ── 2. Command Center multi-column card grid ── */
@media (min-width: 1024px) {
  #cc-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-width: 1200px;
    margin: 0 auto;
  }

  /* Group headers span full width */
  .cc-group-header {
    grid-column: 1 / -1;
  }

  .cc-feed {
    padding: 16px 24px;
  }

  /* CC detail view: side panel instead of full takeover */
  #cc-detail-view {
    left: auto;
    width: 520px;
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.3);
  }
}

@media (min-width: 1440px) {
  #cc-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── 3. Desktop scrollbars ── */
@media (min-width: 1024px) {
  #chat,
  .cc-feed,
  #finance-content,
  #marketing-content,
  #tools-launcher,
  #panel-content,
  #history-list,
  .files-list,
  .cc-detail-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
  }

  #chat::-webkit-scrollbar,
  .cc-feed::-webkit-scrollbar,
  #finance-content::-webkit-scrollbar,
  #marketing-content::-webkit-scrollbar,
  #tools-launcher::-webkit-scrollbar,
  #panel-content::-webkit-scrollbar,
  #history-list::-webkit-scrollbar,
  .files-list::-webkit-scrollbar,
  .cc-detail-body::-webkit-scrollbar {
    display: block;
    width: 6px;
  }

  #chat::-webkit-scrollbar-track,
  .cc-feed::-webkit-scrollbar-track,
  #finance-content::-webkit-scrollbar-track,
  #marketing-content::-webkit-scrollbar-track,
  #tools-launcher::-webkit-scrollbar-track,
  #panel-content::-webkit-scrollbar-track,
  #history-list::-webkit-scrollbar-track,
  .files-list::-webkit-scrollbar-track,
  .cc-detail-body::-webkit-scrollbar-track {
    background: transparent;
  }

  #chat::-webkit-scrollbar-thumb,
  .cc-feed::-webkit-scrollbar-thumb,
  #finance-content::-webkit-scrollbar-thumb,
  #marketing-content::-webkit-scrollbar-thumb,
  #tools-launcher::-webkit-scrollbar-thumb,
  #panel-content::-webkit-scrollbar-thumb,
  #history-list::-webkit-scrollbar-thumb,
  .files-list::-webkit-scrollbar-thumb,
  .cc-detail-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
  }

  #chat::-webkit-scrollbar-thumb:hover,
  .cc-feed::-webkit-scrollbar-thumb:hover,
  #finance-content::-webkit-scrollbar-thumb:hover,
  #marketing-content::-webkit-scrollbar-thumb:hover,
  #tools-launcher::-webkit-scrollbar-thumb:hover,
  #panel-content::-webkit-scrollbar-thumb:hover,
  #history-list::-webkit-scrollbar-thumb:hover,
  .files-list::-webkit-scrollbar-thumb:hover,
  .cc-detail-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
  }
}

/* ── 4. Chat width constraint ── */
@media (min-width: 1024px) {
  #chat {
    padding: 24px 0;
  }

  #messages {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 24px;
  }

  #empty-state {
    max-width: 720px;
    margin: 0 auto;
  }

  .message.user {
    max-width: 560px;
  }

  #input-area {
    max-width: 720px;
    margin: 0 auto;
  }

  #bottom-actions {
    max-width: 720px;
    margin: 0 auto;
  }

  #input-wrapper {
    border-top: none;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0 24px 16px;
  }
}

/* ── 5. Tools/More view card grid ── */
@media (min-width: 1024px) {
  .tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    max-width: 900px;
  }

  .tool-launcher-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
  }

  .tool-launcher-card:last-child {
    border-bottom: 1px solid var(--border);
  }

  .tool-launcher-card:hover {
    background: var(--bg-elevated);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
  }
}

/* ── 6. Panel content max-widths ── */
@media (min-width: 1024px) {
  #panel-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 32px;
  }

  #tools-launcher {
    padding: 24px 32px;
  }

  .health-services {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── 7. Hover states ── */
@media (min-width: 1024px) {
  .cc-card:hover {
    background: var(--bg-tertiary);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .tab-bar-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
  }

  .tab-bar-item.active:hover {
    color: var(--accent);
  }

  .cc-action-btn:hover {
    background: var(--bg-tertiary);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--text);
  }

  .cc-action-btn.cc-action-andy:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.5);
  }

  /* CC card actions: fade in on hover */
  .cc-card .cc-card-actions {
    opacity: 0.5;
    transition: opacity var(--duration-fast) var(--ease-out);
  }

  .cc-card:hover .cc-card-actions {
    opacity: 1;
  }

  #bottom-actions button:hover {
    transform: translateY(-1px);
  }

  .cc-snooze-option:hover {
    background: var(--bg-tertiary);
  }
}

/* ── 8. Touch target reduction ── */
@media (min-width: 1024px) {
  .header-menu {
    min-width: 36px;
    min-height: 36px;
    padding: 6px;
  }

  .cc-action-btn {
    padding: 5px 12px;
    height: 32px;
    font-size: 13px;
  }

  .cc-snooze-option {
    padding: 8px 16px;
    min-height: 36px;
  }

  #bottom-actions button {
    padding: 8px 12px;
    min-height: 36px;
    font-size: 13px;
  }

  .cc-detail-snooze-btn,
  .cc-detail-dismiss-btn {
    padding: 5px 12px;
    min-height: 32px;
  }

  .tab-bar-item {
    min-height: 48px;
    padding: 8px 0 6px;
  }
}

/* ── 9. Finance/Marketing max-widths ── */
@media (min-width: 1024px) {
  #finance-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 32px;
  }

  #marketing-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 32px;
  }

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

  .finance-kpi {
    padding: 16px;
  }

  .kpi-value {
    font-size: 20px;
  }

  .finance-kpi.kpi-large .kpi-value {
    font-size: 28px;
  }
}

/* ── 10. History drawer ── */
@media (min-width: 1024px) {
  #history-drawer {
    max-width: 360px;
    width: 360px;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
  }
}

/* ── 11. Logs Panel (Control Room) ── */

/* Panel header bar with live indicator */
.logs-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 2px;
}
.logs-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.logs-live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.logs-live-indicator--offline {
  color: var(--error);
}
.logs-live-indicator--offline .logs-live-dot {
  background: var(--error);
  animation: none;
}
.logs-live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: logs-live-pulse 2s ease-in-out infinite;
}
@keyframes logs-live-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* Stats bar */
.logs-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.logs-stat-pill {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 10px 6px 8px;
  text-align: center;
  border: 1px solid transparent;
}
.logs-stat-pill.logs-stat--error {
  background: rgba(224, 96, 96, 0.06);
  border-color: rgba(224, 96, 96, 0.18);
}
.logs-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.logs-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.logs-stat-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.logs-stat-value--good { color: var(--success); }
.logs-stat-value--bad { color: var(--error); }
.logs-stat-skeleton {
  height: 20px;
  width: 36px;
  margin: 0 auto;
  background: var(--bg-elevated);
  border-radius: 4px;
  animation: logs-pulse 1.2s ease-in-out infinite;
}
@keyframes logs-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

/* Loki offline banner */
.logs-offline-banner {
  background: rgba(224, 96, 96, 0.06);
  border: 1px solid rgba(224, 96, 96, 0.18);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--error);
  font-size: 14px;
  text-align: center;
  margin-bottom: 14px;
}

/* Error spotlight */
.logs-spotlight {
  background: rgba(224, 96, 96, 0.05);
  border: 1px solid rgba(224, 96, 96, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.logs-spotlight-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--error);
}
.logs-spotlight-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
  letter-spacing: 0.02em;
}
.logs-spotlight-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(224, 96, 96, 0.08);
  cursor: pointer;
  font-size: 14px;
  transition: opacity 0.1s;
}
.logs-spotlight-item:last-of-type { border-bottom: none; }
.logs-spotlight-item:active { opacity: 0.6; }
.logs-spotlight-action { color: var(--text-secondary); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logs-spotlight-err { color: var(--error); font-size: 12px; max-width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.logs-spotlight-ago { color: var(--text-dim); font-size: 12px; flex-shrink: 0; }
.logs-spotlight-chevron { color: var(--text-dim); flex-shrink: 0; }
.logs-spotlight-more { text-align: center; font-size: 12px; color: var(--text-dim); padding-top: 8px; }

/* 7-day error group summary */
.logs-groups {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.logs-groups-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  padding: 0 2px;
}
.logs-groups-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.logs-group-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.logs-group-err {
  color: var(--text-secondary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logs-group-count {
  font-weight: 600;
  color: var(--error);
  flex-shrink: 0;
  font-size: 12px;
}
.logs-group-ago {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Tool filter chips */
.logs-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.logs-filters::-webkit-scrollbar { display: none; }
.logs-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.logs-chip:active { transform: scale(0.96); }
.logs-chip--active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent-muted);
}

/* Live feed list */
.logs-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Session grouping */
.logs-session-group {
  border-left: 3px solid var(--accent-muted);
  margin-left: 4px;
  padding-left: 8px;
  margin-bottom: 6px;
}
.logs-session-label {
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 0 2px 4px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* Row */
.logs-row--error {
  border-left: 3px solid var(--error);
  background: rgba(224, 96, 96, 0.04);
}
.logs-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: hidden;
}

/* Tool badge with color */
.logs-tool-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  white-space: nowrap;
}
.logs-tool-badge--sm {
  font-size: 10px;
  padding: 1px 6px;
}
.logs-action {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status dot */
.logs-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.logs-status-dot--ok { background: var(--success); }
.logs-status-dot--error { background: var(--error); }

.logs-dur {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.logs-row-time {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: auto;
  flex-shrink: 0;
}

.logs-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Detail view */
.logs-detail {
  padding: 4px 0;
}
.logs-detail-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}
.logs-detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.logs-detail-action {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.logs-detail-meta {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.logs-detail-status {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.logs-detail-status--ok { color: var(--success); background: rgba(92, 184, 122, 0.12); }
.logs-detail-status--error { color: var(--error); background: rgba(224, 96, 96, 0.12); }

.logs-detail-section {
  margin-bottom: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.logs-detail-section--error {
  border: 1px solid rgba(224, 96, 96, 0.15);
}
.logs-detail-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px 6px;
}
.logs-detail-section-title--error {
  color: var(--error);
}

.logs-detail-row {
  display: flex;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.logs-detail-row:last-child { border-bottom: none; }
.logs-detail-label {
  min-width: 72px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
}
.logs-detail-value {
  flex: 1;
  word-break: break-word;
  color: var(--text);
}
.logs-detail-error {
  color: var(--error);
}
.logs-detail-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}

/* Add Gotcha button */
.logs-gotcha-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 13px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.logs-gotcha-btn:active { background: var(--bg-elevated); }
.logs-gotcha-btn:disabled { opacity: 0.6; cursor: default; }
.logs-gotcha-btn--saved { color: var(--success); border-color: rgba(92, 184, 122, 0.25); background: rgba(92, 184, 122, 0.06); }

/* Logs panel - new controls */
.logs-controls {
  margin-bottom: 12px;
}
.logs-controls-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
.logs-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  min-width: 100px;
}
.logs-select:focus {
  outline: none;
  border-color: var(--accent);
}
.logs-search-wrap {
  flex: 1;
  min-width: 0;
}
.logs-search {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
}
.logs-search:focus {
  outline: none;
  border-color: var(--accent);
}
.logs-search::placeholder {
  color: var(--text-dim);
}
.logs-severity-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  min-width: 36px;
}
.logs-message {
  color: var(--text-secondary);
  font-size: 13px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
}
.logs-row--warn {
  background: rgba(240, 160, 48, 0.04);
  border-left: 2px solid rgba(240, 160, 48, 0.4);
}
.logs-stat--warn {
  border-color: rgba(240, 160, 48, 0.3);
}
.logs-stat-value--warn {
  color: #f0a030;
}
.logs-detail-message-full {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  word-break: break-word;
  white-space: pre-wrap;
}
.logs-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
  cursor: pointer;
  transition: background 0.12s;
}
.logs-row:active {
  background: var(--bg-tertiary);
}
.logs-row-time {
  color: var(--text-dim);
  font-size: 11px;
  flex-shrink: 0;
  text-align: right;
}

/* ── 12. Reduced motion for desktop animations ── */
@media (prefers-reduced-motion: reduce) and (min-width: 1024px) {
  .tool-launcher-card:hover {
    transform: none;
  }

  #bottom-actions button:hover {
    transform: none;
  }

  #cc-detail-view {
    animation: none;
  }
}

/* ── Version update banner (non-destructive PWA update prompt) ── */
#version-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--accent-muted);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0.01em;
  transform: translateY(-100%);
  transition: transform 200ms ease;
}

@supports (padding-top: env(safe-area-inset-top)) {
  #version-update-banner {
    padding-top: calc(10px + env(safe-area-inset-top));
  }
}

#version-update-banner.vub-visible {
  transform: translateY(0);
}

#version-update-banner .vub-text {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  overflow: hidden;
}

#version-update-banner .vub-title {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

#version-update-banner .vub-detail {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

#version-update-banner .vub-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

#version-update-banner .vub-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm, 6px);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-height: 32px;
}

#version-update-banner .vub-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#version-update-banner .vub-btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

#version-update-banner .vub-btn-ghost:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-focus);
}

#version-update-banner .vub-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 32px;
  min-height: 32px;
  border-radius: var(--radius-sm, 6px);
}

#version-update-banner .vub-close:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}

@media (max-width: 600px) {
  #version-update-banner {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }
  #version-update-banner .vub-text {
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 4px 10px;
  }
  #version-update-banner .vub-detail {
    font-size: 11px;
  }
  #version-update-banner .vub-actions {
    flex: 1 1 100%;
    justify-content: flex-end;
  }
  #version-update-banner .vub-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}
