/* ============================================
   AsefAI — Premium Dark UI
   Palette: Deep Charcoal + Violet/Indigo
============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&display=swap');

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

/* ── Tokens ──────────────────────────────── */
:root {
  /* Backgrounds — pure dark */
  --bg-base:      #0a0a0a;
  --bg-surface:   #111111;
  --bg-elevated:  #1a1a1a;
  --bg-overlay:   #222222;

  /* Accent — crisp white */
  --accent:       #ffffff;
  --accent-light: #e8e8e8;
  --accent-dark:  #cccccc;
  --accent-glow:  rgba(255,255,255,0.08);
  --accent-glow2: rgba(255,255,255,0.04);

  /* Text */
  --text-primary:   #f0f0f0;
  --text-secondary: #888888;
  --text-muted:     #555555;
  --text-faint:     #333333;

  /* Borders */
  --border:       rgba(255,255,255,0.07);
  --border-focus: rgba(255,255,255,0.35);
  --divider:      rgba(255,255,255,0.04);

  /* Bubbles */
  --bubble-user: #1f1f1f;
  --bubble-ai:   #161616;

  /* Feedback */
  --success: #4ade80;
  --error:   #f87171;
  --warning: #fbbf24;

  --sidebar-w: 264px;
  --header-h:  56px;
  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 7px;
  --radius-xs: 5px;

  --t-fast:   0.15s ease;
  --t-normal: 0.25s ease;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.6);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.7);
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: var(--accent); color: #fff; }

body { display: flex; height: 100vh; }

/* Pakai dvh (dynamic viewport height) agar input tidak ketutupan keyboard virtual */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
  body { height: 100dvh; }
}

/* Scrollbars */
::-webkit-scrollbar             { width: 4px; height: 4px; }
::-webkit-scrollbar-track       { background: transparent; }
::-webkit-scrollbar-thumb       { background: var(--text-faint); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 11px;
  gap: 9px;
  z-index: 200;
  transition: transform var(--t-normal);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 5px 14px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 2px;
}

.logo-mark {
  width: 30px; height: 30px;
  background: #ffffff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #0a0a0a; flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(255,255,255,0.15);
}

.logo-text {
  font-size: 14px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--text-primary);
}

.logo-tag {
  font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px;
  background: rgba(255,255,255,0.06); color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 20px; margin-left: auto;
}

.btn-new-chat {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 13px; font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: all var(--t-fast);
}
.btn-new-chat:hover { background: var(--bg-overlay); border-color: rgba(255,255,255,0.2); color: var(--text-primary); }

.sidebar-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-faint); padding: 4px 5px 0;
}

.chat-history {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}

.history-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 7px; padding: 24px 0;
  color: var(--text-faint); font-size: 11.5px;
}

/* Session item */
.session-item {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-secondary);
  cursor: pointer; transition: all var(--t-fast);
  border: 1px solid transparent;
  white-space: nowrap; overflow: hidden;
}

.session-item:hover { background: var(--bg-elevated); color: var(--text-primary); }

.session-item.active {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.session-item::before {
  content: '';
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--text-faint); flex-shrink: 0;
  transition: background var(--t-fast);
}

.session-item.active::before { background: var(--text-secondary); }

.session-item-text {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
}

.session-item-del {
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; padding: 2px 4px; border-radius: 3px;
  font-size: 13px; line-height: 1; flex-shrink: 0;
  opacity: 0; transition: all var(--t-fast);
}

.session-item:hover .session-item-del { opacity: 1; }
.session-item-del:hover { color: var(--error); background: rgba(248,113,113,0.1); }

/* Footer */
.sidebar-footer {
  padding-top: 10px; border-top: 1px solid var(--divider);
  display: flex; flex-direction: column; gap: 7px;
}

.token-counter {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-muted);
  padding: 5px 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.token-counter svg { flex-shrink: 0; opacity: 0.6; }
