/* ═══════════════════════════════════════════════════════════════
   Claude App — Dark Theme Stylesheet
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --bg: #0d0d0f;
  --surface: #1a1a1f;
  --surface2: #222228;
  --border: #2a2a35;
  --text: #e8e8ec;
  --text-muted: #888;
  --accent: #cc785c;
  --accent2: #e8a87c;
  --user-bubble: #1e3a5f;
  --assistant-bubble: #1a1a1f;
  --header-h: 56px;
  --footer-h: 80px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────────── */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: rgba(13,13,15,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 16px;
  max-width: 800px;
  margin: 0 auto;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-actions { display: flex; gap: 8px; }

/* ── Icon buttons ────────────────────────────────────────────── */
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover, .icon-btn:active { background: var(--surface); color: var(--text); }

/* ── Messages ────────────────────────────────────────────────── */
#messages {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top));
  bottom: calc(var(--footer-h) + var(--safe-bottom));
  left: 0;
  right: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg-wrap {
  display: flex;
  margin-bottom: 16px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

.msg-wrap.user { justify-content: flex-end; }
.msg-wrap.assistant { justify-content: flex-start; }

.bubble {
  max-width: min(80%, 600px);
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.65;
  word-break: break-word;
}
.msg-wrap.user .bubble {
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
  color: #c8e0ff;
}
.msg-wrap.assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

/* Markdown content */
.bubble h1, .bubble h2, .bubble h3 {
  font-weight: 700;
  margin: 12px 0 6px;
  line-height: 1.3;
}
.bubble h1 { font-size: 1.3em; }
.bubble h2 { font-size: 1.15em; }
.bubble h3 { font-size: 1.05em; }
.bubble p { margin: 6px 0; }
.bubble p:first-child { margin-top: 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { padding-left: 20px; margin: 6px 0; }
.bubble li { margin: 3px 0; }
.bubble code {
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 0.9em;
}
.bubble pre {
  background: #0a0a0c;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
}
.bubble pre code {
  background: none;
  padding: 0;
  font-size: 0.88em;
  line-height: 1.5;
}
.bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-muted);
  margin: 8px 0;
}
.bubble strong { font-weight: 700; color: #fff; }
.bubble em { font-style: italic; }
.bubble a { color: var(--accent2); text-decoration: underline; }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.bubble table { border-collapse: collapse; width: 100%; font-size: 0.9em; margin: 8px 0; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.bubble th { background: var(--surface2); font-weight: 600; }

/* Bubble actions */
.bubble-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}
.msg-wrap:hover .bubble-actions,
.msg-wrap:focus-within .bubble-actions { opacity: 1; }
.bubble-action-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.bubble-action-btn:hover { color: var(--text); border-color: var(--accent); }

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}
.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
}

/* ── Empty State ─────────────────────────────────────────────── */
#emptyState {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top));
  bottom: calc(var(--footer-h) + var(--safe-bottom));
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.empty-logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-logo h2 {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.empty-logo p { color: var(--text-muted); font-size: 15px; }

/* ── TTS Indicator ───────────────────────────────────────────── */
.tts-indicator {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.tts-indicator button {
  background: var(--border);
  border: none;
  border-radius: 8px;
  padding: 3px 10px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.tts-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
}
.tts-wave span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  animation: wave 0.8s ease-in-out infinite;
}
.tts-wave span:nth-child(1) { height: 6px; animation-delay: 0s; }
.tts-wave span:nth-child(2) { height: 14px; animation-delay: 0.1s; }
.tts-wave span:nth-child(3) { height: 20px; animation-delay: 0.2s; }
.tts-wave span:nth-child(4) { height: 14px; animation-delay: 0.3s; }
.tts-wave span:nth-child(5) { height: 6px; animation-delay: 0.4s; }
@keyframes wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

/* ── Footer ──────────────────────────────────────────────────── */
#footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 12px calc(12px + var(--safe-bottom));
  background: rgba(13,13,15,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 100;
}
.input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto;
}

/* Mic button */
.mic-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mic-btn:hover { border-color: var(--accent); color: var(--accent); }
.mic-btn.recording {
  background: rgba(204,120,92,0.15);
  border-color: var(--accent);
  color: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(204,120,92,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(204,120,92,0); }
}

/* Text input */
.input-box {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  transition: border-color 0.2s;
  min-height: 48px;
  display: flex;
  align-items: center;
}
.input-box:focus-within { border-color: var(--accent); }
#userInput {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  font-family: inherit;
}
#userInput::placeholder { color: var(--text-muted); }
#userInput::-webkit-scrollbar { width: 3px; }
#userInput::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Send button */
.send-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.send-btn:disabled {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--border);
  cursor: not-allowed;
}
.send-btn:not(:disabled):hover { opacity: 0.9; transform: scale(1.05); }
.send-btn:not(:disabled):active { transform: scale(0.95); }

/* Voice status */
.voice-status {
  text-align: center;
  font-size: 13px;
  color: var(--accent);
  margin-top: 6px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  padding: 4px 0;
}

/* ── Settings Panel ──────────────────────────────────────────── */
.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.settings-panel.hidden { display: none; }
.settings-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px 20px calc(24px + var(--safe-bottom));
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.settings-header h2 { font-size: 18px; font-weight: 700; }
.setting-group {
  margin-bottom: 20px;
}
.setting-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.setting-group select,
.setting-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
}
.setting-group select:focus,
.setting-group textarea:focus { border-color: var(--accent); }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle .slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

.danger-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid #ff6b6b;
  border-radius: 10px;
  color: #ff6b6b;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.danger-btn:hover { background: rgba(255,107,107,0.1); }

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

@media (min-width: 600px) {
  .settings-content { border-radius: 20px; margin: 20px; }
  .settings-panel { align-items: center; }
}
