/* ═══════════════════════════════════════════
   Claude For — Cue Design Language
   Based on CUE_ONBOARDING_DESIGN_SPEC.md
   ═══════════════════════════════════════════ */

:root {
  /* ─── Colors (Light) ─── */
  --bg: #f7f7f8;
  --bg-surface: #eeeff1;
  --bg-elevated: #f2f2f4;
  --bg-hover: #e9eaec;
  --border: #e3e4e6;
  --border-strong: #d4d5d8;

  --text: #1d1a1a;
  --text-secondary: #888888;
  --text-dim: #bbbbbb;
  --text-hint: #cccccc;

  --accent: #1d1a1a;
  --accent-hover: #333333;
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.08);
  --green: #059669;
  --green-dim: rgba(5, 150, 105, 0.06);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.06);
  --purple: #7c3aed;
  --purple-dim: rgba(124, 58, 237, 0.06);
  --orange: #d97706;

  /* ─── Typography ─── */
  --font: 'Inter', -apple-system, system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

  /* ─── Radius (from spec) ─── */
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius: 12px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --radius-badge: 5px;

  /* ─── Shadows ─── */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.06);

  /* ─── Pixel Art ─── */
  --pixel-primary: #d4956a;
  --pixel-dark: #a0694a;
  --pixel-eye: #3d2b1f;
  --pixel-highlight: #e8b894;
  --pixel-outline: #5c3d2e;
}

/* ─── Dark Theme ─── */
[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-surface: #242424;
  --bg-elevated: #2a2a2a;
  --bg-hover: #303030;
  --border: #333333;
  --border-strong: #444444;

  --text: #e8e4e0;
  --text-secondary: #999999;
  --text-dim: #666666;
  --text-hint: #555555;

  --accent: #e8e4e0;
  --accent-hover: #d0ccc8;
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.1);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.08);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.08);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.08);
  --orange: #fbbf24;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(37, 99, 235, 0.15);
  color: var(--text);
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

.hidden:not(.modal-overlay) {
  display: none !important;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 400px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  0%   { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1);    opacity: 1; }
}

.modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  display: grid;
  place-items: center;
  font-size: 28px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

.modal h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: var(--text);
}

.modal p {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.6;
}

.modal input {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  margin-bottom: 16px;
  transition: all 0.2s;
}

.modal input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-primary {
  width: 100%;
  height: 48px;
  padding: 0 32px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

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

.modal-hint {
  color: var(--text-dim) !important;
  font-size: 11px !important;
  margin-top: 16px !important;
  margin-bottom: 0 !important;
}

/* ─── Layout ─── */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 48px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  -webkit-app-region: drag;
  app-region: drag;
  user-select: none;
}

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

.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon {
  display: block;
}

.logo {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text);
}

#model-select {
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

#model-select:hover {
  border-color: var(--text-dim);
}

#model-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.cost {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 3px 10px;
  background: var(--bg-surface);
  border-radius: 20px;
  font-weight: 500;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.icon-btn:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text);
}

/* ─── Chat Area ─── */
#chat-area {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

#chat-area::-webkit-scrollbar {
  width: 5px;
}

#chat-area::-webkit-scrollbar-track {
  background: transparent;
}

#chat-area::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

#chat-area::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

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

/* ─── Welcome Screen ─── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  display: grid;
  place-items: center;
  font-size: 36px;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
  box-shadow: var(--shadow-md);
}

.welcome h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 8px;
}

.welcome .welcome-sub {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.welcome p {
  color: var(--text-secondary);
  max-width: 440px;
  margin-bottom: 32px;
  font-size: 14px;
  line-height: 1.6;
}

.welcome-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 520px;
}

.hint-chip {
  padding: 9px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  box-shadow: var(--shadow-sm);
}

.hint-chip:hover {
  border-color: var(--text-dim);
  color: var(--text);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.hint-chip:active {
  transform: scale(0.97);
}

/* ─── Messages ─── */
.message {
  margin-bottom: 24px;
  animation: fadeSlide 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.msg-user {
  display: flex;
  justify-content: flex-end;
}

.msg-user-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: 85%;
}

.msg-user .msg-content {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  padding: 12px 16px;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.msg-assistant {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

/* Message action bar (copy / regenerate) */
.msg-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
  align-self: flex-start;
  margin-bottom: 2px;
}

.msg-assistant:hover .msg-actions,
.msg-user-inner:hover .msg-actions {
  opacity: 1;
}

.msg-action-btn {
  padding: 4px 6px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.12s, background 0.12s;
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
}

.msg-action-btn:hover {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.06);
  opacity: 0.8;
}

/* ─── Collapsible Code Blocks ─── */
.code-block-wrapper {
  margin: 8px 0;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255,255,255,0.02);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  user-select: none;
  min-height: 30px;
  transition: background 0.12s;
}

.code-block-header:hover {
  background: rgba(255,255,255,0.04);
}

.code-block-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.code-lang-icon {
  flex-shrink: 0;
  color: var(--text-dim);
}

.code-block-summary {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-block-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.code-collapse-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: transform 0.2s, color 0.15s;
}

.code-collapse-btn:hover { color: var(--text); }
.code-block-wrapper.expanded .code-collapse-btn { transform: rotate(180deg); }

.code-block-wrapper > pre {
  display: none;
  margin: 0;
  border: none;
  border-radius: 0;
}

.code-block-wrapper.expanded > pre {
  display: block;
}

/* Code block copy */
.code-copy-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  z-index: 2;
  font-family: var(--font);
  transition: all 0.15s;
}

.code-copy-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.code-copy-btn.copied {
  color: var(--green);
  border-color: rgba(5, 150, 105, 0.35);
}