#tokenCount { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.btn-clear {
  display: flex; align-items: center; gap: 7px;
  width: 100%; background: transparent;
  border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: var(--radius-sm); padding: 7px 11px;
  font-size: 12px; font-family: inherit; cursor: pointer;
  transition: all var(--t-fast);
}
.btn-clear:hover { background: rgba(248,113,113,0.08); border-color: rgba(248,113,113,0.3); color: var(--error); }

.sidebar-info {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-faint); padding: 0 3px;
}

.model-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }

/* ══════════════════════════════════════════
   MAIN
══════════════════════════════════════════ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Header ──────────────────────────────── */
.header {
  height: var(--header-h);
  background: rgba(13,13,18,0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 10px;
  flex-shrink: 0; position: relative; z-index: 100;
}

.btn-hamburger, .btn-icon {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 6px; border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast);
}
.btn-hamburger { display: none; }
.btn-hamburger:hover, .btn-icon:hover { background: var(--bg-elevated); color: var(--text-primary); }

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

.header-title {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}

.header-status {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--success); font-weight: 500;
  white-space: nowrap; position: relative;
}

.status-dot { width: 6px; height: 6px; background: var(--success); border-radius: 50%; }

.pulse-ring {
  position: absolute; left: 0;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  animation: pulseRing 2.5s ease-out infinite;
}

@keyframes pulseRing {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(3); opacity: 0; }
}

.header-actions { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }

/* ── Model Selector ──────────────────────── */
.model-selector-wrap { position: relative; }

.btn-model-selector {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 5px 10px; font-size: 12px; font-family: inherit;
  cursor: pointer; transition: all var(--t-fast);
  white-space: nowrap;
}
.btn-model-selector:hover { border-color: rgba(255,255,255,0.2); color: var(--text-primary); }
.btn-model-selector.open { border-color: rgba(255,255,255,0.3); color: var(--text-primary); }

.model-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 300;
  overflow: hidden;
  opacity: 0; transform: translateY(-8px) scale(0.97);
  pointer-events: none;
  transition: all var(--t-fast);
}

.model-dropdown.open {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: auto;
}

.model-dropdown-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-faint);
  padding: 10px 14px 6px;
}

.model-option {
  display: flex; align-items: center; gap: 10px;
  width: 100%; background: none; border: none;
  padding: 9px 14px; cursor: pointer; text-align: left;
  transition: background var(--t-fast);
  border-top: 1px solid var(--divider);
}
.model-option:hover { background: var(--bg-overlay); }
.model-option:first-of-type { border-top: none; }

.model-option-info { flex: 1; }
.model-option-name { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary); }
.model-option-desc { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.model-check { color: var(--text-primary); font-size: 13px; opacity: 0; transition: opacity var(--t-fast); }
.model-option.active .model-check { opacity: 1; }

/* ══════════════════════════════════════════
   CHAT AREA
══════════════════════════════════════════ */
.chat-area {
  flex: 1; overflow-y: auto;
  padding: 28px 0;
  display: flex; flex-direction: column;
  scroll-behavior: smooth;
}

/* ── Welcome ─────────────────────────────── */
.welcome-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1; min-height: 55vh;
  text-align: center; padding: 40px 24px;
  position: relative;
  animation: fadeUp 0.45s ease;
}

.welcome-glow {
  position: absolute;
  width: 400px; height: 280px;
  background: radial-gradient(ellipse, rgba(124,111,224,0.1) 0%, transparent 70%);
  top: 50%; left: 50%; transform: translate(-50%,-50%);
  pointer-events: none;
}

.welcome-icon {
  width: 58px; height: 58px;
  background: #ffffff;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: #0a0a0a; margin-bottom: 20px;
  box-shadow: 0 8px 40px rgba(255,255,255,0.12);
  animation: iconFloat 4s ease-in-out infinite;
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%       { transform: translateY(-6px) rotate(3deg); }
}

