/* Claude Opus 5 Chat - dark theme, Claude-inspired */

:root {
  --bg: #0f0f10;
  --bg-elev: #181819;
  --bg-elev-2: #1f1f21;
  --bg-hover: #26262a;
  --border: #2a2a2e;
  --border-strong: #3a3a40;
  --text: #ececec;
  --text-dim: #a1a1a8;
  --text-faint: #6e6e76;
  --accent: #d97706;
  --accent-hover: #f59e0b;
  --accent-soft: rgba(217, 119, 6, 0.12);
  --user-bubble: #2a2a2e;
  --assistant-bubble: transparent;
  --danger: #ef4444;
  --success: #10b981;
  --code-bg: #0b0b0c;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }

kbd {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: "JetBrains Mono", monospace;
}

/* Layout */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

.app.collapsed { grid-template-columns: 0 1fr; }
.app.collapsed .sidebar { transform: translateX(-100%); }

/* Sidebar */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}
.new-chat-btn:hover { background: var(--bg-hover); }

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

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.12s;
  position: relative;
}
.conversation-item:hover { background: var(--bg-hover); color: var(--text); }
.conversation-item.active { background: var(--accent-soft); color: var(--text); }
.conversation-item .title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversation-item .delete-btn {
  opacity: 0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--text-faint);
  transition: opacity 0.12s;
}
.conversation-item:hover .delete-btn { opacity: 1; }
.conversation-item .delete-btn:hover { background: var(--bg-elev-2); color: var(--danger); }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
}
.settings-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 13.5px;
  transition: background 0.12s;
}
.settings-btn:hover { background: var(--bg-hover); color: var(--text); }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  z-index: 5;
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}
.model-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

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

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px;
  color: var(--text-dim);
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 16px;
  scroll-behavior: smooth;
}

.empty-state {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  padding: 80px 24px 0;
}
.empty-logo {
  font-size: 56px;
  color: var(--accent);
  margin-bottom: 16px;
}
.empty-state h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.empty-state > p {
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 36px;
}
.suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 24px;
}
.suggestion {
  text-align: left;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13.5px;
  transition: all 0.15s;
}
.suggestion:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.message {
  max-width: 768px;
  margin: 0 auto 24px;
  padding: 0 24px;
  display: flex;
  gap: 14px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.avatar {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 13px;
  margin-top: 2px;
}
.avatar.user { background: var(--accent); color: #fff; }
.avatar.assistant { background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text); }

.message-body { flex: 1; min-width: 0; }
.message-role {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.message-content {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  word-wrap: break-word;
}
.message-content p { margin-bottom: 12px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content strong { font-weight: 600; }
.message-content em { font-style: italic; color: var(--text-dim); }
.message-content a { color: var(--accent); text-decoration: none; }
.message-content a:hover { text-decoration: underline; }

.message-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
}
.message-content pre code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  background: transparent;
  padding: 0;
  font-size: inherit;
}
.message-content code {
  font-family: "JetBrains Mono", monospace;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.88em;
}
.message-content pre code { background: transparent; border: none; padding: 0; }

.message-content ul, .message-content ol { margin: 8px 0 12px; padding-left: 24px; }
.message-content li { margin-bottom: 4px; }
.message-content blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 14px;
  color: var(--text-dim);
  margin: 8px 0;
}
.message-content h1, .message-content h2, .message-content h3 {
  font-weight: 600;
  margin: 18px 0 8px;
  letter-spacing: -0.01em;
}
.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.1em; }
.message-content table { border-collapse: collapse; margin: 12px 0; }
.message-content th, .message-content td { border: 1px solid var(--border); padding: 6px 12px; }
.message-content th { background: var(--bg-elev); }

.copy-code-btn {
  position: absolute;
  top: 8px; right: 8px;
  padding: 4px 10px;
  font-size: 11px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.12s;
}
.message-content pre:hover .copy-code-btn { opacity: 1; }
.copy-code-btn:hover { color: var(--text); background: var(--bg-hover); }

.tool-use {
  background: var(--accent-soft);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: var(--text);
}
.tool-use .tool-name {
  color: var(--accent-hover);
  font-weight: 600;
  margin-bottom: 4px;
}
.tool-use pre { margin: 4px 0 0; }

.typing-cursor {
  display: inline-block;
  width: 8px; height: 16px;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.9s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}
.message:hover .message-actions { opacity: 1; }
.message-action {
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-faint);
  border-radius: 5px;
  transition: background 0.12s, color 0.12s;
}
.message-action:hover { background: var(--bg-hover); color: var(--text); }

/* Composer */
.composer-wrap {
  padding: 12px 24px 18px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.composer {
  max-width: 768px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 10px 10px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  max-height: 220px;
  min-height: 24px;
  padding: 4px 0;
}
#input::placeholder { color: var(--text-faint); }

.send-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:active:not(:disabled) { transform: scale(0.95); }
.send-btn:disabled { background: var(--bg-elev-2); color: var(--text-faint); cursor: not-allowed; }
.send-btn.stop { background: var(--danger); }
.send-btn.stop:hover { background: #dc2626; }

.composer-hint {
  max-width: 768px;
  margin: 8px auto 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: min(520px, 92vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: pop 0.15s ease;
}
.modal-card.wide { width: min(680px, 94vw); }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field textarea,
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  font-family: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field small {
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.4;
}
.field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.field.checkbox > span { color: var(--text); font-weight: 400; }
.field.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.btn-primary, .btn-secondary {
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: var(--bg-hover); }

/* Tool editor */
.tool-editor {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}
.tool-editor .row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
}
.tool-editor input, .tool-editor textarea {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
  font-family: inherit;
}
.tool-editor textarea {
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  min-height: 80px;
  resize: vertical;
}
.tool-editor .remove-tool {
  background: transparent;
  color: var(--text-faint);
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 12px;
  transition: color 0.12s, background 0.12s;
}
.tool-editor .remove-tool:hover { color: var(--danger); background: var(--bg-elev-2); }

#addToolBtn {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 13.5px;
  background: transparent;
  transition: all 0.12s;
}
#addToolBtn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--accent); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  z-index: 100;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* Responsive */
@media (max-width: 768px) {
  .app { grid-template-columns: 0 1fr; }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 280px;
    z-index: 30;
    transform: translateX(-100%);
  }
  .app.mobile-open .sidebar { transform: translateX(0); }
  .app.mobile-open::after {
    content: "";
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 25;
  }
  .suggestions { grid-template-columns: 1fr; }
  .empty-state { padding-top: 40px; }
  .empty-state h1 { font-size: 26px; }
  .message { padding: 0 16px; }
  .composer-wrap { padding: 10px 12px 14px; }
}