/* Thinking blocks (cloud SSE) — overridden by enhanced version below */
.thinking-block {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  overflow: hidden;
  font-size: 12px;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.thinking-header:hover {
  background: var(--bg-hover);
}

.thinking-icon {
  font-size: 14px;
}

.thinking-toggle {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.2s;
}

.thinking-block.expanded .thinking-toggle {
  transform: rotate(90deg);
}

.thinking-content {
  display: none;
  padding: 0 12px 12px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.thinking-block.expanded .thinking-content {
  display: block;
}

.msg-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
}

.msg-assistant .msg-content {
  padding: 4px 0;
  line-height: 1.7;
  color: var(--text);
}

.msg-assistant .msg-content p {
  margin-bottom: 12px;
}

.msg-assistant .msg-content p:last-child {
  margin-bottom: 0;
}

.msg-assistant .msg-content h1,
.msg-assistant .msg-content h2,
.msg-assistant .msg-content h3 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.msg-assistant .msg-content h1 { font-size: 20px; }
.msg-assistant .msg-content h2 { font-size: 18px; }
.msg-assistant .msg-content h3 { font-size: 16px; color: var(--text-secondary); }

.msg-assistant .msg-content ul,
.msg-assistant .msg-content ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.msg-assistant .msg-content li {
  margin-bottom: 4px;
}

.msg-assistant .msg-content code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-surface);
  padding: 2px 7px;
  border-radius: var(--radius-badge);
  color: var(--blue);
  border: 1px solid var(--border);
}

.msg-assistant .msg-content pre {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 12px 0;
  overflow-x: auto;
  position: relative;
}

.msg-assistant .msg-content pre code {
  background: none;
  padding: 0;
  border: none;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
}

.msg-assistant .msg-content a {
  color: var(--blue);
  text-decoration: none;
  text-underline-offset: 2px;
}

.msg-assistant .msg-content a:hover {
  text-decoration: underline;
}

.msg-assistant .msg-content blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 14px;
  color: var(--text-secondary);
  margin: 12px 0;
}

.msg-assistant .msg-content strong {
  font-weight: 700;
  color: var(--text);
}

.msg-assistant .msg-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 13px;
}

.msg-assistant .msg-content th,
.msg-assistant .msg-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.msg-assistant .msg-content th {
  background: var(--bg-surface);
  font-weight: 600;
}

/* ─── Tool Execution Cards ─── */
.tool-card {
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  overflow: hidden;
  margin: 4px 0;
  background: transparent;
  transition: border-color 0.2s;
  border-left: 2px solid var(--border);
}

.tool-card.tool-success { border-left-color: var(--border-strong); }
.tool-card.tool-error { border-left-color: rgba(248,113,113,0.4); }

.tool-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}

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

.tool-card-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 4px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.tool-card.tool-success .tool-card-icon { color: var(--text-dim); }
.tool-card.tool-error .tool-card-icon { color: rgba(248,113,113,0.6); }

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

.tool-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.tool-card-step {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255,255,255,0.06);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-card.tool-success .tool-card-step { color: var(--text-dim); background: rgba(255,255,255,0.06); }
.tool-card.tool-error .tool-card-step { color: rgba(248,113,113,0.6); background: rgba(248,113,113,0.08); }

.tool-card-label {
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.tool-card-summary {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.7;
}

.tool-card-status {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}

.tool-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ─── Tool Group (Claude Code style batch) ─── */
.tool-group {
  margin: 4px 0;
  border-radius: 6px;
  overflow: hidden;
}
.tool-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s;
  user-select: none;
}
.tool-group-header:hover { background: rgba(255,255,255,0.04); }
.tool-group-chevron {
  flex-shrink: 0;
  color: var(--text-dim);
  opacity: 0.5;
  transition: transform 0.2s ease, opacity 0.2s;
}
.tool-group-header:hover .tool-group-chevron { opacity: 0.8; }
.tool-group:not(.collapsed) .tool-group-chevron { transform: rotate(90deg); opacity: 0.8; }
.tool-group-summary {
  flex: 1;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 400;
}
.tool-group-status {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  opacity: 0.6;
}
.tool-group.group-success .tool-group-summary { color: var(--text-secondary); }
.tool-group.group-error .tool-group-summary { color: var(--red); opacity: 0.8; }

.tool-group-body {
  padding: 0 4px 4px 22px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tool-group.collapsed .tool-group-body { display: none; }

.tool-group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
  transition: background 0.1s;
}
.tool-group-item:hover { background: rgba(255,255,255,0.03); }
.tool-group-item.tgi-success .tgi-label { color: var(--text-secondary); }
.tool-group-item.tgi-error .tgi-label { color: var(--red); opacity: 0.8; }

.tgi-status {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}
.tool-spinner-sm {
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border-strong);
  border-top-color: var(--text-dim);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.tgi-label {
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  min-width: 36px;
}
.tgi-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}
.tgi-cmd {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  padding: 1px 5px;
  border-radius: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 400px;
  display: inline-block;
  vertical-align: middle;
}
.tgi-meta {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.7;
}
.tgi-result {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  padding-left: 8px;
  opacity: 0.6;
}
/* end Tool Group */

.tool-card-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: transform 0.2s;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}

.tool-card-toggle:hover { background: var(--bg-hover); color: var(--text); }
.tool-card.expanded .tool-card-toggle { transform: rotate(180deg); }

.tool-card-body {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}

.tool-card.expanded .tool-card-body { display: block; }

.tool-detail-command {
  margin: 8px 0;
}

.tool-detail-command code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 12px;
  display: block;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

.tool-detail-path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  padding: 6px 0;
  word-break: break-all;
}

.tool-detail-meta {
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 0;
}

.tool-diff {
  margin: 8px 0;
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
}

.diff-del {
  background: var(--red-dim);
  color: var(--red);
  padding: 6px 12px;
  white-space: pre-wrap;
  word-break: break-all;
  border-bottom: 1px solid var(--border);
}

.diff-del::before { content: '- '; font-weight: 700; }

.diff-add {
  background: var(--green-dim);
  color: var(--green);
  padding: 6px 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-add::before { content: '+ '; font-weight: 700; }

.tool-terminal {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: #111111;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 6px 0;
}

[data-theme="light"] .tool-terminal {
  background: #1a1a1a;
  color: #e0e0e0;
}

.tool-code-output {
  margin: 6px 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  max-height: 400px;
  overflow: auto;
}

.tool-code-output code {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
}

.tool-file-list {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin: 6px 0;
}

.tool-section-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin: 10px 0 4px;
}