.welcome-title {
  font-size: 28px; font-weight: 700; letter-spacing: -0.8px;
  color: var(--text-primary); margin-bottom: 5px;
}

.gradient-text {
  background: linear-gradient(135deg, #ffffff, #888888);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.welcome-sub { font-size: 11.5px; color: var(--text-faint); font-weight: 500; margin-bottom: 12px; }

.welcome-desc {
  font-size: 13.5px; color: var(--text-secondary);
  max-width: 400px; line-height: 1.8; margin-bottom: 28px;
}
.welcome-desc em { font-style: normal; color: var(--text-primary); font-weight: 500; }

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

.chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); padding: 7px 13px;
  border-radius: 20px; font-size: 12px; font-family: inherit;
  cursor: pointer; transition: all var(--t-fast);
}
.chip svg { opacity: 0.5; flex-shrink: 0; }
.chip:hover {
  background: var(--bg-overlay); border-color: rgba(255,255,255,0.2);
  color: var(--text-primary); transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(255,255,255,0.06);
}
.chip:hover svg { opacity: 1; }

/* ══════════════════════════════════════════
   MESSAGES
══════════════════════════════════════════ */
.messages { display: flex; flex-direction: column; gap: 0; padding-bottom: 8px; }

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

.msg-row { display: flex; padding: 5px 0; animation: fadeUp 0.25s ease; }
.msg-row.user { justify-content: flex-end; }
.msg-row.ai   { justify-content: flex-start; }

.msg-inner {
  max-width: 72%; display: flex; flex-direction: column;
  gap: 4px; padding: 0 22px;
}
.msg-row.user .msg-inner { align-items: flex-end; }
.msg-row.ai   .msg-inner { align-items: flex-start; }

.msg-header { display: flex; align-items: center; gap: 7px; }

.msg-avatar {
  width: 24px; height: 24px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.msg-row.ai   .msg-avatar { background: linear-gradient(135deg,var(--accent),#a78bfa); color:#fff; }
.msg-row.user .msg-avatar { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary); }

.msg-sender { font-size: 10.5px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.2px; }

.msg-bubble {
  padding: 11px 15px; border-radius: var(--radius-md);
  font-size: 13.5px; line-height: 1.75; word-break: break-word;
}

.msg-row.user .msg-bubble {
  background: #1f1f1f;
  color: var(--text-primary); border-bottom-right-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
.msg-row.ai .msg-bubble {
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.msg-row.error .msg-bubble {
  background: rgba(248,113,113,0.07);
  border-color: rgba(248,113,113,0.2); color: #fca5a5;
}

.msg-footer { display: flex; align-items: center; gap: 7px; padding: 0 2px; }

.msg-time { font-size: 10px; color: var(--text-faint); }

.provider-badge {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-overlay);
  padding: 2px 7px;
  border-radius: 10px;
}

.btn-copy-msg {
  display: flex; align-items: center; gap: 4px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-faint); border-radius: var(--radius-xs);
  padding: 2px 7px; font-size: 10.5px; font-family: inherit;
  cursor: pointer; opacity: 0; transition: all var(--t-fast);
}
.msg-row:hover .btn-copy-msg { opacity: 1; border-color: var(--border); color: var(--text-secondary); }
.btn-copy-msg:hover { background: var(--bg-overlay); color: var(--text-primary); }
.btn-copy-msg.copied { color: var(--success); border-color: rgba(74,222,128,0.3); }

/* ── Typing ──────────────────────────────── */
.typing-row { display: flex; padding: 5px 0; animation: fadeUp 0.25s ease; }
.typing-inner { padding: 0 22px; max-width: 72%; display: flex; flex-direction: column; gap: 4px; }

.typing-bubble {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); border-bottom-left-radius: 4px;
  padding: 11px 15px; display: flex; align-items: center; gap: 9px;
}

.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--text-secondary);
  animation: dotBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotBounce {
  0%,80%,100% { transform: translateY(0); opacity: 0.4; }
  40%         { transform: translateY(-7px); opacity: 1; }
}

