/* ============================================
   CLAUDE INTERFACE REPLICA
   ============================================ */

:root {
  /* Palette Claude (dark) */
  --bg: #262624;
  --bg-2: #1f1e1d;
  --sidebar: #1f1e1d;
  --sidebar-hover: #2a2927;
  --panel: #30302e;
  --panel-2: #393937;
  --border: #3a3a37;
  --border-soft: #2e2d2b;

  --text: #f5f4ee;
  --text-2: #c9c7bd;
  --text-3: #8a8780;
  --text-4: #66635c;

  --accent: #d97757;
  --accent-2: #c66547;
  --accent-soft: rgba(217, 119, 87, 0.15);

  --user-bubble: #3a3a37;

  --code-bg: #1a1918;
  --code-border: #2e2d2b;

  --shadow-soft: 0 1px 2px rgba(0,0,0,0.2), 0 8px 24px rgba(0,0,0,0.15);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.2);

  --sidebar-w: 260px;

  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Copernicus', 'Inter', ui-serif, Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3a3937; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #4a4946; background-clip: padding-box; border: 2px solid transparent; }

/* ============================================
   APP LAYOUT
   ============================================ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 10px 8px 8px;
  transition: width .25s cubic-bezier(.4,0,.2,1), padding .25s;
  overflow: hidden;
}

.app.collapsed .sidebar {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-right-color: transparent;
}

.sidebar-top { padding: 4px 6px 8px; }

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  margin-bottom: 14px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.sidebar-toggle {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-3);
  transition: background .15s, color .15s;
}
.sidebar-toggle:hover { background: var(--sidebar-hover); color: var(--text); }
.sidebar-toggle i { width: 18px; height: 18px; }

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  transition: background .15s;
  text-align: left;
}
.new-chat-btn:hover { background: var(--accent-soft); }
.new-chat-btn i { width: 16px; height: 16px; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 450;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--text); }
.nav-item i { width: 16px; height: 16px; opacity: .85; }

/* Recents */
.sidebar-recents {
  flex: 1;
  overflow-y: auto;
  padding: 12px 6px 4px;
  min-height: 0;
}
.recents-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 0 8px;
  margin-bottom: 6px;
}
.recents-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.recent {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .15s, color .15s;
}
.recent:hover { background: var(--sidebar-hover); color: var(--text); }
.recent.active { background: var(--sidebar-hover); color: var(--text); }

.see-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 4px);
  margin: 8px 2px 4px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-3);
  font-size: 13px;
  transition: background .15s, color .15s;
}
.see-more:hover { background: var(--sidebar-hover); color: var(--text); }
.see-more i { width: 14px; height: 14px; }

/* Sidebar bottom: account */
.sidebar-bottom {
  border-top: 1px solid var(--border-soft);
  padding: 8px 4px 2px;
}
.account {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 8px;
  border-radius: 10px;
  transition: background .15s;
}
.account:hover { background: var(--sidebar-hover); }
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d97757, #b35435);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.account-info { flex: 1; text-align: left; min-width: 0; }
.account-name { font-size: 13.5px; font-weight: 500; color: var(--text); line-height: 1.2; }
.account-plan { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.acc-chev { width: 14px; height: 14px; color: var(--text-3); }

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

/* TOPBAR */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel); color: var(--text); }
.icon-btn i { width: 18px; height: 18px; }

.mobile-only { display: none; }

.model-selector {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 7px 12px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  transition: background .15s;
}
.model-selector:hover { background: var(--panel); }
.model-selector i { width: 16px; height: 16px; color: var(--text-3); transition: transform .2s; }
.model-selector.open i.lucide-chevron-down { transform: rotate(180deg); }
.model-name { display: inline-flex; align-items: center; gap: 6px; }

.model-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  display: none;
  text-align: left;
}
.model-selector.open .model-dropdown { display: block; animation: dd-pop .15s ease-out; }

@keyframes dd-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dd-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 8px 10px 6px;
}

.dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.dd-item:hover { background: var(--panel-2); }
.dd-item.selected { background: transparent; }
.dd-item.selected i { color: var(--accent); width: 16px; height: 16px; }

.dd-item-main { flex: 1; min-width: 0; }
.dd-item-title { font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.2; }
.dd-item-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.dd-divider { height: 1px; background: var(--border); margin: 4px 6px; }

.dd-item-row { font-size: 13.5px; color: var(--text-2); }
.dd-item-row i { width: 16px; height: 16px; color: var(--text-3); }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--border);
  transition: background .15s, color .15s, border-color .15s;
}
.pill-btn:hover { background: var(--panel); color: var(--text); border-color: var(--panel-2); }
.pill-btn i { width: 15px; height: 15px; }

/* ============================================
   CHAT
   ============================================ */
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 16px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 740px;
  margin: 0 auto 28px;
}