.tool-output {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ─── Agent Badge (enhanced) ─── */
.agent-badge {
  margin: 4px 0;
  padding: 8px 12px;
  border: none;
  border-left: 2px solid var(--border);
  border-radius: 6px;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.agent-icon {
  font-size: 18px;
}

/* ─── Permission Request (enhanced) ─── */
.permission-request {
  margin: 4px 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  padding: 6px 10px;
}

.permission-request.auto-approved,
.permission-request.auto-denied {
  border: none;
  background: transparent;
}

.perm-header {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-dim);
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.perm-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.perm-icon.perm-ok { color: var(--text-dim); }
.perm-icon.perm-no { color: var(--text-dim); }
.perm-label {
  color: var(--text-dim);
  font-weight: 500;
}
.perm-tool {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.perm-result {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
}
.perm-result.perm-ok { color: var(--green); }
.perm-result.perm-no { color: var(--red); }

.perm-detail {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.perm-buttons {
  display: flex;
  gap: 8px;
}

/* ─── Ask User (enhanced) ─── */
.ask-user-request {
  margin: 12px 0;
  border: 1px solid rgba(96, 165, 250, 0.35);
  border-left: 3px solid var(--blue);
  border-radius: 10px;
  background: rgba(96, 165, 250, 0.08);
  padding: 16px 18px;
  animation: fadeSlide 0.3s ease;
}

.ask-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  line-height: 1.5;
}

.ask-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.ask-option {
  padding: 7px 16px;
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 20px;
  background: rgba(96, 165, 250, 0.06);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.ask-option:hover {
  background: rgba(96, 165, 250, 0.18);
  border-color: var(--blue);
  color: #fff;
  transform: translateY(-1px);
}

.ask-input-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.ask-input,
.ask-text-input {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid rgba(96, 165, 250, 0.25);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ask-input:focus,
.ask-text-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
}

.ask-input::placeholder,
.ask-text-input::placeholder {
  color: var(--text-dim);
}

.ask-submit,
.ask-send-btn {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.ask-submit:hover,
.ask-send-btn:hover {
  background: #3b82f6;
  transform: translateY(-1px);
}

/* ─── Thinking block (enhanced) ─── */
.thinking-block {
  margin: 4px 0;
  border: none;
  border-left: 2px solid var(--border);
  border-radius: 6px;
  background: transparent;
  overflow: hidden;
  font-size: 12px;
}

.thinking-spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border-strong);
  border-top-color: var(--text-dim);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
  opacity: 0.5;
}

.thinking-label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 400;
}

.thinking-timer {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  min-width: 28px;
  opacity: 0.6;
}

.thinking-tokens {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
  margin-right: 4px;
  opacity: 0.5;
}

.hatching-icon {
  opacity: 0.5;
  animation: hatch-pulse 2s ease-in-out infinite;
}
@keyframes hatch-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.25; }
}

.thinking-chevron {
  color: var(--text-dim);
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-left: 4px;
}

.thinking-block.expanded .thinking-chevron {
  transform: rotate(180deg);
}

/* ─── Tool Output Collapse ─── */
.tool-output-toggle {
  display: block;
  width: 100%;
  padding: 4px 8px;
  margin: 2px 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--mono);
  cursor: pointer;
  text-align: left;
  transition: color 0.12s;
  opacity: 0.5;
}
.tool-output-toggle:hover { opacity: 0.8; }

.tool-output-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.tool-output-peek {
  position: relative;
  max-height: 56px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 12px;
  white-space: pre-wrap;
  line-height: 1.4;
}

.tool-output-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: linear-gradient(transparent, var(--bg-surface));
  pointer-events: none;
}

.tool-output-full {
  display: none;
}

.tool-output-full.output-expanded {
  display: block;
}

/* ─── Streaming Cursor ─── */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 16px;
  background: var(--blue);
  border-radius: 1px;
  animation: cursorBlink 0.8s infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

@keyframes cursorBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 0;
}

.thinking-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: dotPulse 1.4s infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40%           { opacity: 1;   transform: scale(1); }
}

/* ─── Error ─── */
.msg-error .msg-content {
  color: var(--red);
  background: var(--red-dim);
  border: 1px solid rgba(220, 38, 38, 0.15);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
}

/* ─── Footer / Input ─── */
footer {
  padding: 16px 24px 20px;
  flex-shrink: 0;
}

.input-wrapper {
  position: relative;
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.input-wrapper:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

#input {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  max-height: 200px;
  outline: none;
  padding: 4px 0;
}

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

.send-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.send-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

.send-btn:not(:disabled):hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.send-btn:not(:disabled):active {
  transform: scale(0.97);
}

.footer-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* ─── Sidebar Overlay ─── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 280px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  padding: 0 14px 0 20px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text);
}

.sidebar-header .sidebar-title {
  flex: 1;
}

.sidebar-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

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

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.session-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.session-item:hover {
  background: var(--bg-surface);
}

.session-item.active {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.session-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}

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

.version-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-surface);
  padding: 2px 7px;
  border-radius: var(--radius-badge);
  border: 1px solid var(--border);
  margin-left: 6px;
  letter-spacing: 0.02em;
}

/* ─── Settings Panel ─── */
.settings-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 560px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.settings-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.settings-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  z-index: 9999;
}

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

.settings-tabs {
  display: flex;
  gap: 0;
  padding: 16px 24px 0;
  border-bottom: 1px solid var(--border);
}

.settings-tab {
  padding: 8px 16px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: -1px;
}

.settings-tab:hover {
  color: var(--text);
}

.settings-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.settings-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.settings-body.hidden {
  display: none;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.settings-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.settings-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.settings-input[type="password"] {
  font-family: var(--mono);
}

.settings-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.settings-select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.settings-select:focus {
  border-color: var(--blue);
}

.settings-textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
  transition: all 0.2s;
}

.settings-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.btn-secondary {
  width: 100%;
  height: 44px;
  padding: 0 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  border-color: var(--text-dim);
  box-shadow: var(--shadow-sm);
}