.typing-label { font-size: 12px; color: var(--text-muted); font-style: italic; }

/* ══════════════════════════════════════════
   MARKDOWN
══════════════════════════════════════════ */
.msg-bubble p { margin-bottom: 7px; }
.msg-bubble p:last-child { margin-bottom: 0; }

.msg-bubble h1,.msg-bubble h2,.msg-bubble h3 { font-weight: 600; margin: 13px 0 5px; letter-spacing: -0.3px; }
.msg-bubble h1 { font-size: 1.12em; }
.msg-bubble h2 { font-size: 1.03em; }
.msg-bubble h3 { font-size: 0.96em; color: var(--text-secondary); }

.msg-bubble ul,.msg-bubble ol { padding-left: 17px; margin-bottom: 7px; }
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble strong { color: #d4d4f0; font-weight: 600; }
.msg-bubble em { color: #a5a5c8; }
.msg-bubble a { color: var(--text-primary); text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.25); }
.msg-bubble a:hover { border-color: var(--text-primary); }

.msg-bubble blockquote {
  border-left: 2px solid var(--text-muted); padding: 5px 0 5px 13px;
  margin: 9px 0; color: var(--text-secondary); font-style: italic;
  background: rgba(255,255,255,0.02); border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.msg-bubble hr { border: none; border-top: 1px solid var(--divider); margin: 11px 0; }

.msg-bubble table { width: 100%; border-collapse: collapse; margin-bottom: 9px; font-size: 12.5px; }
.msg-bubble th,.msg-bubble td { border: 1px solid var(--border); padding: 6px 11px; }
.msg-bubble th { background: rgba(255,255,255,0.05); color: var(--text-primary); font-weight: 600; }
.msg-bubble tr:hover td { background: rgba(255,255,255,0.02); }

.msg-bubble code:not(pre code) {
  background: rgba(255,255,255,0.08); color: var(--text-primary);
  padding: 2px 6px; border-radius: 4px;
  font-family: 'Fira Code', monospace; font-size: 12px;
  border: 1px solid rgba(255,255,255,0.08);
}

.code-wrapper { margin: 11px 0; border-radius: var(--radius-md); overflow: hidden; border: 1px solid rgba(255,255,255,0.07); }

.code-header {
  display: flex; align-items: center; justify-content: space-between;
  background: #0a0a10; padding: 7px 13px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.code-lang-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-faint); }

.btn-copy-code {
  display: flex; align-items: center; gap: 4px;
  background: transparent; border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted); border-radius: var(--radius-xs);
  padding: 3px 9px; font-size: 10.5px; font-family: inherit; cursor: pointer;
  transition: all var(--t-fast);
}
.btn-copy-code:hover { background: var(--bg-overlay); color: var(--text-primary); }
.btn-copy-code.copied { color: var(--success); border-color: rgba(74,222,128,0.3); }

.msg-bubble pre { margin: 0; background: #0a0a10; }
.msg-bubble pre code {
  display: block; padding: 13px 15px;
  font-family: 'Fira Code', monospace; font-size: 12.5px;
  line-height: 1.65; overflow-x: auto;
  color: #c9d1d9; background: transparent;
}

/* ── Streaming cursor ────────────────────── */
.cursor-blink {
  display: inline-block; width: 2px; height: 1em;
  background: var(--text-secondary); margin-left: 2px;
  vertical-align: text-bottom; border-radius: 1px;
  animation: blink 0.7s step-end infinite;
}
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }

/* ══════════════════════════════════════════
   INPUT AREA
══════════════════════════════════════════ */
.input-area {
  padding: 12px 22px 16px;
  background: var(--bg-base); border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* System Prompt Bar */
.system-prompt-bar {
  background: var(--bg-elevated); border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md); padding: 10px 13px;
  margin-bottom: 10px; animation: fadeUp 0.2s ease;
}

.sp-header {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; color: var(--text-primary);
  margin-bottom: 8px;
}
.sp-header svg { opacity: 0.8; }
.sp-header span { flex: 1; }

.sp-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px;
  transition: color var(--t-fast);
}
.sp-close:hover { color: var(--text-primary); }

.sp-textarea {
  width: 100%; background: var(--bg-overlay);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 12.5px; font-family: inherit;
  line-height: 1.55; padding: 8px 11px; resize: none; outline: none;
  transition: border-color var(--t-fast);
}
.sp-textarea:focus { border-color: var(--border-focus); }
.sp-textarea::placeholder { color: var(--text-faint); }

.sp-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 7px;
}
.sp-char { font-size: 10.5px; color: var(--text-faint); }