/* USER */
.msg.user {
  display: flex;
  justify-content: flex-end;
}
.user-bubble {
  background: var(--user-bubble);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 78%;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ASSISTANT */
.msg.assistant {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.assistant-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #1f1e1d;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.assistant-content {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--text);
}
.assistant-content p { margin: 0 0 14px; }
.assistant-content p:last-child { margin-bottom: 0; }
.assistant-content ul, .assistant-content ol {
  margin: 0 0 14px;
  padding-left: 22px;
}
.assistant-content li { margin-bottom: 6px; }
.assistant-content strong { font-weight: 600; color: var(--text); }
.assistant-content code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  background: var(--panel);
  padding: 2px 6px;
  border-radius: 5px;
  color: #e8c4a8;
}

/* Code block */
.code-block {
  margin: 14px 0 18px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 10px;
  overflow: hidden;
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 8px 14px;
  background: #221f1e;
  border-bottom: 1px solid var(--code-border);
}
.code-lang {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
}
.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-3);
  transition: background .15s, color .15s;
}
.code-copy:hover { background: #2a2625; color: var(--text); }
.code-copy i { width: 13px; height: 13px; }

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: #d6d2c4;
}
.code-block code { background: none; padding: 0; color: inherit; font-size: inherit; }

.tk-kw { color: #c178c1; }
.tk-fn { color: #82b4dd; }
.tk-tag { color: #d97757; }
.tk-attr { color: #d2a86a; }
.tk-str { color: #a7c080; }

/* Message actions */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  margin-left: -6px;
  opacity: 0;
  transition: opacity .2s;
}
.msg.assistant:hover .msg-actions { opacity: 1; }

.msg-action {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: var(--text-3);
  transition: background .15s, color .15s;
}
.msg-action:hover { background: var(--panel); color: var(--text); }
.msg-action i { width: 15px; height: 15px; }

.msg-action-text {
  width: auto;
  padding: 0 10px;
  gap: 6px;
  font-size: 12.5px;
  margin-left: 6px;
}

/* ============================================
   COMPOSER
   ============================================ */
.composer-wrap {
  padding: 8px 20px 14px;
  flex-shrink: 0;
}

.composer {
  max-width: 740px;
  margin: 0 auto;
  position: relative;
}

.composer-badge {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent);
  background: rgba(217, 119, 87, 0.08);
  border: 1px solid rgba(217, 119, 87, 0.25);
  border-radius: 999px;
  white-space: nowrap;
  animation: badge-in .5s cubic-bezier(.2,.8,.2,1) both;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(217,119,87,.55);
  animation: pulse-dot 1.6s ease-out infinite;
}

@keyframes badge-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(217,119,87,.55); }
  70%  { box-shadow: 0 0 0 8px rgba(217,119,87,0); }
  100% { box-shadow: 0 0 0 0 rgba(217,119,87,0); }
}

.composer-glow {
  border-color: rgba(217, 119, 87, 0.45) !important;
  box-shadow:
    0 0 0 3px rgba(217,119,87,.08),
    0 0 24px rgba(217,119,87,.18) !important;
  animation: glow-breathe 3.5s ease-in-out infinite;
}
@keyframes glow-breathe {
  0%, 100% { box-shadow: 0 0 0 3px rgba(217,119,87,.06), 0 0 18px rgba(217,119,87,.14); }
  50%      { box-shadow: 0 0 0 3px rgba(217,119,87,.12), 0 0 32px rgba(217,119,87,.28); }
}

.composer-inner {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px 12px 6px;
  transition: border-color .15s, box-shadow .15s;
}
.composer-inner:focus-within {
  border-color: #4f4d49;
  box-shadow: 0 0 0 3px rgba(217,119,87,.06);
}

.composer-input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
  padding: 6px 4px 4px;
  max-height: 220px;
}
.composer-input::placeholder { color: var(--text-3); }

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  width: 30px;
  border-radius: 8px;
  color: var(--text-3);
  transition: background .15s, color .15s;
}
.tool-btn:hover { background: var(--panel-2); color: var(--text); }
.tool-btn i { width: 16px; height: 16px; }

.tool-pill {
  width: auto;
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--text-2);
  border: 1px solid transparent;
}
.tool-pill:hover { border-color: var(--border); background: var(--panel-2); }

.send-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s, opacity .15s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-2); }
.send-btn:active:not(:disabled) { transform: scale(.94); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; background: var(--panel-2); color: var(--text-3); }
.send-btn i { width: 17px; height: 17px; stroke-width: 2.5; }

.composer-footnote {
  text-align: center;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-4);
}

/* ============================================
   TYPING DOTS (for streaming responses)
   ============================================ */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.typing span {
  width: 6px;
  height: 6px;
  background: var(--text-3);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 820px) {
  :root { --sidebar-w: 280px; }
  .mobile-only { display: inline-flex; }
  .sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    width: var(--sidebar-w);
  }
  .app.mobile-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .app.collapsed .sidebar { width: var(--sidebar-w); }
  .pill-btn span { display: none; }
  .pill-btn { padding: 7px; }
  .messages { padding: 18px 14px 8px; }
  .composer-wrap { padding: 6px 14px 12px; }
  .tool-pill span { display: none; }
  .tool-pill { width: 30px; padding: 0; }
}

/* Backdrop for mobile sidebar */
.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 20;
}
.app.mobile-open .backdrop { opacity: 1; pointer-events: auto; }