.auth-buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.auth-buttons .btn-primary,
.auth-buttons .btn-secondary {
  flex: 1;
}

.auth-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 8px;
  min-height: 16px;
}

/* ─── Account Info ─── */
.account-info {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 0;
}

.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
}

.account-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.account-email {
  font-size: 12px;
  color: var(--text-secondary);
}

.account-plan-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.account-plan-badge.pro {
  background: var(--blue-dim);
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.15);
}

.account-plan-badge.team,
.account-plan-badge.team_premium {
  background: var(--purple-dim);
  color: var(--purple);
  border-color: rgba(124, 58, 237, 0.15);
}

.account-plan-badge.max5x {
  background: var(--green-dim);
  color: var(--green);
  border-color: rgba(5, 150, 105, 0.15);
}

.account-plan-badge.max20x,
.account-plan-badge.enterprise {
  background: linear-gradient(135deg, var(--purple-dim), var(--blue-dim));
  color: var(--purple);
  border-color: rgba(124, 58, 237, 0.2);
}

/* ─── Usage Bars ─── */
.usage-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.usage-item {}

.usage-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.usage-bar {
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.usage-fill.warning { background: #f59e0b; }
.usage-fill.danger { background: var(--red); }
.usage-fill.bonus { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.usage-reset {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ─── Credit Summary ─── */
.credit-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0;
}
.credit-stat {
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
  border: 1px solid var(--border);
}
.credit-stat-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.credit-stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.credit-formula {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-surface);
  border-radius: 8px;
  padding: 10px 14px;
  border-left: 3px solid var(--blue);
}

/* ─── Credit Pack Cards ─── */
.credit-packs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.credit-pack-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.credit-pack-card:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.1);
}
.credit-pack-card.highlight {
  border-color: var(--blue);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(139, 92, 246, 0.05));
}
.pack-savings {
  position: absolute;
  top: -8px;
  right: 12px;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 10px;
}
.pack-credits {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}
.pack-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.pack-price {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.btn-pack-buy {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-pack-buy:hover { opacity: 0.85; }

/* ─── Referral ─── */
.referral-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}
.referral-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
}
.referral-code-display {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.referral-code-text {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.1em;
  font-family: 'JetBrains Mono', monospace;
  color: var(--blue);
}
.btn-copy-ref {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-copy-ref:hover { background: var(--bg-surface); }
.referral-share-url {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.referral-share-url input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.referral-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
}
.referral-stats .stat {
  text-align: center;
}
.referral-stats .stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.referral-stats .stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.referral-rules {
  font-size: 13px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.referral-rules p { margin: 0 0 6px; }
.referral-rules ul { margin: 0; padding-left: 18px; }
.referral-rules li { margin-bottom: 2px; }
.referral-apply, .promo-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
}
.referral-apply h3, .promo-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
}
.referral-input-row {
  display: flex;
  gap: 8px;
}
.referral-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.referral-input-row .btn-primary {
  white-space: nowrap;
}
.referral-status, .promo-status {
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
}
.referral-status.success, .promo-status.success { color: var(--green); }
.referral-status.error, .promo-status.error { color: var(--red); }
.referral-applied {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

/* ─── Quota Exceeded Modal ─── */
.quota-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}
.quota-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.quota-modal-icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.quota-modal h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}
.quota-modal p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 24px;
  line-height: 1.5;
}
.quota-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quota-btn-upgrade {
  background: linear-gradient(135deg, #3b82f6, #6366f1) !important;
  color: #fff !important;
  font-weight: 600;
}
.quota-btn-credits {
  background: linear-gradient(135deg, #8b5cf6, #a78bfa) !important;
  color: #fff !important;
  font-weight: 600;
}
.quota-btn-close {
  background: transparent !important;
  border: 1px solid var(--border) !important;
}

/* ─── Plans Header ─── */
.plans-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.plans-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.plans-category-tab {
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.plans-category-tab.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ─── Billing Toggle ─── */
.billing-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.billing-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

.billing-annual { display: flex; align-items: center; gap: 4px; }

.billing-save {
  padding: 1px 6px;
  border-radius: 8px;
  background: #dcfce7;
  color: #15803d;
  font-size: 10px;
  font-weight: 700;
}

.billing-switch {
  position: relative;
  width: 36px;
  height: 20px;
  display: inline-block;
}

.billing-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.billing-slider {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.billing-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: all 0.2s;
}

.billing-switch input:checked + .billing-slider {
  background: var(--accent);
}

.billing-switch input:checked + .billing-slider::before {
  transform: translateX(16px);
}

/* ─── Plans Grid ─── */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
}

.plan-card:hover {
  box-shadow: var(--shadow-md);
}

.plan-card.featured {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.plan-badge-tag {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 12px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.plan-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.plan-sub-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.plan-price {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.plan-amount {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.plan-price-note {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 14px;
  min-height: 16px;
}

.plan-price-original {
  text-decoration: line-through;
  color: var(--text-dim);
  font-size: 14px;
  margin-right: 4px;
}

.plan-usd-equiv {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
}

.plan-amount .plan-usd-equiv {
  font-size: 12px;
  font-weight: 400;
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  flex: 1;
}

.plan-features li {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 0;
  padding-left: 18px;
  position: relative;
  line-height: 1.5;
}

.plan-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--green);
  font-weight: 700;
  font-size: 11px;
}

.plan-features li.section-head {
  padding-left: 0;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
}

.plan-features li.section-head::before {
  content: none;
}

.btn-plan {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-plan:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn-plan.current {
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: default;
}

.btn-upgrade {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-upgrade:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
}

.btn-switch {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-switch:hover {
  background: var(--bg-surface) !important;
  border-color: var(--text) !important;
}

.btn-contact {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn-contact:hover {
  opacity: 0.85;
}

.plans-footnote {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 16px;
  line-height: 1.5;
}

/* ─── Feedback Status ─── */
.feedback-status {
  font-size: 12px;
  margin-top: 8px;
  min-height: 16px;
}

.feedback-status.success { color: var(--green); }
.feedback-status.error { color: var(--red); }

/* ─── Agent / Compact badges ─── */
.agent-badge, .compact-badge {
  margin: 4px 0;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
}

.agent-badge {
  background: transparent;
  border: none;
  border-left: 2px solid var(--border);
  color: var(--text-dim);
}

.agent-badge.success {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.agent-badge.failed {
  background: transparent;
  border-color: rgba(220, 38, 38, 0.3);
  color: rgba(248,113,113,0.7);
}

.compact-badge {
  background: transparent;
  border: none;
  border-left: 2px solid var(--border);
  color: var(--text-dim);
}

.permission-badge {
  margin: 4px 0;
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  color: var(--text-dim);
  animation: fadeSlide 0.2s ease;
}

.permission-badge.interactive {
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.permission-badge.approved {
  background: var(--green-dim);
  border-color: rgba(5, 150, 105, 0.15);
  color: var(--green);
}

.permission-badge.denied {
  background: var(--red-dim);
  border-color: rgba(220, 38, 38, 0.15);
  color: var(--red);
}

.perm-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.perm-allow, .perm-deny {
  padding: 5px 14px;
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid;
}

.perm-allow {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.perm-allow:hover { background: var(--accent-hover); }

.perm-deny {
  background: var(--bg);
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.perm-deny:hover { border-color: var(--red); color: var(--red); }


/* ─── Agent Feed (Terminal look) ─── */
.cue-feed {
  background: #111;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 8px 0;
}

.feed-step { font-size: 12px; color: #ccc; }
.feed-done { color: #4ade80; font-weight: 600; }
.feed-command { color: #93c5fd; font-style: italic; }

/* ─── Success Pop ─── */
.success-pop {
  animation: successPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes successPop {
  0%   { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

/* ─── Clerk Sign-in ─── */
#clerk-sign-in {
  min-height: 100px;
  width: 100%;
}

#clerk-auth-section .settings-section {
  padding: 0;
}

/* ─── WeChat Login Button ─── */
.btn-wechat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: #07c160;
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-wechat:hover { background: #06ae56; }
.btn-wechat:active { transform: scale(0.98); }

.btn-wechat svg { flex-shrink: 0; }

/* ─── Auth Divider ─── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-dim);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Account Provider Badge ─── */
.account-provider {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.account-provider.wechat { color: #07c160; }

/* ─── Locale Switcher ─── */
.locale-btn {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  min-width: 36px;
  letter-spacing: 0.02em;
}

.locale-btn #locale-label {
  pointer-events: none;
}

/* ─── Plans Payment Note ─── */
.plans-payment-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-xs);
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
  font-size: 13px;
  font-weight: 500;
}

/* ─── Responsive ─── */
/* ─── Mode Tabs ─── */
.mode-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-surface);
  border-radius: var(--radius-xs);
  padding: 2px;
  margin-right: 8px;
}

.mode-tab {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.mode-tab:hover { color: var(--text-secondary); }
.mode-tab.active { background: var(--bg); color: var(--text); box-shadow: var(--shadow-sm); }

/* ─── Model Context Badge ─── */
.model-ctx-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.model-mult-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}
.mult-2 { background: #e8f5e9; color: #2e7d32; }
.mult-5 { background: #e3f2fd; color: #1565c0; }
.mult-25 { background: #fce4ec; color: #c62828; }
[data-theme="dark"] .mult-2 { background: #1b3a1b; color: #66bb6a; }
[data-theme="dark"] .mult-5 { background: #0d2744; color: #64b5f6; }
[data-theme="dark"] .mult-25 { background: #3c1020; color: #ef9a9a; }

/* ─── Slow Mode Banner ─── */
.slow-mode-banner {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  border: 1px solid #ffb74d;
  border-radius: 8px;
  margin: 8px 16px;
  font-size: 13px;
  color: #e65100;
}
.slow-mode-banner .slow-icon { font-size: 16px; }
.slow-mode-banner b { font-weight: 700; }
.slow-upgrade-link { color: #e65100; font-weight: 600; text-decoration: underline; }
[data-theme="dark"] .slow-mode-banner {
  background: linear-gradient(135deg, #3e2723, #4e342e);
  border-color: #8d6e63;
  color: #ffcc80;
}
[data-theme="dark"] .slow-upgrade-link { color: #ffcc80; }

/* ─── Check-in UI ─── */
.checkin-card {
  text-align: center;
  padding: 24px;
}
.checkin-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}
.checkin-icon { font-size: 48px; }
.checkin-streak-num {
  font-size: 42px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.checkin-streak-label {
  font-size: 13px;
  color: var(--text-secondary);
}
.checkin-rewards-track {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.checkin-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  min-width: 52px;
  transition: all 0.2s;
}
.checkin-day.done {
  border-color: var(--accent);
  background: rgba(217, 119, 6, 0.08);
}
.checkin-day.active {
  border-color: var(--accent);
  background: rgba(217, 119, 6, 0.15);
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.2);
}
.checkin-day-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}
.checkin-day-reward {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}
.checkin-day.done .checkin-day-reward { color: var(--accent); }
.checkin-btn {
  font-size: 15px;
  padding: 12px 32px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.checkin-btn:disabled {
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: default;
  border-color: var(--border);
}
.checkin-status {
  font-size: 13px;
  color: var(--text-secondary);
  min-height: 20px;
}
.checkin-status.success { color: var(--accent); font-weight: 600; }
.checkin-total {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* ─── Footer Bar ─── */
.footer-bar {
  max-width: 780px;
  margin: 6px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.footer-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.footer-chip:hover { border-color: var(--border-strong); color: var(--text); background: var(--bg-surface); }
.footer-chip.active { border-color: var(--blue); color: var(--blue); background: var(--blue-dim); }
select.footer-chip { display: inline-flex; outline: none; appearance: none; -webkit-appearance: none; padding-right: 16px; background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 8 5' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 6px center; }

.footer-select {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
}

.footer-select:hover { border-color: var(--border-strong); }
.footer-select:focus { border-color: var(--blue); }

/* ─── Attach Button & Preview ─── */
.attach-btn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  color: var(--text-dim);
}

.attach-btn:hover { color: var(--text-secondary); background: var(--bg-surface); border-color: var(--border); }

.attach-preview {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.attach-preview.hidden { display: none; }

.attach-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--blue-dim);
  color: var(--blue);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.attach-chip .remove-attach {
  cursor: pointer;
  opacity: 0.6;
  font-size: 13px;
}

.attach-chip .remove-attach:hover { opacity: 1; }

/* ─── Right Panel ─── */
.right-panel {
  position: fixed;
  right: 0; top: 48px; bottom: 0;
  width: 320px;
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  box-shadow: -2px 0 12px rgba(0,0,0,0.06);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  pointer-events: none;
}

.right-panel.open {
  transform: translateX(0);
  pointer-events: auto;
}

.right-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.right-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

/* ─── Todo / Task / MCP Items ─── */
.panel-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-dim);
  font-size: 13px;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  margin-bottom: 6px;
  font-size: 12px;
  transition: all 0.15s;
}

.todo-item:hover { background: var(--bg-surface); }

.todo-status {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  margin-top: 1px;
  display: grid;
  place-items: center;
  font-size: 10px;
}

.todo-status.completed { border-color: var(--green); background: var(--green); color: #fff; }
.todo-status.in_progress { border-color: var(--blue); background: var(--blue-dim); color: var(--blue); }
.todo-status.pending { border-color: var(--border-strong); }
.todo-status.cancelled { border-color: var(--text-dim); background: var(--bg-surface); color: var(--text-dim); }

.todo-content {
  flex: 1;
  color: var(--text);
  line-height: 1.4;
}

.todo-item.completed .todo-content {
  text-decoration: line-through;
  color: var(--text-dim);
}

.task-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-item:hover { background: var(--bg-surface); }

.task-info { flex: 1; min-width: 0; }
.task-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

.task-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

.task-status-dot.running { background: var(--blue); animation: dotPulse 1.4s infinite; }
.task-status-dot.completed { background: var(--green); }
.task-status-dot.failed { background: var(--red); }
.task-status-dot.pending { background: var(--text-dim); }

.task-kill {
  padding: 3px 8px;
  border: 1px solid var(--red);
  border-radius: 4px;
  background: transparent;
  color: var(--red);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}

.task-kill:hover { background: var(--red-dim); }

.mcp-item {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  margin-bottom: 4px;
  transition: all 0.15s;
}

.mcp-item:hover { background: var(--bg-surface); }

.mcp-name { font-size: 12px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 4px; }
.mcp-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; line-height: 1.4; }

/* ─── Sidebar Search ─── */
.sidebar-search {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.sidebar-search-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  transition: all 0.15s;
}

.sidebar-search-input:focus { border-color: var(--blue); background: var(--bg); }
.sidebar-search-input::placeholder { color: var(--text-dim); }

/* ─── Plan Mode Banner ─── */
.plan-mode-banner {
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-left: 2px solid var(--border);
  border-radius: 6px;
  margin: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 400;
}

.plan-mode-banner .exit-plan {
  margin-left: auto;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
}

.plan-mode-banner .exit-plan:hover { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

/* ─── Btn SM for inline small buttons ─── */
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; width: auto; }

/* ─── Responsive ─── */
@media (max-width: 640px) {
  #messages { padding: 16px; }
  footer { padding: 12px 16px 16px; }
  .welcome h1 { font-size: 24px; }
  .welcome-icon { width: 64px; height: 64px; font-size: 28px; }
  .hint-chip { font-size: 12px; padding: 7px 14px; }
  .sidebar { width: 240px; }
  .modal { width: calc(100% - 32px); padding: 28px; }
  .settings-panel { width: calc(100% - 24px); max-height: 90vh; }
  .plans-grid { grid-template-columns: 1fr; }
  .right-panel { width: 100%; }
  .footer-bar { flex-direction: column; align-items: stretch; }
  .footer-left, .footer-right { flex-wrap: wrap; }
  .mode-tabs { gap: 2px; }
  .mode-tabs button { font-size: 11px; padding: 4px 8px; }
}

/* ═══════════════════════════════════════════
   Pixel Mascot & Enhanced Sidebar
   ═══════════════════════════════════════════ */

/* ─── Welcome Logo (Claude-style starburst) ─── */
.welcome-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  animation: logoFloat 5s ease-in-out infinite;
}

.welcome-logo-svg {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 6px 32px rgba(212,149,106,0.45));
  transition: transform 0.3s ease;
}

.welcome-logo:hover .welcome-logo-svg {
  transform: scale(1.12) rotate(12deg);
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ─── Pixel Art Mascot ─── */
.pixel-mascot {
  position: relative;
  width: 88px;
  height: 96px;
  margin: 0 auto 16px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  animation: mascotFloat 3s ease-in-out infinite;
}
.pixel-mascot:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}

.pixel-mascot canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 64px;
  height: 64px;
}

.mascot-name {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--mono);
  text-transform: capitalize;
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.2s;
}
.pixel-mascot:hover .mascot-name { opacity: 0.5; }

/* ─── Thought Bubble (lil-agents style) ─── */
.mascot-bubble {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: var(--bg-secondary, #f5f5f5);
  color: var(--text-dim, #888);
  font-size: 11px;
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid var(--border, #e0e0e0);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}
.mascot-bubble::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  background: var(--bg-secondary, #f5f5f5);
  border-right: 1px solid var(--border, #e0e0e0);
  border-bottom: 1px solid var(--border, #e0e0e0);
  transform: translateX(-50%) rotate(45deg);
}
.mascot-bubble.visible {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

@keyframes mascotFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ─── Sidebar Navigation (Claude Code style) ─── */
.sidebar-nav {
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}

.sidebar-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar-nav-btn.sidebar-new {
  color: var(--text);
  font-weight: 600;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 0;
}

.sidebar-collapse {
  margin-left: auto;
}

/* ─── Sidebar Projects Filter ─── */
.sidebar-projects {
  padding: 8px 8px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.sidebar-projects-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.sidebar-filter-btn {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-filter-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ─── Sidebar User Profile Bar ─── */
.sidebar-user-bar {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  overflow: hidden;
}

.sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-plan {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
}

.sidebar-user-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.sidebar-icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ─── Session date group ─── */
.session-date-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 12px 12px 6px;
}

/* ─── Dark theme overrides ─── */
[data-theme="dark"] .msg-user .msg-content {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

[data-theme="dark"] .send-btn {
  background: var(--text);
  color: var(--bg);
}

[data-theme="dark"] .hint-chip {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="dark"] .hint-chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

[data-theme="dark"] .settings-panel {
  background: var(--bg);
  border-color: var(--border);
}

[data-theme="dark"] .msg-assistant .msg-content code {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--blue);
}

[data-theme="dark"] .msg-assistant .msg-content pre {
  background: #111111;
  border-color: var(--border);
}

[data-theme="dark"] .msg-assistant .msg-content pre code {
  color: var(--text);
}

[data-theme="dark"] .code-block-wrapper {
  background: rgba(0,0,0,0.2);
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .code-block-header {
  background: rgba(255,255,255,0.02);
  border-color: rgba(255,255,255,0.05);
}

[data-theme="dark"] .code-block-header:hover {
  background: rgba(255,255,255,0.04);
}

[data-theme="dark"] .tool-output-toggle {
  background: transparent;
  border: none;
}

[data-theme="dark"] .tool-output-peek {
  color: var(--text-dim);
}

[data-theme="dark"] .tool-output-fade {
  background: linear-gradient(transparent, #1a1a1a);
}

[data-theme="dark"] .welcome {
  color: var(--text);
}

[data-theme="dark"] .pixel-mascot {
  border-color: rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}
[data-theme="dark"] .mascot-bubble {
  background: #2a2a2a;
  color: #aaa;
  border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .mascot-bubble::after {
  background: #2a2a2a;
  border-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .input-wrapper {
  background: var(--bg-surface);
  border-color: var(--border);
}

[data-theme="dark"] .tool-call {
  background: var(--bg-surface);
  border-color: var(--border);
}

[data-theme="dark"] .code-copy-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  opacity: 0.4;
}
[data-theme="dark"] .msg-action-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
}

[data-theme="dark"] select,
[data-theme="dark"] .footer-select {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .sidebar {
  background: var(--bg);
  border-right-color: var(--border);
}

[data-theme="dark"] header {
  background: var(--bg);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .sidebar-overlay.visible {
  background: rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .version-badge {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-secondary);
}

[data-theme="dark"] .tool-group-header:hover {
  background: rgba(255,255,255,0.04);
}
[data-theme="dark"] .tool-group-item:hover {
  background: rgba(255,255,255,0.03);
}
[data-theme="dark"] .tgi-cmd {
  background: rgba(255,255,255,0.04);
  border: none;
}

/* ─── Bargain (砍一刀) ─── */
.bargain-hero {
  text-align: center;
  padding: 16px 0 20px;
}
.bargain-hero-icon { font-size: 48px; margin-bottom: 8px; }
.bargain-hero h3 { font-size: 18px; font-weight: 700; margin: 0 0 6px; color: var(--text); }
.bargain-hero p { font-size: 13px; color: var(--text-secondary); margin: 0; line-height: 1.5; }

.bargain-tiers {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.bargain-tier-card {
  text-align: center;
  padding: 20px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  min-width: 120px;
  flex: 1;
  max-width: 160px;
  transition: all 0.2s;
}
.bargain-tier-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.bargain-tier-amount {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.bargain-tier-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.bargain-tier-helpers {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 8px 0 12px;
}
.bargain-tier-btn { width: 100%; font-size: 13px; padding: 8px 0; }

/* Active bargain */
.bargain-active {
  padding: 16px;
  border-radius: 12px;
  border: 1.5px solid var(--accent);
  background: rgba(217, 119, 6, 0.04);
  margin-bottom: 16px;
}
.bargain-active-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.bargain-active-icon { font-size: 36px; }
.bargain-active-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.bargain-timer { font-size: 12px; color: var(--accent); font-weight: 600; }

.bargain-progress-section { margin-bottom: 16px; }
.bargain-progress-bar {
  height: 20px;
  background: var(--bg-surface);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bargain-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  border-radius: 10px;
  transition: width 0.6s ease;
}
.bargain-progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.bargain-remaining {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  margin-top: 8px;
}

.bargain-share {
  margin: 16px 0;
  display: flex;
  gap: 8px;
  align-items: center;
}
.bargain-share-url {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-copy-bargain { white-space: nowrap; font-size: 13px; padding: 8px 16px; }

.bargain-helpers { margin-top: 12px; }
.bargain-helpers h4 { font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 8px; }
.bargain-helper-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.bargain-helper-name { color: var(--text); }
.bargain-helper-cut { color: var(--accent); font-weight: 700; }
.bargain-no-helpers { font-size: 13px; color: var(--text-dim); text-align: center; padding: 16px 0; }

.bargain-history { margin-top: 20px; }
.bargain-history h4 { font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 8px; }
.bargain-history-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}
.bargain-history-date { color: var(--text-dim); }

/* Bargain result modal */
.bargain-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.bargain-modal {
  background: var(--bg);
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
@keyframes bargainSwing {
  0%, 100% { transform: rotate(-15deg) scale(1); }
  50% { transform: rotate(15deg) scale(1.1); }
}
.bargain-modal-anim {
  font-size: 56px;
  animation: bargainSwing 0.6s ease-in-out 3;
  display: inline-block;
}
.bargain-modal h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 12px 0 8px;
}
.bargain-modal-cut {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.bargain-modal-cut b { color: var(--accent); font-size: 20px; }
.bargain-modal-reward {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.bargain-modal-reward b { color: #16a34a; }
.bargain-modal-complete {
  font-size: 15px;
  font-weight: 700;
  color: #16a34a;
  background: #f0fdf4;
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 12px;
}
[data-theme="dark"] .bargain-modal-complete { background: #052e16; }
.bargain-modal-close {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 12px;
  margin-top: 8px;
}

/* ─── Drag & Drop indicator ─── */
.input-wrapper.drag-over {
  border: 2px dashed var(--blue) !important;
  background: rgba(96, 165, 250, 0.08) !important;
  transition: all 0.15s ease;
}
.input-wrapper.drag-over::after {
  content: 'Drop files here';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--blue);
  font-weight: 600;
  pointer-events: none;
  background: rgba(96, 165, 250, 0.06);
  border-radius: inherit;
  z-index: 5;
}

/* ─── Slash command & @ popup ─── */
.slash-popup {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-elevated, var(--bg-secondary));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 6px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
  z-index: 100;
}
.slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background 0.1s;
}
.slash-item.active,
.slash-item:hover {
  background: rgba(96, 165, 250, 0.15);
}
.slash-item.loading {
  opacity: 0.6;
  cursor: default;
}
.slash-cmd {
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  color: var(--blue);
  min-width: 80px;
}
.slash-desc {
  color: var(--text-secondary);
  font-size: 12px;
}

/* ─── Message attachments ─── */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.msg-attach-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 120px;
}
.msg-attach-thumb img {
  width: 100px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.msg-attach-name {
  font-size: 11px;
  color: var(--text-secondary);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-attach-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.25);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-primary);
}
.msg-attach-size {
  color: var(--text-secondary);
  font-size: 11px;
}

/* ─── Welcome Actions Row ─── */
.welcome-actions-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ─── Gacha Entry Button ─── */
.gacha-entry-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--text-secondary, #888);
  cursor: pointer;
  transition: all 0.2s;
  margin: 8px 0;
}
.gacha-entry-btn:hover {
  border-color: var(--accent, #cc7b42);
  color: var(--accent, #cc7b42);
  background: rgba(204,123,66,0.06);
}

/* ─── Gacha System ─── */
.gacha-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: gachaFadeIn 0.2s ease;
}
@keyframes gachaFadeIn { from { opacity: 0; } to { opacity: 1; } }

.gacha-modal {
  background: var(--bg-primary, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 16px;
  width: min(480px, 90vw);
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.gacha-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border, #e0e0e0);
  padding: 0 12px;
}
.gacha-tab {
  background: none;
  border: none;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #888);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.gacha-tab.active {
  color: var(--text-primary, #222);
  border-bottom-color: var(--accent, #cc7b42);
}
.gacha-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary, #888);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.gacha-close:hover { background: var(--bg-secondary, #f0f0f0); }

.gacha-panel {
  padding: 20px;
  overflow-y: auto;
}

/* Pull stage */
.gacha-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  position: relative;
  overflow: hidden;
}
.gacha-egg {
  cursor: pointer;
  transition: transform 0.15s;
  animation: gachaEggBob 2s ease-in-out infinite;
}
@keyframes gachaEggBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.gacha-egg-shake {
  animation: gachaShake 0.12s ease-in-out 8 !important;
}
@keyframes gachaShake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

.gacha-result {
  text-align: center;
  animation: gachaRevealIn 0.4s ease-out;
}
@keyframes gachaRevealIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#gacha-result-canvas {
  image-rendering: pixelated;
  border-radius: 12px;
  background: var(--bg-secondary, #f5f5f5);
  border: 2px solid var(--border, #e0e0e0);
}
.gacha-result-rarity {
  margin: 8px 0 4px;
  display: flex;
  justify-content: center;
  gap: 2px;
}
.gacha-result-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #222);
  margin: 4px 0;
}
.gacha-result-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.gacha-result-new {
  color: #e8a830;
  font-weight: 700;
  font-size: 13px;
  margin: 4px 0;
  animation: gachaPulse 0.6s ease infinite alternate;
}
@keyframes gachaPulse { from { opacity: 0.7; } to { opacity: 1; } }
.gacha-result-desc {
  font-size: 12px;
  color: var(--text-secondary, #888);
  margin: 8px 0 12px;
  line-height: 1.5;
}

.gacha-actions {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}
.gacha-btn {
  background: var(--accent, #cc7b42);
  color: #fff;
  border: none;
  padding: 10px 28px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.gacha-btn:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.gacha-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.gacha-use-btn {
  margin-top: 8px;
  background: transparent;
  color: var(--accent, #cc7b42);
  border: 1px solid var(--accent, #cc7b42);
  padding: 6px 20px;
  font-size: 12px;
}
.gacha-rates {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 11px;
  font-family: var(--mono);
  opacity: 0.6;
}
.gacha-pity {
  color: var(--text-dim, #aaa);
}

/* Flash effect on rare pull */
.gacha-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 12px;
  animation: gachaFlash 1.2s ease-out forwards;
}
@keyframes gachaFlash {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}
.gacha-flash-SSR { background: radial-gradient(circle, rgba(232,168,48,0.5), transparent 70%); }
.gacha-flash-SR { background: radial-gradient(circle, rgba(192,96,224,0.4), transparent 70%); }
.gacha-flash-R { background: radial-gradient(circle, rgba(80,144,224,0.3), transparent 70%); }
.gacha-flash-N { background: radial-gradient(circle, rgba(138,138,154,0.2), transparent 70%); }

/* Album Grid */
.gacha-album-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.gacha-album-tier {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border, #e0e0e0);
}
.gacha-album-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gacha-album-card {
  width: 80px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border, #e0e0e0);
  background: var(--bg-secondary, #f5f5f5);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.gacha-album-card.owned:hover {
  border-color: var(--accent, #cc7b42);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.gacha-album-card.locked {
  opacity: 0.3;
  cursor: default;
  filter: grayscale(1);
}
.gacha-album-canvas {
  image-rendering: pixelated;
  width: 48px;
  height: 48px;
}
.gacha-album-card.locked .gacha-album-canvas {
  visibility: hidden;
}
.gacha-album-name {
  font-size: 10px;
  margin-top: 4px;
  color: var(--text-secondary, #888);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gacha-album-count {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9px;
  color: var(--text-dim, #aaa);
  font-family: var(--mono);
}
.gacha-album-stats {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary, #888);
  padding: 8px 0;
}

/* Dark theme */
[data-theme="dark"] .gacha-modal {
  background: #1a1a1a;
  border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .gacha-album-card {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}
[data-theme="dark"] #gacha-result-canvas {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
}