.sp-apply {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-xs); padding: 5px 14px;
  font-size: 12px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: background var(--t-fast);
}
.sp-apply:hover { background: var(--accent-light); }

/* Active system prompt indicator */
.sp-active-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 10.5px; color: var(--text-secondary);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 4px; padding: 3px 8px; margin-bottom: 8px;
  cursor: pointer; width: fit-content;
  transition: all var(--t-fast);
}
.sp-active-badge:hover { background: var(--bg-overlay); }
.sp-active-badge svg { opacity: 0.5; }

/* Input box */
.input-box {
  display: flex; align-items: flex-end; gap: 9px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px 13px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input-box:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(255,255,255,0.04); }

.message-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13.5px; font-family: 'Inter', sans-serif;
  line-height: 1.5; resize: none; max-height: 130px; overflow-y: auto; padding: 2px 0;
}
.message-input::placeholder { color: var(--text-faint); }

.input-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

.char-count { font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; transition: color var(--t-fast); }
.char-count.warn   { color: var(--warning); }
.char-count.danger { color: var(--error); }

.btn-send {
  width: 33px; height: 33px; background: #ffffff; border: none;
  border-radius: var(--radius-sm); color: #0a0a0a; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast);
  box-shadow: 0 2px 10px rgba(255,255,255,0.1); flex-shrink: 0;
}
.btn-send:hover:not(:disabled) { background: var(--accent-light); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(255,255,255,0.15); }
.btn-send:active:not(:disabled) { transform: translateY(0); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-send .icon-loading { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.input-hint { text-align: center; font-size: 10.5px; color: var(--text-faint); margin-top: 7px; }

/* ── Utility ─────────────────────────────── */
.hidden { display: none !important; }

/* ── Sidebar Overlay ─────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 150;
  backdrop-filter: blur(3px);
}

.modal-backdrop {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(0,0,0,0.5);
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Sidebar jadi overlay — tidak makan ruang layout */
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 82vw);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 40px rgba(0,0,0,0.6); }
  .sidebar-overlay.open { display: block; }
  .btn-hamburger { display: flex; }

  /* Main selalu full width */
  .main { width: 100%; flex: 1; }

  .chat-area { padding: 18px 0; }
  .msg-inner { padding: 0 12px; max-width: 92%; }
  .typing-inner { padding: 0 12px; }

  /* Input area sticky di atas keyboard — pakai dvh + safe-area */
  .input-area {
    padding: 10px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    position: sticky;
    bottom: 0;
    z-index: 50;
  }

  .welcome-title { font-size: 22px; }

  /* Sembunyikan teks model, cukup icon */
  .model-selector-wrap .btn-model-selector span:not(:last-child) { display: none; }

  .input-hint { display: none; }
}

@media (max-width: 480px) {
  .msg-inner { max-width: 96%; }
  .welcome-chips { gap: 6px; }
  .chip { font-size: 11.5px; padding: 7px 11px; }
  .header { padding: 0 10px; gap: 6px; }
  .header-title { max-width: 110px; }
  /* Input font lebih besar di HP biar tidak di-zoom browser */
  .message-input { font-size: 16px; }
}
