/* =====================================================
   Claude — UI v18
   Warm cream / espresso palette • Lucide icons •
   Spring-based motion • Real Anthropic-style accents
   ===================================================== */

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

:root {
  /* Color tokens (dark by default) */
  --bg-primary:      #262624;
  --bg-secondary:    #2F2E2C;
  --bg-sidebar:      #1F1F1D;
  --bg-input:        #30302E;
  --bg-hover:        #36352F;
  --bg-active:       #3F3E37;
  --bg-user-msg:     #34332E;
  --bg-code:         #1A1A18;
  --bg-code-header:  #232321;

  --text-primary:    #F2F1ED;
  --text-secondary:  #B6B2A8;
  --text-muted:      #8B877D;
  --text-faint:      #5F5C56;

  --accent:          #D97757;
  --accent-hover:    #C46944;
  --accent-soft:     rgba(217, 119, 87, 0.12);
  --accent-ring:     rgba(217, 119, 87, 0.20);

  --border:          rgba(255, 247, 230, 0.07);
  --border-strong:   rgba(255, 247, 230, 0.12);

  --success:         #5CB87A;
  --error:           #E27575;

  --shadow-sm:       0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow:          0 4px 12px rgba(0, 0, 0, 0.22);
  --shadow-lg:       0 14px 38px rgba(0, 0, 0, 0.32);

  --radius-xs:       6px;
  --radius-sm:       10px;
  --radius:          14px;
  --radius-lg:       18px;
  --radius-xl:       22px;
  --radius-pill:     999px;

  --ease-out:        cubic-bezier(0.22, 0.94, 0.32, 1);
  --ease-spring:     cubic-bezier(0.34, 1.56, 0.4, 1);
  --ease-snap:       cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast:          0.16s;
  --t-base:          0.22s;
  --t-slide:         0.36s;

  --font-sans:
    "Söhne", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI Variable", "Segoe UI", system-ui, "Helvetica Neue",
    Arial, sans-serif;
  --font-mono:
    "Berkeley Mono", "JetBrains Mono", ui-monospace, "SF Mono",
    "Cascadia Code", "Fira Code", Consolas, monospace;

  --max-width: 760px;
}

[data-theme="light"] {
  --bg-primary:      #FAF9F5;
  --bg-secondary:    #F2F0E8;
  --bg-sidebar:      #F2F0E8;
  --bg-input:        #FFFFFF;
  --bg-hover:        #EAE7DC;
  --bg-active:       #DFDCCE;
  --bg-user-msg:     #EFEDE4;
  --bg-code:         #F4F2EB;
  --bg-code-header:  #ECE9DD;

  --text-primary:    #1F1F1E;
  --text-secondary:  #54534A;
  --text-muted:      #7E7C72;
  --text-faint:      #ABA89C;

  --accent:          #C25C35;
  --accent-hover:    #AB4F2C;
  --accent-soft:     rgba(194, 92, 53, 0.10);
  --accent-ring:     rgba(194, 92, 53, 0.18);

  --border:          rgba(63, 56, 38, 0.10);
  --border-strong:   rgba(63, 56, 38, 0.18);

  --shadow-sm:       0 1px 2px rgba(63, 56, 38, 0.06);
  --shadow:          0 4px 14px rgba(63, 56, 38, 0.08);
  --shadow-lg:       0 16px 40px rgba(63, 56, 38, 0.14);
}

/* Code body stays dark in both themes to match real Claude */

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11", "ss01";
  letter-spacing: -0.011em;
  line-height: 1.55;
}

html { transition: background-color 0.4s var(--ease-out), color 0.4s var(--ease-out); }
body { display: flex; transition: background-color 0.4s var(--ease-out); }

::selection { background: var(--accent-soft); color: var(--text-primary); }

/* ===== Theme icon swap (CSS-controlled) ===== */
.icon-sun  { display: inline-flex; }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: inline-flex; }

/* ===== BUTTONS ===== */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast) var(--ease-snap),
              color var(--t-fast) var(--ease-snap),
              transform 0.14s var(--ease-snap);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.small { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn.accent { color: var(--accent); }
.icon-btn.accent:hover { background: var(--accent-soft); color: var(--accent-hover); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.small svg { width: 14px; height: 14px; }

.btn {
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  border: none;
  letter-spacing: -0.01em;
  transition: background var(--t-fast),
              color var(--t-fast),
              transform 0.12s var(--ease-snap),
              box-shadow var(--t-base);
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: #FFFFFF; }
.btn.primary:hover { background: var(--accent-hover); box-shadow: 0 4px 14px var(--accent-ring); }
.btn.secondary { background: transparent; color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn.secondary:hover { background: var(--bg-hover); }
.btn.danger { background: #C8413E; color: #FFFFFF; }
.btn.danger:hover { background: #B33836; box-shadow: 0 4px 14px rgba(200, 65, 62, 0.28); }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  transition: margin-left var(--t-slide) var(--ease-out);
  z-index: 100;
  position: relative;
}
.sidebar.hidden { margin-left: -260px; }
.sidebar::after {
  content: "";
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 1px;
  background: var(--border);
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 26px; height: 26px;
  border-radius: 28%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--accent-ring);
  transition: transform 0.4s var(--ease-spring), box-shadow var(--t-base);
}
.logo-mark:hover { transform: rotate(12deg) scale(1.04); }
.logo-text {
  font-size: 16px; font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-search {
  margin: 0 12px 8px;
  padding: 7px 12px;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-pill);
  transition: background var(--t-fast), box-shadow var(--t-base);
}
.sidebar-search:focus-within {
  background: var(--bg-active);
  box-shadow: 0 0 0 1.5px var(--accent-ring);
}
.sidebar-search svg { color: var(--text-muted); flex-shrink: 0; width: 14px; height: 14px; }
.sidebar-search input {
  flex: 1; background: none; border: none; color: var(--text-primary);
  font-size: 13px; font-family: var(--font-sans); outline: none;
  letter-spacing: -0.005em;
}
.sidebar-search input::placeholder { color: var(--text-muted); }

.sidebar-chats { flex: 1; overflow-y: auto; padding: 6px 8px 12px; }

.chat-date-group {
  padding: 14px 12px 6px;
  font-size: 11px; font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-item {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--t-fast), color var(--t-fast);
  display: flex; align-items: center; justify-content: space-between;
  gap: 4px;
  position: relative;
  letter-spacing: -0.005em;
}
.chat-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.chat-item.active { background: var(--bg-active); color: var(--text-primary); }
.chat-item-title { overflow: hidden; text-overflow: ellipsis; flex: 1; }

.chat-item-actions {
  display: flex; gap: 2px; flex-shrink: 0;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s var(--ease-snap);
}
.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions { opacity: 1; pointer-events: auto; }
.chat-item-action {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer;
  padding: 4px; border-radius: 6px;
  display: flex; align-items: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.chat-item-action:hover { color: var(--text-primary); background: var(--bg-secondary); }
.chat-item-action.delete:hover { color: var(--error); }
.chat-item-action svg { width: 13px; height: 13px; }

.sidebar-footer {
  padding: 10px 8px 12px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-footer-btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-family: var(--font-sans);
  cursor: pointer;
  border-radius: var(--radius-sm);
  letter-spacing: -0.005em;
  transition: background var(--t-fast), color var(--t-fast), transform 0.12s var(--ease-snap);
}
.sidebar-footer-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-footer-btn:active { transform: scale(0.985); }
.sidebar-footer-btn svg { width: 16px; height: 16px; }

.badge {
  margin-left: auto;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
[data-theme="light"] .badge { background: var(--bg-active); }

/* ===== PANELS & MODAL ===== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 14, 12, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 300;
  opacity: 0; visibility: hidden;
  transition: opacity 0.28s var(--ease-out), visibility 0.28s var(--ease-out);
}
.overlay.show { opacity: 1; visibility: visible; }

.slide-panel {
  position: fixed; right: -440px; top: 0; bottom: 0; width: 420px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  z-index: 301; display: flex; flex-direction: column;
  transition: right var(--t-slide) var(--ease-out);
  box-shadow: -10px 0 50px rgba(0, 0, 0, 0.25);
}
.slide-panel.show { right: 0; }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.panel-header h3 {
  font-size: 16px; font-weight: 600;
  letter-spacing: -0.02em;
}

.panel-input-row {
  display: flex; gap: 8px; padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-input-row input {
  flex: 1; background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  padding: 7px 14px;
  font-size: 13px; font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-base);
}
.panel-input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.panel-list {
  flex: 1; overflow-y: auto; padding: 14px 18px;
  display: flex; flex-direction: column; gap: 8px;
}

.memory-item, .skill-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  font-size: 13px; line-height: 1.55;
  border: 1px solid var(--border);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.memory-item:hover, .skill-item:hover { border-color: var(--border-strong); }
.memory-item-content { flex: 1; }
.memory-item-meta, .skill-item-meta {
  font-size: 11px; color: var(--text-muted);
  margin-top: 4px;
}
.memory-item-delete, .skill-item-delete {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 3px; border-radius: 6px; flex-shrink: 0; opacity: 0;
  transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.memory-item:hover .memory-item-delete,
.skill-item:hover .skill-item-delete { opacity: 1; }
.memory-item-delete:hover, .skill-item-delete:hover { color: var(--error); background: var(--bg-hover); }
.memory-item-delete svg, .skill-item-delete svg { width: 14px; height: 14px; }

.memory-empty {
  text-align: center; color: var(--text-muted); padding: 40px 20px;
  font-size: 13px; line-height: 1.7;
}

.skill-upload-area {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.skill-upload-hint {
  font-size: 12px; color: var(--text-muted); text-align: center;
}
.skill-item-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.skill-item-icon svg { width: 16px; height: 16px; }
.skill-item-content { flex: 1; min-width: 0; }
.skill-item-name { font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.skill-item-preview {
  font-size: 12px; color: var(--text-secondary); margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.5;
}

.modal {
  display: none;
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 26px;
  z-index: 301;
  min-width: 400px;
  box-shadow: var(--shadow-lg);
}
.modal.show {
  display: block;
  animation: modalIn 0.34s var(--ease-out);
}
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.94); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal h3 {
  margin-bottom: 12px;
  font-size: 17px; font-weight: 600;
  letter-spacing: -0.02em;
}
.modal-body-text {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.modal-emphasis {
  color: var(--text-primary);
  font-weight: 500;
}
.modal input {
  width: 100%; background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 11px 14px;
  font-size: 14px; font-family: var(--font-sans);
  outline: none;
  margin-bottom: 18px;
  transition: border-color var(--t-fast), box-shadow var(--t-base);
}
.modal input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== MAIN ===== */
.main {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg-primary);
}

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  min-height: 56px;
}

.model-selector { display: flex; align-items: center; gap: 10px; }
.model-label {
  font-size: 15.5px; font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  transition: background var(--t-fast);
  letter-spacing: -0.02em;
}
.model-label:hover { background: var(--bg-hover); }
.model-badge {
  font-size: 11px; font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  letter-spacing: 0.01em;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }

/* ===== DROP OVERLAY ===== */
.drop-overlay {
  display: none; position: absolute; inset: 56px 0 0 0;
  z-index: 50;
  background: var(--accent-soft);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border: 2px dashed var(--accent);
  margin: 12px;
  border-radius: var(--radius-xl);
  align-items: center; justify-content: center;
  animation: dropOverlayIn 0.24s var(--ease-out);
}
.drop-overlay.show { display: flex; }
@keyframes dropOverlayIn {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}
.drop-overlay-content svg {
  animation: dropPulse 1.6s var(--ease-snap) infinite;
  color: var(--accent);
  width: 48px; height: 48px;
}
@keyframes dropPulse {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.drop-overlay-content {
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 10px;
}
.drop-overlay-content p {
  font-size: 18px; font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.drop-overlay-content span { font-size: 13px; color: var(--text-muted); }

/* ===== CHAT ===== */
.chat-container {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  scroll-behavior: smooth;
}

.welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 22px; padding: 40px 20px;
}
.welcome-icon {
  width: 64px; height: 64px;
  border-radius: 22%;
  object-fit: cover;
  display: block;
  box-shadow: 0 12px 32px var(--accent-ring);
  animation: welcomeIn 0.7s var(--ease-out) backwards,
             gentleFloat 6s ease-in-out 0.7s infinite;
}
.welcome h1 {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.03em;
  text-align: center;
  color: var(--text-primary);
  animation: welcomeIn 0.7s var(--ease-out) 0.08s backwards;
}
.welcome.hidden { display: none; }

@keyframes welcomeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

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

.chip {
  padding: 9px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-family: var(--font-sans);
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: background var(--t-fast),
              border-color var(--t-fast),
              color var(--t-fast),
              transform 0.18s var(--ease-snap),
              box-shadow var(--t-base);
  animation: chipIn 0.5s var(--ease-out) backwards;
}
.welcome-chips .chip:nth-child(1) { animation-delay: 0.22s; }
.welcome-chips .chip:nth-child(2) { animation-delay: 0.28s; }
.welcome-chips .chip:nth-child(3) { animation-delay: 0.34s; }
.welcome-chips .chip:nth-child(4) { animation-delay: 0.40s; }
@keyframes chipIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.chip:active { transform: translateY(0); }

/* ===== MESSAGES ===== */
.messages {
  max-width: var(--max-width); width: 100%;
  margin: 0 auto;
  padding: 24px 22px 80px;
  display: flex; flex-direction: column;
  gap: 6px;
}

.message {
  display: flex; gap: 16px;
  padding: 10px 0;
  line-height: 1.7;
  font-size: 15.5px;
  letter-spacing: -0.005em;
  animation: messageIn 0.5s var(--ease-out);
}
@keyframes messageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.message-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin-top: 4px;
}
.message-avatar.user {
  background: linear-gradient(135deg, #837C72 0%, #5C5853 100%);
  color: #FAF9F5;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.01em;
}
[data-theme="light"] .message-avatar.user {
  background: linear-gradient(135deg, #C9C0AE 0%, #9C9384 100%);
  color: #FFFFFF;
}
.message-avatar.assistant {
  background: var(--accent);
  color: #FFFFFF;
  box-shadow: 0 2px 8px var(--accent-ring);
  overflow: hidden;
  border-radius: 28%;
  padding: 0;
}
.message-avatar.assistant img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.message-body { flex: 1; min-width: 0; }

.message-role {
  font-size: 12.5px; font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-primary);
  letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 8px;
}

.message-content { overflow-wrap: break-word; word-break: break-word; }

/* User-message bubble (real claude.ai look) */
.message.user-message .message-content {
  background: var(--bg-user-msg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
}

.message-files {
  display: flex; flex-wrap: wrap;
  gap: 8px; margin-bottom: 8px;
}
.message-file {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.message-file-icon { font-size: 18px; }
.message-file-info { display: flex; flex-direction: column; }
.message-file-name { font-weight: 500; color: var(--text-primary); }
.message-file-size { font-size: 11px; color: var(--text-muted); }
.message-file-img {
  max-width: 320px; max-height: 220px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
}
.message-file-img:hover { opacity: 0.92; }

.message-actions {
  display: flex; gap: 2px; margin-top: 8px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.24s var(--ease-snap), transform 0.24s var(--ease-snap);
}
.message:hover .message-actions { opacity: 1; transform: translateY(0); }

.msg-action-btn {
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 9px;
  border-radius: var(--radius-xs);
  display: inline-flex; align-items: center;
  gap: 5px; font-size: 12px; font-family: var(--font-sans);
  transition: background var(--t-fast), color var(--t-fast), transform 0.12s var(--ease-snap);
}
.msg-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.msg-action-btn:active { transform: scale(0.94); }
.msg-action-btn svg { width: 13px; height: 13px; }

/* Markdown rendering inside message-content */
.message-content p { margin-bottom: 12px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 8px 0 12px 22px; }
.message-content li { margin-bottom: 5px; }
.message-content li > p { margin-bottom: 5px; }
.message-content h1, .message-content h2,
.message-content h3, .message-content h4 {
  margin: 22px 0 10px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.3;
}
.message-content h1 { font-size: 1.45em; }
.message-content h2 { font-size: 1.25em; }
.message-content h3 { font-size: 1.10em; }
.message-content strong { font-weight: 600; }
.message-content a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--accent-soft);
  transition: border-color var(--t-fast);
}
.message-content a:hover { border-color: var(--accent); }

.message-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 6px 16px;
  margin: 14px 0;
  color: var(--text-secondary);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.message-content hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.message-content table {
  border-collapse: collapse;
  margin: 14px 0; width: 100%;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.message-content th, .message-content td {
  border-bottom: 1px solid var(--border);
  padding: 9px 13px; text-align: left;
}
.message-content tr:last-child td { border-bottom: none; }
.message-content th { background: var(--bg-secondary); font-weight: 600; }

/* Code blocks — dark body in both themes, sticky copy button */
.message-content pre {
  position: relative;
  background: #1A1A18;
  border-radius: var(--radius);
  margin: 16px 0;
  border: 1px solid var(--border);
}
/* Sticky bar: zero-height container so the button can stick to the top of the
   viewport while the code block is in view, then ride away with the block. */
.code-sticky-bar {
  position: sticky;
  top: 8px;
  height: 0;
  z-index: 3;
  pointer-events: none;
}
.code-copy-btn {
  position: absolute;
  top: 0; right: 8px;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  padding: 5px 11px;
  border-radius: var(--radius-xs);
  display: inline-flex; align-items: center;
  gap: 6px; font-size: 12px;
  font-family: var(--font-sans); font-weight: 500;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast), transform 0.12s var(--ease-snap);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.message-content pre:hover .code-copy-btn,
.code-copy-btn:focus-visible { opacity: 1; }
.code-copy-btn:hover { background: rgba(255, 255, 255, 0.12); color: #FFFFFF; }
.code-copy-btn:active { transform: scale(0.94); }
.code-copy-btn.copied { color: var(--success); opacity: 1; }
.code-copy-btn svg { width: 13px; height: 13px; flex-shrink: 0; }

.message-content pre code,
.message-content pre code.hljs {
  display: block;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  tab-size: 2;
  background: #1A1A18;
  color: #E5E4E0;
  border-radius: var(--radius);
}
.message-content :not(pre) > code {
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--accent);
}

/* ===== Scroll to bottom ===== */
.scroll-to-bottom {
  position: absolute;
  bottom: 100px; left: 50%;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  cursor: pointer;
  display: none; align-items: center; justify-content: center;
  z-index: 10;
  box-shadow: var(--shadow);
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  transition: opacity 0.22s var(--ease-out),
              transform 0.28s var(--ease-out),
              background var(--t-fast),
              color var(--t-fast),
              box-shadow var(--t-base);
}
.scroll-to-bottom.show {
  display: flex;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.scroll-to-bottom:hover {
  background: var(--bg-hover); color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%) translateY(-2px);
}
.scroll-to-bottom:active { transform: translateX(-50%) translateY(0) scale(0.92); }
.scroll-to-bottom svg { width: 16px; height: 16px; }

/* ===== Thinking block ===== */
.thinking-block {
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  margin: 14px 0;
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.thinking-toggle {
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  font-weight: 500; color: var(--accent);
  user-select: none;
  transition: opacity var(--t-fast);
}
.thinking-toggle:hover { opacity: 0.85; }
.thinking-toggle svg {
  width: 12px; height: 12px;
  transition: transform 0.3s var(--ease-out);
}
.thinking-toggle.open svg { transform: rotate(90deg); }
.thinking-content {
  margin-top: 10px;
  display: none; line-height: 1.65;
}
.thinking-content.show {
  display: block;
  animation: thinkingExpand 0.32s var(--ease-out);
}
@keyframes thinkingExpand {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Typing & streaming ===== */
.typing-indicator {
  display: flex; gap: 5px;
  padding: 8px 0;
  align-items: center;
}
.typing-indicator span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.35s var(--ease-snap) infinite;
  opacity: 0.7;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.18s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.36s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0) scale(0.65); opacity: 0.40; }
  40%           { transform: translateY(-5px) scale(1);    opacity: 1.00; }
}

.streaming-cursor::after {
  content: '';
  display: inline-block;
  width: 8px; height: 16px;
  margin-left: 3px;
  vertical-align: text-bottom;
  background: var(--accent);
  border-radius: 2px;
  animation: cursorBlink 1.1s ease-in-out infinite;
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.18; }
}

/* ===== Status (compaction) ===== */
.status-indicator {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px; margin: 4px 0 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  border-radius: var(--radius);
  animation: statusFadeIn 0.28s var(--ease-out);
}
@keyframes statusFadeIn {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}
.status-indicator .status-body { flex: 1; min-width: 0; }
.status-indicator .status-title {
  font-size: 13.5px; font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
}
.status-indicator .status-timer {
  font-size: 11.5px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: var(--accent-ring);
  color: var(--accent);
  padding: 1px 9px;
  border-radius: var(--radius-pill);
}
.status-indicator .status-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px; line-height: 1.5;
}

.status-spinner {
  position: relative;
  width: 22px; height: 22px;
  flex-shrink: 0; margin-top: 1px;
}
.status-spinner div {
  position: absolute; inset: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  animation: statusPulse 1.6s var(--ease-out) infinite;
  opacity: 0;
}
.status-spinner div:nth-child(2) { animation-delay: 0.4s; }
.status-spinner div:nth-child(3) { animation-delay: 0.8s; }
.status-spinner div:nth-child(4) { animation-delay: 1.2s; }
@keyframes statusPulse {
  0%   { transform: scale(0.4); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

.inline-error {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 16px;
  background: rgba(226, 117, 117, 0.08);
  border: 1px solid rgba(226, 117, 117, 0.30);
  border-left-width: 3px;
  border-radius: var(--radius);
  color: var(--error);
  font-size: 13.5px; line-height: 1.55;
  animation: statusFadeIn 0.28s var(--ease-out);
}
.inline-error svg { flex-shrink: 0; margin-top: 2px; width: 16px; height: 16px; }
.inline-error span { color: var(--text-primary); }

/* ===== File previews (input area) ===== */
.file-previews {
  max-width: var(--max-width); width: 100%;
  margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 0; max-height: 0; overflow: hidden;
  transition: max-height 0.34s var(--ease-out),
              padding 0.28s var(--ease-out);
}
.file-previews.has-files {
  padding: 10px 4px; max-height: 320px;
}
.file-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  position: relative;
  max-width: 260px;
  animation: chipIn 0.3s var(--ease-out);
}
.file-preview-icon { font-size: 20px; flex-shrink: 0; }
.file-preview-img {
  width: 42px; height: 42px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
}
.file-preview-info { flex: 1; min-width: 0; }
.file-preview-name {
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-preview-size { font-size: 11px; color: var(--text-muted); }
.file-preview-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  transition: background var(--t-fast),
              color var(--t-fast),
              border-color var(--t-fast),
              transform 0.14s var(--ease-snap);
}
.file-preview-remove:hover {
  background: var(--error); color: #FFFFFF;
  border-color: var(--error);
  transform: scale(1.05);
}

/* ===== INPUT ===== */
.input-area {
  padding: 0 22px 18px;
  display: flex; flex-direction: column; align-items: center;
}

.input-wrapper {
  max-width: var(--max-width); width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  display: flex; align-items: flex-end;
  padding: 8px 10px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: border-color 0.22s var(--ease-snap),
              box-shadow 0.3s var(--ease-snap);
}
.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring),
              0 4px 16px rgba(0, 0, 0, 0.06);
}

.input-left-actions, .input-right-actions {
  display: flex; align-items: center;
}

textarea {
  flex: 1; background: none; border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  resize: none; outline: none;
  max-height: 220px;
  padding: 7px 6px;
}
textarea::placeholder { color: var(--text-muted); }

.send-btn {
  width: 34px; height: 34px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #FFFFFF;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--t-fast),
              transform 0.14s var(--ease-snap),
              box-shadow var(--t-base),
              opacity var(--t-fast);
}
.send-btn:hover { background: var(--accent-hover); box-shadow: 0 4px 14px var(--accent-ring); }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.send-btn:disabled:hover { box-shadow: none; }
.send-btn.stop-btn { background: var(--error); }
.send-btn.stop-btn:hover { background: #C95252; box-shadow: 0 4px 14px rgba(226, 117, 117, 0.35); }
.send-btn svg { width: 18px; height: 18px; }

.disclaimer {
  font-size: 12px; color: var(--text-muted);
  margin-top: 9px;
  letter-spacing: -0.005em;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed; bottom: 90px;
  left: 50%; transform: translateX(-50%);
  z-index: 500;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px; font-family: var(--font-sans);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.4s var(--ease-out),
             toastOut 0.34s var(--ease-snap) 2.7s forwards;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error);   }
.toast.info    { border-left: 3px solid var(--accent);  }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-10px) scale(0.97); }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 4px;
  border: 2px solid var(--bg-sidebar);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint); background-clip: padding-box;
  border: 2px solid var(--bg-sidebar);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.30);
  }
  .sidebar.hidden { margin-left: -260px; }
  .messages { padding: 18px 18px 80px; }
  .welcome h1 { font-size: 24px; }
  .slide-panel { width: 100%; right: -100%; }
  .modal { min-width: auto; width: calc(100% - 32px); }
}
