/* ── 1. RESET & ROOT VARIABLES ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:#0c0e0f;
  --surface:#141618;
  --surface2:#1a1c1e;
  --border:#222527;
  --border-focus:#3a3d40;
  --accent:#d4a853;
  --accent2:#8b6b35;
  --accent-dim:rgba(212,168,83,.1);
  --text:#e8e2d9;
  --muted:#6b6560;
  --err:#e07070;
  --ok:#4caf82;
  --radius:10px;
  --sidebar-w:255px;
  --font-size: 14px;
}

/* ── 2. BASE ── */
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: var(--font-size);
  line-height: 1.7;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(212,168,83,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212,168,83,.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}
a { color: var(--accent); }

/* Font size variants */
[data-font-size="small"] { --font-size: 12px; }
[data-font-size="medium"] { --font-size: 14px; }
[data-font-size="large"] { --font-size: 16px; }

/* ── 3. ROOT LAYOUT ── */
#app-wrapper {
  display: flex;
  height: 100vh;
  width: 100%;
  position: relative;
  z-index: 1;
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* ── 4. SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform .25s ease, width .25s ease, min-width .25s ease;
  position: relative;
  z-index: 10;
  overflow: hidden;
}
.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-w)));
  width: 0;
  min-width: 0;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 300;
  color: var(--text);
  white-space: nowrap;
}
.sidebar-logo span { color: var(--accent); font-weight: 600; font-style: italic; }
.sidebar-collapse-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  transition: color .2s, background .2s;
  flex-shrink: 0;
}
.sidebar-collapse-btn:hover { color: var(--text); background: var(--accent-dim); }

.new-chat-btn {
  margin: 10px 10px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--accent-dim);
  border: 1px solid var(--accent2);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  letter-spacing: .06em;
  cursor: pointer;
  transition: background .2s, border-color .2s;
  white-space: nowrap;
}
.new-chat-btn:hover { background: rgba(212,168,83,.2); border-color: var(--accent); }

.sidebar-conversations {
  flex: 1;
  overflow-y: auto;
  padding: 6px 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-conversations::-webkit-scrollbar { width: 4px; }
.sidebar-conversations::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.conv-group-label {
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 8px 4px;
}
.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s;
  position: relative;
  animation: fadeUp .2s ease both;
}
.conv-item:hover { background: var(--surface2); }
.conv-item.active { background: var(--accent-dim); }
.conv-item-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.conv-item-info { flex: 1; min-width: 0; }
.conv-item-title {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item-meta {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity .15s, color .15s;
  flex-shrink: 0;
}
.conv-item:hover .conv-item-delete { opacity: 1; }
.conv-item-delete:hover { color: var(--err); }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-settings-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: color .2s, background .2s;
  text-align: left;
  white-space: nowrap;
}
.sidebar-settings-btn:hover { color: var(--text); background: var(--surface2); }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
}
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent2);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-name {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile overlay */
.sidebar-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 9;
  backdrop-filter: blur(2px);
}
.sidebar-mobile-overlay.active { display: block; }

/* ── 5. HEADER ── */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 200; /* above tab-nav so model dropdown renders on top */
}
.hamburger-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  transition: color .2s, background .2s;
}
.hamburger-btn:hover { color: var(--text); background: var(--accent-dim); }
.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent2);
  animation: pulse 2.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%,100% { opacity:1; box-shadow:0 0 14px var(--accent2); }
  50% { opacity:.5; box-shadow:0 0 4px var(--accent2); }
}
header h1 {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 300;
}
header h1 span { color: var(--accent); font-weight: 600; font-style: italic; }
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}


/* ── 6. MODEL SELECTOR DROPDOWN ── */
.model-selector { position: relative; }
.model-selector-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  white-space: nowrap;
}
.model-selector-btn:hover { border-color: var(--accent2); background: var(--surface2); }
.model-selector.open .model-selector-btn { border-color: var(--accent2); }
.model-selector .model-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chevron {
  font-size: 10px;
  color: var(--muted);
  transition: transform .2s;
}
.model-selector.open .chevron { transform: rotate(180deg); }
.model-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 240px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 9999; /* must be above everything including tabs and panels */
  box-shadow: 0 12px 40px rgba(0,0,0,.7);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.model-selector.open .model-dropdown { display: block; }
.model-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.model-search-icon {
  color: var(--muted);
  flex-shrink: 0;
}
.model-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  line-height: 1.4;
}
.model-search-input::placeholder { color: var(--muted); }
.model-no-results {
  padding: 14px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.model-group-label {
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px 4px;
}
.model-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s;
  font-size: 12px;
}
.model-option:hover { background: var(--surface2); }
.model-option.selected { background: var(--accent-dim); color: var(--accent); }
.model-option-name { flex: 1; }
.model-option-tag {
  font-size: 8px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
}

/* ── 7. TAB NAVIGATION ── */
.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .2s;
}
.tab-btn:hover { color: var(--text); background: var(--accent-dim); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-icon { font-size: 15px; }

/* ── 8. TAB PANELS ── */
.tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  animation: fadeUp .25s ease both;
}
.tab-panel.active { display: flex; }
@keyframes fadeUp {
  from { opacity:0; transform:translateY(8px); }
  to { opacity:1; transform:translateY(0); }
}

/* ── 9. CHAT MESSAGES & MARKDOWN ── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.chat-area::-webkit-scrollbar { width: 5px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeUp .25s ease both;
}
.msg-meta {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.message.assistant .msg-meta::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--meta-dot-color, var(--accent));
  flex-shrink: 0;
}
.msg-body {
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}
.message.user .msg-meta { text-align: right; color: var(--accent2); justify-content: flex-end; }
.message.user .msg-body { background: var(--surface2); align-self: flex-end; max-width: 80%; border-color: #2a2c2e; }
.message.assistant .msg-body { background: var(--surface); align-self: flex-start; max-width: 88%; }
.message.deepthink .msg-body { border-left: 3px solid var(--accent2); }
.message.error .msg-body { border-color: #5c2929; color: var(--err); background: #1a0f0f; }

.deepthink-label {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 6px;
}

/* Markdown */
.msg-body.md { white-space: normal; }
.msg-body.md p { margin-bottom: 8px; }
.msg-body.md p:last-child { margin-bottom: 0; }
.msg-body.md pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; margin: 10px 0; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.msg-body.md code { font-family: 'DM Mono', monospace; font-size: 13px; }
.msg-body.md :not(pre)>code { background: var(--accent-dim); padding: 1px 5px; border-radius: 3px; color: var(--accent); }
.msg-body.md ul, .msg-body.md ol { padding-left: 18px; margin: 6px 0; }
.msg-body.md li { margin-bottom: 3px; }
.msg-body.md h1,.msg-body.md h2,.msg-body.md h3,.msg-body.md h4 { font-family: 'Fraunces', serif; font-weight: 600; margin: 14px 0 6px; }
.msg-body.md blockquote { border-left: 2px solid var(--accent2); padding-left: 12px; margin: 8px 0; color: var(--muted); }
.msg-body.md table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.msg-body.md th, .msg-body.md td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; font-size: 13px; }
.msg-body.md th { background: var(--surface2); font-weight: 500; }
.msg-body.md strong { color: var(--accent); }

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border-radius: 6px 6px 0 0;
  margin: -12px -14px 10px;
}
.code-block-header button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color .2s, background .2s;
}
.code-block-header button:hover { color: var(--accent); background: var(--accent-dim); }

/* Thinking dots */
.thinking .msg-body { display: flex; gap: 6px; align-items: center; padding: 12px 18px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s ease-in-out infinite; }
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%,80%,100% { opacity:.2; transform:scale(.8); }
  40% { opacity:1; transform:scale(1); }
}

/* Thinking / searching indicator */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-self: flex-start;
  max-width: 88%;
  font-size: 12px;
  color: var(--muted);
  animation: fadeUp .2s ease both;
}
.thinking-dots { display: flex; gap: 4px; align-items: center; }
.thinking-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: .2s; }
.thinking-dots span:nth-child(3) { animation-delay: .4s; }

/* Message actions */


/* Streaming cursor */
.streaming-cursor::after {
  content: '▋';
  color: var(--accent);
  animation: blink-cursor .7s ease infinite;
}
@keyframes blink-cursor { 0%,100%{opacity:1;} 50%{opacity:0;} }

/* ── 10. INPUT TOGGLES (DeepThink, Search) ── */
.input-toggles {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.input-toggle {
  padding: 5px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.input-toggle:hover { border-color: var(--accent2); color: var(--text); }
.input-toggle.active {
  background: var(--accent-dim);
  border-color: var(--accent2);
  color: var(--accent);
}

/* ── 11. INPUT BAR ── */
.input-area {
  padding: 12px 20px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: border-color .2s;
}
.input-row:focus-within { border-color: var(--accent2); }
.input-row textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: var(--font-size);
  line-height: 1.6;
  resize: none;
  min-height: 22px;
  max-height: 160px;
  overflow-y: auto;
}
.input-row textarea::placeholder { color: var(--muted); }
.send-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  background: var(--accent);
  border: none;
  border-radius: 7px;
  color: #0c0e0f;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .1s;
  font-size: 13px;
  font-weight: bold;
}
.send-btn:hover { background: #e0b96a; }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }
.send-btn.stop { background: var(--err); }

.mic-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  border-radius: 5px;
  transition: color .2s, background .2s;
}
.mic-btn:hover { color: var(--accent); background: var(--accent-dim); }
.mic-btn.recording { color: var(--err); animation: pulse 1s ease-in-out infinite; }

.hint {
  margin-top: 5px;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
}

/* ── 12. EMPTY STATE & TIP CARDS ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px 24px;
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 14px; opacity: .5; }
.empty-state h3 { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 300; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 12px; color: var(--muted); max-width: 340px; line-height: 1.8; }

.tips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 20px;
  width: 100%;
  max-width: 560px;
}
.tip {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .2s, background .2s;
  text-align: left;
}
.tip:hover { border-color: var(--accent2); background: var(--surface2); }
.tip .t-icon { font-size: 1.2rem; margin-bottom: 6px; }
.tip h4 { font-family: 'Fraunces', serif; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.tip p { font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ── 13. IMAGE PANEL ── */
.img-controls {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.controls-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 110px;
}
.field label {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input, .field select {
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  outline: none;
  transition: border-color .2s;
}
.field input:focus, .field select:focus { border-color: var(--accent2); }
.field input::placeholder { color: var(--muted); }

.gen-btn {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--accent);
  color: #0c0e0f;
  border: none;
  padding: 9px 18px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .2s, transform .1s;
  white-space: nowrap;
  align-self: flex-end;
}
.gen-btn:hover { background: #e0b96a; }
.gen-btn:active { transform: scale(.97); }
.gen-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.style-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.style-preset {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: .06em;
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
}
.style-preset:hover { border-color: var(--accent2); color: var(--text); }
.style-preset.active { background: var(--accent-dim); border-color: var(--accent2); color: var(--accent); }

.img-gallery {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.img-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  animation: fadeUp .3s ease both;
  transition: border-color .3s;
}
.img-card:hover { border-color: var(--accent2); }
.img-card img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.img-card .caption { padding: 10px 14px; font-size: 11px; color: var(--muted); line-height: 1.5; border-top: 1px solid var(--border); }
.img-card .dl-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,.65);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity .2s;
}
.img-card:hover .dl-btn { opacity: 1; }
.loading-box {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

/* ── 14. VOICE / TTS PANEL ── */
.voice-controls {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
.voice-controls textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  min-height: 80px;
  max-height: 180px;
  transition: border-color .2s;
}
.voice-controls textarea:focus { border-color: var(--accent2); }
.voice-controls textarea::placeholder { color: var(--muted); }
.voice-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.speak-btn {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--accent);
  color: #0c0e0f;
  border: none;
  padding: 9px 18px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.speak-btn:hover { background: #e0b96a; }
.speak-btn:active { transform: scale(.97); }
.speak-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.char-count { font-size: 10px; color: var(--muted); letter-spacing: .05em; }
.char-count.warn { color: var(--accent); }
.char-count.danger { color: var(--err); }

.voice-history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.v-card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fadeUp .25s ease both;
}
.v-card .v-text { font-size: 12px; color: var(--muted); margin-bottom: 8px; line-height: 1.6; }
.v-card audio { width: 100%; height: 36px; margin-top: 6px; }
.v-card .v-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.v-tag {
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--accent2);
}

/* ── 15. SPINNER ── */
.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(212,168,83,.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 16. LOGIN OVERLAY ── */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(212,168,83,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212,168,83,.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}
.login-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 48px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.login-logo {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 300;
  margin-bottom: 10px;
}
.login-logo span { color: var(--accent); font-weight: 600; font-style: italic; }
.login-tagline {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 28px;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}
.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 28px;
  background: var(--accent);
  color: #0c0e0f;
  border: none;
  border-radius: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .2s, transform .1s;
  width: 100%;
  justify-content: center;
}
.login-btn:hover { background: #e0b96a; }
.login-btn:active { transform: scale(.98); }
.login-status {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  min-height: 20px;
}
.polling-dots::after {
  content: '';
  animation: polling-anim 1.5s steps(4, end) infinite;
}
@keyframes polling-anim {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}
.login-fallback {
  display: none;
  margin-top: 14px;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.login-fallback.visible { display: inline-block; }
.login-fallback:hover { color: var(--text); border-color: var(--accent2); }

/* ── 17. SETTINGS DRAWER ── */
.settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  backdrop-filter: blur(2px);
}
.settings-overlay.open { display: block; }
.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-width: 95vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 201;
  transform: translateX(100%);
  transition: transform .3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.4);
}
.settings-drawer.open { transform: translateX(0); }
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-title {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 300;
}
.settings-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 5px;
  display: flex;
  transition: color .2s, background .2s;
}
.settings-close:hover { color: var(--text); background: var(--surface2); }
.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.settings-section {
  margin-bottom: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.settings-section-title {
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--border);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-col {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-label {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}
.settings-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-value-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}
.settings-value-row span {
  font-size: 11px;
  color: var(--muted);
  min-width: 32px;
  text-align: right;
}
.settings-select {
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  max-width: 160px;
  outline: none;
}
.settings-select:focus { border-color: var(--accent2); }
.settings-textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  min-height: 70px;
  transition: border-color .2s;
}
.settings-textarea:focus { border-color: var(--accent2); }

.size-options, .toggle-options {
  display: flex;
  gap: 4px;
}
.size-option {
  width: 30px;
  height: 26px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all .2s;
}
.size-option:hover { border-color: var(--accent2); color: var(--text); }
.size-option.active { background: var(--accent-dim); border-color: var(--accent2); color: var(--accent); }

.toggle-switch {
  width: 38px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-switch.active { background: var(--accent2); }
.toggle-switch.active::after { transform: translateX(16px); }

.settings-btn-row { gap: 8px; flex-wrap: wrap; }
.settings-btn {
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  white-space: nowrap;
}
.settings-btn:hover { border-color: var(--accent2); background: var(--surface2); }
.settings-btn.danger { border-color: #5c2929; color: var(--err); }
.settings-btn.danger:hover { background: #1a0f0f; }

/* ── 18. VOICE RECORDING OVERLAY ── */
.voice-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12,14,15,.95);
  z-index: 500;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.voice-overlay.active { display: flex; }
.voice-visual {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 60px;
}
.voice-visual span {
  width: 5px;
  background: var(--accent);
  border-radius: 3px;
  animation: wave-bar 1s ease-in-out infinite;
}
.voice-visual span:nth-child(1) { animation-delay: 0s; }
.voice-visual span:nth-child(2) { animation-delay: .1s; }
.voice-visual span:nth-child(3) { animation-delay: .2s; }
.voice-visual span:nth-child(4) { animation-delay: .3s; }
.voice-visual span:nth-child(5) { animation-delay: .2s; }
.voice-visual span:nth-child(6) { animation-delay: .1s; }
.voice-visual span:nth-child(7) { animation-delay: .05s; }
.voice-visual span:nth-child(8) { animation-delay: .15s; }
@keyframes wave-bar {
  0%,100% { height: 10px; opacity: .4; }
  50% { height: 50px; opacity: 1; }
}
.voice-status {
  font-size: 14px;
  color: var(--text);
  max-width: 300px;
  text-align: center;
  line-height: 1.5;
}
.voice-cancel-btn {
  padding: 9px 20px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
}
.voice-cancel-btn:hover { border-color: var(--err); color: var(--err); }

/* ── 19. TOASTS ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  animation: toast-in .2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  max-width: 280px;
}
.toast.success { border-left: 3px solid var(--ok); }
.toast.error { border-left: 3px solid var(--err); color: var(--err); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 20. RESPONSIVE ── */
@media (max-width: 640px) {
  header { padding: 12px 14px; }
  header h1 { font-size: 14px; }
  .tab-btn { padding: 10px 8px; font-size: 11px; gap: 5px; }
  .tab-btn .tab-label { display: none; }
  .chat-area, .img-gallery, .voice-history { padding: 14px; }
  .input-area, .img-controls, .voice-controls { padding-left: 14px; padding-right: 14px; }
  .msg-body { max-width: 92% !important; }
  .img-gallery { grid-template-columns: 1fr; }
  .model-selector-btn { font-size: 11px; padding: 5px 8px; }
}

/* ── 21. MESSAGE ACTION BAR ── */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0 0;
  opacity: 0;
  transition: opacity .15s;
  flex-wrap: wrap;
}
.message:hover .msg-actions { opacity: 1; }

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: .04em;
  padding: 3px 9px;
  border-radius: 5px;
  transition: color .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.msg-action-btn:hover,
.msg-action-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent2);
}

.msg-menu-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 5px;
  transition: color .15s, background .15s, border-color .15s;
  flex-shrink: 0;
}
.msg-menu-btn:hover,
.msg-menu-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent2);
}

.msg-action-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 2px;
  flex-shrink: 0;
}

/* ── 22. GLOBAL MODEL PICKER (position:fixed, body-level) ── */
.rewrite-picker {
  /* Hidden by default; JS sets top/left then adds .open */
  display: none;
  position: fixed;
  z-index: 900;
  width: 250px;
  max-height: 320px;
  background: var(--surface);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  flex-direction: column;
  overflow: hidden;
}
.rewrite-picker.open { display: flex; animation: popIn .14s ease both; }

@keyframes popIn {
  from { opacity: 0; transform: scale(.97) translateY(4px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.rewrite-picker-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.rewrite-picker-search svg { color: var(--muted); flex-shrink: 0; }
.rewrite-picker-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
}
.rewrite-picker-search input::placeholder { color: var(--muted); }

.rewrite-picker-list {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  flex: 1;
}
.rewrite-picker-list .model-group-label {
  padding: 8px 12px 2px;
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.rewrite-picker-list .model-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
}
.rewrite-picker-list .model-option:hover { background: var(--surface2); }
.model-no-results {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ── 23. GLOBAL THREE-DOT DROPDOWN (position:fixed, body-level) ── */
.msg-menu-dropdown {
  display: none;
  position: fixed;
  z-index: 900;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  overflow: hidden;
}
.msg-menu-dropdown.open { display: block; animation: popIn .14s ease both; }

.msg-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background .1s;
  white-space: nowrap;
  font-family: 'DM Mono', monospace;
}
.msg-menu-item:hover { background: var(--surface2); color: var(--accent); }
.msg-menu-item:hover svg { color: var(--accent); }
.msg-menu-item svg { color: var(--muted); flex-shrink: 0; transition: color .1s; }
.msg-menu-sep { height: 1px; background: var(--border); margin: 3px 0; }

/* ── 24. SHARE MODAL ── */
.share-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.share-modal-overlay.open { display: flex; }
.share-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  max-width: 480px;
  width: 92%;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
  animation: fadeUp .2s ease both;
}
.share-modal-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 300;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.share-modal-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 4px; border-radius: 4px; display: flex; transition: color .15s;
}
.share-modal-close:hover { color: var(--text); }
.share-modal-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-size: 11px;
  line-height: 1.8;
  color: var(--muted);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 16px;
  font-family: 'DM Mono', monospace;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.share-modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: var(--accent-dim);
  border: 1px solid var(--accent2);
  border-radius: 7px;
  color: var(--accent);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.share-btn:hover { background: rgba(212,168,83,.25); border-color: var(--accent); }
.share-btn.primary { background: var(--accent); color: #0c0e0f; border-color: var(--accent); font-weight: 600; }
.share-btn.primary:hover { background: #dbb96e; }

/* ── 25. RESPONSIVE (768px) ── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 10;
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); width: var(--sidebar-w); min-width: var(--sidebar-w); }
  .sidebar.open { transform: translateX(0); }
  .controls-row { flex-wrap: wrap; }
  .rewrite-picker, .msg-menu-dropdown { max-width: calc(100vw - 16px); }
}

/* ══════════════════════════════════════════════════
   NEW FEATURES — appended
   ══════════════════════════════════════════════════ */

/* ── SIDEBAR SEARCH ── */
.sidebar-search-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 4px 10px 2px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  flex-shrink: 0;
}
.sidebar-search-wrap svg { color: var(--muted); flex-shrink: 0; }
.sidebar-search-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
}
.sidebar-search-wrap input::placeholder { color: var(--muted); }

/* ── CONV ITEM PIN ── */
.conv-item-btns {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
  flex-shrink: 0;
}
.conv-item:hover .conv-item-btns { opacity: 1; }
.conv-item-pin, .conv-item-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 3px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  font-size: 10px;
  transition: color .15s;
  flex-shrink: 0;
}
.conv-item-pin:hover { color: var(--accent); }
.conv-item-delete:hover { color: var(--err); }

/* ── CONTEXT INDICATOR ── */
/* ── STOP BUTTON ── */
.stop-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  background: var(--err);
  border: none;
  border-radius: 7px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .1s;
}
.stop-btn:hover { background: #c85555; }
.stop-btn:active { transform: scale(.94); }

/* ── ATTACH BUTTON ── */
.attach-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  border-radius: 5px;
  transition: color .2s, background .2s;
}
.attach-btn:hover { color: var(--accent); background: var(--accent-dim); }

/* ── ATTACHMENT STRIP ── */
.attachment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 8px;
}
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text);
  max-width: 180px;
}
.att-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip-img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}
.att-chip-icon { font-size: 14px; flex-shrink: 0; }
.att-chip-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 0 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s;
}
.att-chip-del:hover { color: var(--err); }

/* ── RESPONSE LENGTH BUTTONS ── */
.length-btns {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-radius: 20px;
  padding: 2px;
  flex-shrink: 0;
}
.length-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 9px;
  border-radius: 16px;
  font-size: 13px;
  font-family: 'DM Mono', monospace;
  transition: all .15s;
  line-height: 1;
}
.length-btn:hover { color: var(--text); }
.length-btn.active { background: var(--surface2); color: var(--accent); }

/* ── MESSAGE ATTACHMENT PREVIEWS ── */
.msg-att-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  align-self: flex-end;
}
.msg-att-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.msg-att-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  color: var(--muted);
}

/* ── USER MSG EDIT ── */
.msg-edit-ta {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--accent2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: var(--font-size);
  line-height: 1.6;
  resize: none;
  outline: none;
  min-height: 48px;
  max-height: 200px;
  overflow-y: auto;
}
.user-actions {
  justify-content: flex-end;
}
.edit-actions {
  justify-content: flex-end;
  gap: 6px;
}

/* ── MERMAID DIAGRAMS ── */
.mermaid-rendered {
  margin: 10px 0;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
}
.mermaid-rendered svg { max-width: 100%; height: auto; }

/* ── CODE BLOCK CANVAS BUTTON ── */
.code-block-btns {
  display: flex;
  gap: 4px;
  align-items: center;
}
.open-canvas-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color .2s, background .2s;
}
.open-canvas-btn:hover { color: var(--accent); background: var(--accent-dim); }

/* ── CANVAS / ARTIFACT PANEL ── */
.canvas-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 300;
}
.canvas-overlay.open { display: block; }

.canvas-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 95vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 301;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s ease;
  box-shadow: -8px 0 40px rgba(0,0,0,.5);
}
.canvas-panel.open { transform: translateX(0); }

.canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}
.canvas-title {
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-weight: 300;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.canvas-header-actions { display: flex; gap: 4px; }
.canvas-action-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  gap: 4px;
  transition: color .2s, background .2s;
}
.canvas-action-btn:hover { color: var(--accent); background: var(--accent-dim); }

.canvas-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.canvas-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  height: 100%;
}

.canvas-run-output {
  display: none;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  max-height: 220px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.canvas-run-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
#canvas-output-pre {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.canvas-html-preview {
  flex: 1;
  border: none;
  background: #fff;
  min-height: 160px;
}

/* ── KEYBOARD SHORTCUTS MODAL ── */
.shortcuts-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.shortcuts-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
  max-width: 420px;
  width: 92%;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
  animation: fadeUp .2s ease both;
}
.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 300;
}
.shortcuts-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shortcut-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
}
.shortcut-row span {
  flex: 1;
  color: var(--muted);
  font-size: 11px;
}
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text);
  letter-spacing: .04em;
  white-space: nowrap;
}

/* ── LIVE VOICE OVERLAY ── */
.live-voice-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 800;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.live-voice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  max-width: 380px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.7);
  animation: fadeUp .2s ease both;
}
.live-voice-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 300;
}
.live-voice-orb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all .3s;
}
.live-voice-orb.recording {
  background: rgba(224,112,112,.12);
  border-color: var(--err);
  color: var(--err);
  box-shadow: 0 0 20px rgba(224,112,112,.3);
  animation: pulse 1s ease-in-out infinite;
}
.live-voice-status {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  min-height: 20px;
}
.live-voice-controls {
  display: flex;
  gap: 10px;
  width: 100%;
}
.live-voice-talk-btn {
  flex: 1;
  padding: 12px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #0c0e0f;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, transform .1s;
  user-select: none;
  -webkit-user-select: none;
}
.live-voice-talk-btn:active { transform: scale(.97); background: #c8923a; }
.live-voice-end-btn {
  padding: 12px 18px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
}
.live-voice-end-btn:hover { border-color: var(--err); color: var(--err); }
.live-voice-transcript {
  width: 100%;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.lv-user {
  align-self: flex-end;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 11px;
  max-width: 90%;
  text-align: right;
  color: var(--text);
}
.lv-ai {
  align-self: flex-start;
  background: var(--accent-dim);
  border: 1px solid var(--accent2);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 11px;
  max-width: 90%;
  color: var(--accent);
}
.live-voice-btn-tab {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 400;
}
.live-voice-btn-tab:hover { background: var(--surface2); border-color: var(--accent2); }

/* ── SETTINGS LABEL NOTE ── */
.settings-label-note {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: .04em;
}

/* ── KATEX MATH RENDERING ── */
.katex { font-size: 1em; color: var(--text); }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; }
.katex-display > .katex { text-align: left; }

/* ── CANVAS RUN OUTPUT (fix display:none conflict) ── */
#canvas-run-output[style*="display:none"],
#canvas-run-output[style*="display: none"] {
  display: none !important;
}

/* ── RESPONSIVE: canvas full width on mobile ── */
@media (max-width: 640px) {
  .canvas-panel { width: 100vw; }
  .length-btns { display: none; }
}

/* ══════════════════════════════════════════════
   ENHANCED ANIMATIONS & INTERACTIVE EFFECTS
══════════════════════════════════════════════ */

/* ── Animated background grid drift ── */
@keyframes grid-drift {
  0%   { background-position: 0 0, 0 0; }
  50%  { background-position: 8px 8px, 8px 8px; }
  100% { background-position: 0 0, 0 0; }
}
body::before {
  animation: grid-drift 24s ease-in-out infinite;
}

/* ── Login particle canvas ── */
#login-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── Login card enhanced entrance + glow ── */
@keyframes card-rise {
  from { opacity: 0; transform: translateY(32px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.login-card {
  animation: card-rise .6s cubic-bezier(.22,1,.36,1) both;
  transition: box-shadow .4s ease;
}
.login-card:hover {
  box-shadow: 0 24px 80px rgba(0,0,0,.65), 0 0 40px rgba(212,168,83,.08);
}

/* ── Login button glow ── */
.login-btn {
  position: relative;
  overflow: hidden;
}
.login-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.18) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform .5s ease;
}
.login-btn:hover::after { transform: translateX(100%); }
.login-btn:hover {
  box-shadow: 0 0 20px rgba(212,168,83,.45);
}

/* ── Header logo dot enhanced pulse ── */
@keyframes logo-pulse {
  0%,100% { box-shadow: 0 0 6px var(--accent2), 0 0 0 0 rgba(212,168,83,.3); }
  50%      { box-shadow: 0 0 18px var(--accent),  0 0 0 8px rgba(212,168,83,.0); }
}
.logo-dot {
  animation: logo-pulse 2.8s ease-in-out infinite;
}

/* ── Glowing send button ── */
.send-btn:hover {
  background: #e0b96a;
  box-shadow: 0 0 14px rgba(212,168,83,.5);
}

/* ── Input row glow on focus ── */
.input-row:focus-within {
  border-color: var(--accent2);
  box-shadow: 0 0 0 2px rgba(212,168,83,.08);
}

/* ── Tip cards — lift + glow on hover ── */
@keyframes tip-glow {
  from { box-shadow: none; }
  to   { box-shadow: 0 4px 20px rgba(212,168,83,.12); }
}
.tip {
  transition: border-color .2s, background .2s, transform .2s, box-shadow .2s;
}
.tip:hover {
  border-color: var(--accent2);
  background: var(--surface2);
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(212,168,83,.12);
}

/* ── Empty state icon float animation ── */
@keyframes float-icon {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-10px); }
}
.empty-state .icon {
  animation: float-icon 4s ease-in-out infinite;
  display: block;
}

/* ── Tab button shimmer on hover ── */
.tab-btn {
  position: relative;
  overflow: hidden;
}
.tab-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 140%, rgba(212,168,83,.12) 0%, transparent 70%);
  opacity: 0;
  transition: opacity .3s;
}
.tab-btn:hover::before, .tab-btn.active::before { opacity: 1; }
.tab-btn.active {
  text-shadow: 0 0 12px rgba(212,168,83,.4);
}

/* ── Message slide-in ── */
@keyframes msg-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.message {
  animation: msg-in .28s cubic-bezier(.22,1,.36,1) both;
}

/* ── Message body subtle hover ── */
.message.assistant .msg-body {
  transition: border-color .2s, box-shadow .2s;
}
.message.assistant .msg-body:hover {
  border-color: #2e3135;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

/* ── Model dropdown animated open ── */
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.model-selector.open .model-dropdown {
  display: block;
  animation: dropdown-in .18s ease both;
}

/* ── Model option hover glow ── */
.model-option {
  transition: background .15s, box-shadow .15s;
  border-radius: 6px;
  margin: 1px 6px;
  padding: 8px 10px;
}
.model-option:hover {
  background: var(--surface2);
  box-shadow: inset 0 0 0 1px rgba(212,168,83,.1);
}
.model-option.selected {
  box-shadow: inset 0 0 0 1px rgba(212,168,83,.2);
}

/* ── FREE tag — glowing green badge ── */
.model-option-tag.free-tag {
  color: #4caf82;
  border-color: rgba(76,175,130,.4);
  background: rgba(76,175,130,.08);
  box-shadow: 0 0 8px rgba(76,175,130,.2);
  animation: free-pulse 3s ease-in-out infinite;
}
@keyframes free-pulse {
  0%,100% { box-shadow: 0 0 6px rgba(76,175,130,.2); }
  50%     { box-shadow: 0 0 12px rgba(76,175,130,.4); }
}

/* ── New Chat button shimmer ── */
.new-chat-btn {
  position: relative;
  overflow: hidden;
}
.new-chat-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(212,168,83,.15), transparent);
  transform: skewX(-20deg);
  transition: left .6s ease;
}
.new-chat-btn:hover::after { left: 140%; }

/* ── Sidebar conversation item animation ── */
.conv-item {
  transition: background .15s, transform .15s;
}
.conv-item:hover { transform: translateX(2px); }

/* ── Gen/Speak button glow ── */
.gen-btn:hover, .speak-btn:hover {
  box-shadow: 0 0 16px rgba(212,168,83,.4);
}

/* ── Image card hover ── */
.img-card {
  transition: border-color .25s, transform .25s, box-shadow .25s;
}
.img-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0,0,0,.4);
  border-color: var(--accent2);
}

/* ── Sidebar settings btn glow ── */
.sidebar-settings-btn:hover {
  color: var(--text);
  background: var(--surface2);
}

/* ── Toggle switch pulse when active ── */
.toggle-switch.active {
  position: relative;
}
.toggle-switch.active::after {
  box-shadow: 0 0 6px rgba(76,175,130,.5);
}

/* ── Toast entrance animation ── */
@keyframes toast-in {
  from { opacity:0; transform:translateX(20px); }
  to   { opacity:1; transform:translateX(0); }
}
.toast { animation: toast-in .25s ease both; }

/* ── Streaming cursor accent glow ── */
.streaming-cursor::after {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(212,168,83,.7);
}

/* ── Settings drawer entrance ── */
.settings-drawer {
  transition: transform .3s cubic-bezier(.22,1,.36,1);
}

/* ── Canvas panel entrance ── */
.canvas-panel {
  transition: transform .28s cubic-bezier(.22,1,.36,1);
}

/* ── Input toggle active glow ── */
.input-toggle.active {
  box-shadow: 0 0 10px rgba(212,168,83,.2);
}

/* ── Code block header copy btn ── */
.code-block-header button:hover {
  color: var(--accent);
  background: var(--accent-dim);
  box-shadow: none;
}

/* ── Inline orbit animation for logo ── */
@keyframes orbit-glow {
  0%   { filter: drop-shadow(0 0 3px rgba(212,168,83,.6)); }
  50%  { filter: drop-shadow(0 0 9px rgba(212,168,83,.9)); }
  100% { filter: drop-shadow(0 0 3px rgba(212,168,83,.6)); }
}
header h1 span {
  animation: orbit-glow 3s ease-in-out infinite;
  display: inline-block;
}

/* ── Login card animated border ── */
@keyframes border-glow {
  0%,100% { box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(212,168,83,.08); }
  50%      { box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(212,168,83,.22); }
}
.login-card {
  animation: card-rise .6s cubic-bezier(.22,1,.36,1) both, border-glow 4s ease-in-out 1s infinite;
}

/* ── Model selector button hover glow ── */
.model-selector-btn:hover {
  border-color: var(--accent2);
  background: var(--surface2);
  box-shadow: 0 0 10px rgba(212,168,83,.12);
}

/* ── Header subtle gradient separator ── */
header {
  background: linear-gradient(180deg, rgba(20,22,24,.98) 0%, rgba(20,22,24,.92) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── Sidebar logo shimmer ── */
.sidebar-logo span, .login-logo span {
  position: relative;
}

/* ── Tab active underline glow ── */
.tab-btn.active {
  border-bottom-color: var(--accent);
  box-shadow: inset 0 -2px 8px rgba(212,168,83,.15);
}

/* ── Input area glass effect ── */
.input-area {
  background: rgba(12,14,15,.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ── Voice orb enhanced pulse ── */
@keyframes orb-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(212,168,83,.2); }
  50%      { box-shadow: 0 0 0 12px rgba(212,168,83,.0); }
}
.live-voice-orb:not(.recording) {
  animation: orb-pulse 2.5s ease-in-out infinite;
}

/* ── Style preset active glow ── */
.style-preset.active {
  box-shadow: 0 0 10px rgba(212,168,83,.2);
}

/* ── Thinking dots enhanced ── */
.dot {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(212,168,83,.5);
}

/* ══════════════════════════════════════════════
   IDE — CODE TAB STYLES
══════════════════════════════════════════════ */

.ide-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* ── Explorer sidebar ── */
.ide-explorer {
  width: 220px;
  min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.ide-explorer-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ide-explorer-title {
  font-size: 9px;
  letter-spacing: .14em;
  color: var(--muted);
}
.ide-explorer-actions { display: flex; gap: 2px; }
.ide-hdr-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  gap: 3px;
  transition: color .15s, background .15s;
}
.ide-hdr-btn:hover { color: var(--accent); background: var(--accent-dim); }

.ide-project-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ide-proj-name {
  color: var(--text);
  font-size: 11px;
  outline: none;
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.ide-proj-name:focus {
  background: var(--surface2);
  border-radius: 3px;
  padding: 0 3px;
}

.ide-file-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.ide-empty-tree {
  padding: 20px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}
.ide-empty-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ide-empty-btn:hover { color: var(--accent); border-color: var(--accent2); }

.ide-file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 14px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text);
  border-radius: 4px;
  margin: 1px 4px;
  position: relative;
  transition: background .12s;
  animation: fadeUp .15s ease both;
}
.ide-file-item:hover { background: var(--surface2); }
.ide-file-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.ide-file-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.ide-file-icon { font-size: 12px; flex-shrink: 0; }
.ide-file-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ide-file-modified { color: var(--accent); font-size: 9px; flex-shrink: 0; }
.ide-file-del {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}
.ide-file-item:hover .ide-file-del { display: block; }
.ide-file-del:hover { color: var(--err); }

.ide-explorer-footer {
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  flex-shrink: 0;
}
.ide-tpl-label {
  font-size: 9px;
  letter-spacing: .12em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.ide-tpl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.ide-tpl-chip {
  padding: 5px 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  text-align: center;
}
.ide-tpl-chip:hover { color: var(--accent); border-color: var(--accent2); background: var(--accent-dim); }

/* ── Editor column ── */
.ide-editor-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.ide-topbar {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  min-height: 36px;
  overflow: hidden;
}
.ide-tabs-list {
  display: flex;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  min-width: 0;
}
.ide-tabs-list::-webkit-scrollbar { display: none; }
.ide-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
  height: 36px;
  font-size: 11px;
  color: var(--muted);
  border-right: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s, background .15s;
  position: relative;
}
.ide-tab:hover { color: var(--text); background: var(--surface2); }
.ide-tab.active {
  color: var(--text);
  background: var(--bg);
  border-bottom: 2px solid var(--accent);
}
.ide-tab-name { font-size: 11px; }
.ide-tab-dot { font-size: 8px; color: var(--accent); }
.ide-tab-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1;
  transition: color .15s, background .15s;
}
.ide-tab:hover .ide-tab-close { color: var(--text); }
.ide-tab-close:hover { background: var(--surface2); color: var(--err) !important; }

.ide-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  flex-shrink: 0;
}
.ide-tool-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.ide-tool-btn:hover { color: var(--text); border-color: var(--accent2); background: var(--accent-dim); }
.ide-ai-toggle {
  color: var(--accent);
  border-color: var(--accent2);
  background: var(--accent-dim);
}
.ide-ai-toggle:hover { background: rgba(212,168,83,.2); }

.ide-editor-body {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* ── Welcome screen ── */
.ide-welcome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  z-index: 2;
}
.ide-welcome-icon { font-size: 2rem; margin-bottom: 12px; opacity: .5; }
.ide-welcome h3 { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 300; margin-bottom: 6px; }
.ide-welcome p { font-size: 12px; color: var(--muted); margin-bottom: 20px; line-height: 1.7; }
.ide-welcome-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-width: 400px;
  margin-bottom: 16px;
}
.ide-wlc-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
  font-family: 'DM Mono', monospace;
}
.ide-wlc-card:hover {
  border-color: var(--accent2);
  background: var(--surface2);
  transform: translateY(-2px);
}
.ide-wlc-card span { font-size: 1.4rem; }
.ide-wlc-card strong { font-size: 11px; color: var(--text); }
.ide-wlc-card small { font-size: 9px; color: var(--muted); }
.ide-welcome-or { font-size: 10px; color: var(--muted); margin: 10px 0; letter-spacing: .1em; }
.ide-welcome-row { display: flex; gap: 8px; }
.ide-welcome-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ide-welcome-btn:hover { color: var(--accent); border-color: var(--accent2); }

/* ── CodeMirror theme: aistudio ── */
/* #ide-monaco wraps the CodeMirror textarea and must fill .ide-editor-body */
#ide-monaco {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
#ide-monaco .CodeMirror {
  flex: 1;
  height: 100%;
  min-height: 0;
}
.cm-s-aistudio.CodeMirror { background: var(--bg); color: #e8e2d9; font-family: 'DM Mono', monospace; font-size: 13px; line-height: 1.7; height: 100%; }
.cm-s-aistudio .CodeMirror-gutters { background: var(--surface); border-right: 1px solid var(--border); padding-right: 4px; }
.cm-s-aistudio .CodeMirror-linenumber { color: var(--muted); padding: 0 8px 0 4px; }
.cm-s-aistudio .CodeMirror-cursor { border-left: 2px solid var(--accent); }
.cm-s-aistudio .CodeMirror-selected { background: rgba(212,168,83,.13); }
.cm-s-aistudio .CodeMirror-activeline-background { background: rgba(255,255,255,.02); }
.cm-s-aistudio .CodeMirror-matchingbracket { outline: 1px solid rgba(212,168,83,.5); color: var(--accent) !important; }
.cm-s-aistudio .cm-keyword { color: #d4a853; font-weight: 500; }
.cm-s-aistudio .cm-atom { color: #c96b3e; }
.cm-s-aistudio .cm-number { color: #4caf82; }
.cm-s-aistudio .cm-def { color: #8dd3ff; }
.cm-s-aistudio .cm-variable { color: #e8e2d9; }
.cm-s-aistudio .cm-variable-2 { color: #b3c8e8; }
.cm-s-aistudio .cm-variable-3, .cm-s-aistudio .cm-type { color: #c678dd; }
.cm-s-aistudio .cm-property { color: #e8e2d9; }
.cm-s-aistudio .cm-operator { color: #d4a853; }
.cm-s-aistudio .cm-comment { color: var(--muted); font-style: italic; }
.cm-s-aistudio .cm-string { color: #98c379; }
.cm-s-aistudio .cm-string-2 { color: #98c379; }
.cm-s-aistudio .cm-meta { color: #c678dd; }
.cm-s-aistudio .cm-qualifier { color: #c678dd; }
.cm-s-aistudio .cm-builtin { color: #c96b3e; }
.cm-s-aistudio .cm-bracket { color: #e8e2d9; }
.cm-s-aistudio .cm-tag { color: #d4a853; }
.cm-s-aistudio .cm-attribute { color: #98c379; }
.cm-s-aistudio .cm-hr { color: var(--muted); }
.cm-s-aistudio .cm-link { color: #61afef; text-decoration: underline; }
.cm-s-aistudio .cm-error { color: var(--err); }
.CodeMirror { height: 100%; }
.CodeMirror-scroll { overflow-x: auto !important; overflow-y: scroll !important; }

/* ── Output panel ── */
.ide-output {
  flex-shrink: 0;
  height: 240px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.ide-output-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 8px;
}
.ide-out-tabs { display: flex; gap: 2px; }
.ide-out-tab {
  padding: 3px 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  cursor: pointer;
  transition: all .15s;
}
.ide-out-tab.active { color: var(--accent); background: var(--accent-dim); border-color: var(--accent2); }
.ide-out-tab:hover:not(.active) { color: var(--text); background: var(--surface2); }
.ide-output-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}
#ide-html-frame { border: none; width: 100%; height: 100%; background: #fff; }
#ide-output-pre {
  margin: 0;
  padding: 12px 16px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text);
  overflow-y: auto;
  height: 100%;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── AI Panel ── */
.ide-ai-panel {
  width: 320px;
  min-width: 280px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width .25s ease, min-width .25s ease;
}
.ide-ai-panel.hidden { width: 0; min-width: 0; }
.ide-ai-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ide-ai-title {
  flex: 1;
  font-size: 11px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: .04em;
}
.ide-ai-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.ide-ai-welcome-msg {
  text-align: center;
  padding: 12px 8px 6px;
}
.ide-ai-welcome-icon { font-size: 1.8rem; margin-bottom: 8px; }
.ide-ai-welcome-msg strong { display: block; font-size: 13px; margin-bottom: 4px; color: var(--text); }
.ide-ai-welcome-msg p { font-size: 11px; color: var(--muted); line-height: 1.6; }
.ide-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 4px 0;
}
.ide-ai-chip {
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
}
.ide-ai-chip:hover { color: var(--accent); border-color: var(--accent2); background: var(--accent-dim); }

/* AI chat messages */
.ide-ai-msg {
  max-width: 100%;
  animation: fadeUp .2s ease both;
}
.ide-ai-msg.user {
  align-self: flex-end;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text);
  max-width: 90%;
  text-align: right;
}
.ide-ai-msg.assistant {
  align-self: flex-start;
  background: var(--accent-dim);
  border: 1px solid rgba(212,168,83,.15);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text);
  width: 100%;
}
.ide-ai-msg.assistant.md { white-space: normal; }
.ide-ai-msg.assistant.md p { margin-bottom: 6px; font-size: 11px; line-height: 1.6; }
.ide-ai-msg.assistant.md pre { font-size: 11px; margin: 6px 0; position: relative; }
.ide-ai-msg.assistant.md code { font-size: 11px; }
.ide-ai-msg.thinking { background: none; border: none; padding: 4px 0; display: flex; gap: 4px; }
.ide-ai-msg.error { background: rgba(224,112,112,.1); border-color: rgba(224,112,112,.3); color: var(--err); }

/* Apply to editor button */
.ide-apply-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 8px;
  background: var(--surface);
  border: 1px solid var(--accent2);
  border-radius: 4px;
  color: var(--accent);
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  cursor: pointer;
  transition: background .15s;
  z-index: 10;
}
.ide-apply-btn:hover { background: var(--accent-dim); }

/* ── AI input area ── */
.ide-ai-input-row {
  border-top: 1px solid var(--border);
  padding: 8px 10px 10px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
}
.ide-ai-ctx-row {
  display: flex;
  align-items: center;
}
.ide-ctx-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.ide-ctx-label input { accent-color: var(--accent); }
.ide-ai-bottom-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
#ide-ai-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  padding: 8px 10px;
  resize: none;
  outline: none;
  line-height: 1.5;
  min-height: 36px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color .2s;
}
#ide-ai-input:focus { border-color: var(--accent2); }
#ide-ai-input::placeholder { color: var(--muted); }
.ide-ai-btns { display: flex; flex-direction: column; gap: 4px; }
.ide-ai-send-btn, .ide-ai-stop-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  transition: background .2s, transform .1s;
}
.ide-ai-send-btn { background: var(--accent); color: #0c0e0f; }
.ide-ai-send-btn:hover { background: #e0b96a; box-shadow: 0 0 12px rgba(212,168,83,.4); }
.ide-ai-send-btn:active { transform: scale(.93); }
.ide-ai-stop-btn { background: var(--err); color: #fff; }
.ide-ai-stop-btn:hover { background: #c85555; }


/* ══════════════════════════════════════════════
   IMAGE TAB — EXPANDED STYLES
══════════════════════════════════════════════ */

.img-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Left sidebar ── */
.img-ctrl-sidebar {
  width: 280px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.img-ctrl-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.img-ctrl-section { display: flex; flex-direction: column; gap: 6px; }
.img-ctrl-label {
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.img-ctrl-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Provider tabs */
.img-provider-tabs { display: flex; flex-direction: column; gap: 4px; }
.img-prov-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
}
.img-prov-btn:hover { color: var(--text); border-color: var(--accent2); background: var(--accent-dim); }
.img-prov-btn.active { color: var(--text); border-color: var(--accent2); background: var(--accent-dim); box-shadow: inset 0 0 0 1px rgba(212,168,83,.15); }
.img-prov-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Model select */
.img-select {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  outline: none;
  cursor: pointer;
  transition: border-color .2s;
}
.img-select:focus { border-color: var(--accent2); }
.img-model-info {
  font-size: 9px;
  color: var(--muted);
  line-height: 1.5;
  min-height: 12px;
}

/* Prompt area */
.img-prompt-ta {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  padding: 9px 10px;
  resize: vertical;
  outline: none;
  min-height: 80px;
  line-height: 1.5;
  transition: border-color .2s;
}
.img-prompt-ta:focus { border-color: var(--accent2); }
.img-prompt-ta::placeholder { color: var(--muted); }
.img-neg-ta { min-height: 50px; }
.img-enhance-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all .15s;
}
.img-enhance-btn:hover { color: var(--accent); border-color: var(--accent2); background: var(--accent-dim); }

/* Aspect ratio grid */
.img-ar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}
.img-ar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  cursor: pointer;
  transition: all .15s;
}
.img-ar-btn:hover { color: var(--text); border-color: var(--accent2); }
.img-ar-btn.active { color: var(--accent); border-color: var(--accent2); background: var(--accent-dim); }
.ar-preview {
  background: var(--border);
  border-radius: 2px;
  flex-shrink: 0;
}
.ar-1-1  { width: 20px; height: 20px; }
.ar-16-9 { width: 24px; height: 13px; }
.ar-9-16 { width: 13px; height: 22px; }
.ar-4-3  { width: 20px; height: 15px; }
.ar-3-4  { width: 15px; height: 20px; }
.ar-3-2  { width: 21px; height: 14px; }

/* Range sliders */
.img-range {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}
.img-slider-val {
  color: var(--accent);
  font-size: 10px;
  margin-left: 4px;
}

/* Count buttons */
.img-count-row { display: flex; gap: 6px; }
.img-count-btn {
  padding: 5px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
}
.img-count-btn:hover { color: var(--text); border-color: var(--accent2); }
.img-count-btn.active { color: var(--accent); border-color: var(--accent2); background: var(--accent-dim); }

/* Small input */
.img-input-sm {
  width: 100%;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  outline: none;
  transition: border-color .2s;
}
.img-input-sm:focus { border-color: var(--accent2); }
.img-input-sm::placeholder { color: var(--muted); }
.img-optional { font-size: 8px; color: var(--muted); }

/* ── Gallery area ── */
.img-gallery-area {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.img-gallery {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .ide-ai-panel { display: none; }
  .ide-ai-panel.open { display: flex; position: fixed; right: 0; top: 0; height: 100vh; z-index: 500; box-shadow: -8px 0 32px rgba(0,0,0,.5); }
  .img-ctrl-sidebar { width: 240px; min-width: 200px; }
}
@media (max-width: 680px) {
  .ide-explorer { display: none; }
  .img-layout { flex-direction: column; }
  .img-ctrl-sidebar { width: 100%; max-height: 50vh; }
}

/* ── Image card overlay buttons ── */
.img-card { position: relative; overflow: hidden; }
.img-card-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .2s;
  z-index: 5;
}
.img-card:hover .img-card-overlay { opacity: 1; }
.img-card-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  backdrop-filter: blur(4px);
}
.img-card-btn:hover { background: rgba(212,168,83,.8); color: #0c0e0f; }


/* ══════════════════════════════════════════════
   AUTH ADDITIONS — social row, email form, banner
══════════════════════════════════════════════ */

/* Divider between Puter btn and social options */
.login-divider-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.login-divider-line::before,
.login-divider-line::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Three compact social buttons in a row */
.login-social-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.login-social-sm {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.login-social-sm:hover {
  border-color: var(--accent2);
  background: var(--surface);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

/* Email form (revealed on click) */
.login-email-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
  animation: fadeUp .2s ease both;
}
.login-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  outline: none;
  transition: border-color .2s;
}
.login-input:focus { border-color: var(--accent2); }
.login-input::placeholder { color: var(--muted); }
.login-form-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.login-text-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  cursor: pointer;
  padding: 0;
  transition: color .15s;
}
.login-text-btn:hover { color: var(--accent); }

/* Shake animation for wrong password */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}
.login-card.shake { animation: shake .45s ease both; }

/* ── Puter connect banner ──────────────────────────────────────────────── */
.puter-banner {
  background: linear-gradient(90deg, rgba(212,168,83,.1), rgba(212,168,83,.05));
  border-bottom: 1px solid rgba(212,168,83,.2);
  padding: 8px 16px;
  flex-shrink: 0;
}
.puter-banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
}
.puter-banner-icon { font-size: 16px; flex-shrink: 0; }
.puter-banner-text { flex: 1; font-size: 12px; color: var(--text); }
.puter-banner-text strong { color: var(--accent); }
.puter-banner-btn {
  padding: 6px 14px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #0c0e0f;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s;
  flex-shrink: 0;
}
.puter-banner-btn:hover { background: #e0b96a; }
.puter-banner-dismiss {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color .15s;
}
.puter-banner-dismiss:hover { color: var(--text); }

/* ── Sign-out button ─────────────────────────────────────────────────────── */
#sign-out-btn { color: var(--err) !important; }
#sign-out-btn:hover { background: rgba(224,112,112,.1) !important; }

/* ── Sidebar user avatar (supports OAuth profile pictures) ───────────────── */
#user-avatar {
  background-color: var(--accent2);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}


/* ══════════════════════════════════════════════
   IDE THEMED MODAL (replaces native confirm/prompt)
══════════════════════════════════════════════ */

.ide-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeUp .15s ease both;
}

.ide-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  min-width: 300px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .7);
}

.ide-modal-title {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 300;
  color: var(--text);
  margin-bottom: 10px;
}

.ide-modal-msg {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 16px;
}

.ide-modal-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  outline: none;
  margin-bottom: 16px;
  transition: border-color .2s;
}
.ide-modal-input:focus { border-color: var(--accent2); }
.ide-modal-input::placeholder { color: var(--muted); }

.ide-modal-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.ide-modal-btn {
  padding: 8px 18px;
  border-radius: 7px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  border: none;
  transition: all .15s;
}
.ide-modal-btn.cancel {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.ide-modal-btn.cancel:hover { color: var(--text); border-color: var(--accent2); }
.ide-modal-btn.confirm {
  background: var(--accent);
  color: #0c0e0f;
  font-weight: 500;
}
.ide-modal-btn.confirm:hover { background: #e0b96a; }

/* ── IDE thinking dots ─────────────────────────────────────────────────── */
.ide-thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 4px 0;
}

/* ══════════════════════════════════════════════
   SETTINGS PAGE  (sp-* prefix)
   Full-screen overlay like claude.ai/settings
══════════════════════════════════════════════ */

/* ── Overlay backdrop ────────────────────────────────────────────────────── */
.sp-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 800;
  backdrop-filter: blur(3px);
}
.sp-overlay.open { display: block; }

/* ── Full page panel ─────────────────────────────────────────────────────── */
.sp-page {
  position: fixed;
  inset: 0;
  z-index: 801;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.22,1,.36,1);
}
.sp-page.open { transform: translateY(0); }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.sp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.sp-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sp-logo-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent2);
  animation: pulse 2.4s ease-in-out infinite;
}
.sp-logo-name {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 300;
  color: var(--text);
}
.sp-logo-name span { color: var(--accent); font-weight: 600; font-style: italic; }
.sp-close-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all .2s;
}
.sp-close-btn:hover { color: var(--text); border-color: var(--accent2); background: var(--accent-dim); }

/* ── Body layout ─────────────────────────────────────────────────────────── */
.sp-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Left nav ────────────────────────────────────────────────────────────── */
.sp-nav {
  width: 220px;
  min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}
.sp-nav-section-label {
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 10px 6px;
}
.sp-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all .15s;
  width: 100%;
}
.sp-nav-item:hover { color: var(--text); background: var(--surface2); }
.sp-nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(212,168,83,.15);
}
.sp-nav-item svg { flex-shrink: 0; opacity: .7; }
.sp-nav-item.active svg { opacity: 1; }

/* ── Content area ────────────────────────────────────────────────────────── */
.sp-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 48px;
  max-width: 760px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Sections ────────────────────────────────────────────────────────────── */
.sp-section { display: none; animation: fadeUp .2s ease both; }
.sp-section.active { display: block; }

.sp-section-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.sp-section-header h2 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 300;
  color: var(--text);
  margin-bottom: 6px;
}
.sp-section-header p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.sp-card-header-label {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 24px 0 8px;
}
.sp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
}
.sp-card-flush { padding: 0; }
.sp-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.sp-card-row:hover { background: rgba(255,255,255,.01); }
.sp-no-border { border-bottom: none !important; }
.sp-card-row:last-child { border-bottom: none; }

.sp-card-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.sp-card-label > span {
  font-size: 13px;
  color: var(--text);
  font-weight: 400;
}
.sp-card-label > small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Font size picker ────────────────────────────────────────────────────── */
.sp-font-picker {
  display: flex;
  gap: 8px;
}
.sp-font-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
  min-width: 64px;
  font-family: 'DM Mono', monospace;
}
.sp-font-btn > span:last-child { font-size: 10px; letter-spacing: .06em; }
.sp-font-btn:hover { border-color: var(--accent2); color: var(--text); }
.sp-font-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* ── Theme swatch ────────────────────────────────────────────────────────── */
.sp-theme-preview { display: flex; gap: 8px; }
.sp-theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .2s;
  font-size: 10px;
  color: var(--muted);
}
.sp-theme-swatch.active { border-color: var(--accent); color: var(--accent); }
.sp-theme-dot { width: 28px; height: 28px; border-radius: 50%; }

/* ── Select ──────────────────────────────────────────────────────────────── */
.sp-select {
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  min-width: 200px;
  max-width: 260px;
  outline: none;
  cursor: pointer;
  transition: border-color .2s;
}
.sp-select:focus { border-color: var(--accent2); }

/* ── Slider ──────────────────────────────────────────────────────────────── */
.sp-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sp-slider-label {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.sp-range {
  width: 140px;
  accent-color: var(--accent);
  cursor: pointer;
}
.sp-range-val {
  font-size: 12px;
  color: var(--accent);
  min-width: 30px;
  text-align: right;
  font-weight: 500;
}

/* ── Response length grid ────────────────────────────────────────────────── */
.sp-response-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
}
.sp-resp-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 12px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  transition: background .15s;
  text-align: center;
  font-family: 'DM Mono', monospace;
}
.sp-resp-card:hover { background: var(--surface2); }
.sp-resp-card.active { background: var(--accent-dim); }
.sp-resp-card.active .sp-resp-icon { color: var(--accent); }
.sp-resp-card.active strong { color: var(--accent); }
.sp-resp-icon {
  font-size: 20px;
  color: var(--muted);
  transition: color .15s;
  line-height: 1;
}
.sp-resp-card strong { font-size: 11px; color: var(--text); display: block; }
.sp-resp-card small  { font-size: 10px; color: var(--muted); line-height: 1.5; }

/* ── Toggle ──────────────────────────────────────────────────────────────── */
.sp-toggle {
  width: 42px;
  height: 24px;
  background: var(--border);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.sp-toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.sp-toggle.active { background: var(--accent2); }
.sp-toggle.active::after { transform: translateX(18px); }

/* ── Textarea ────────────────────────────────────────────────────────────── */
.sp-textarea-wrap { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.sp-textarea-label { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.sp-textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  min-height: 80px;
  transition: border-color .2s;
}
.sp-textarea:focus { border-color: var(--accent2); }
.sp-textarea::placeholder { color: var(--muted); }
.sp-textarea-hint { font-size: 10px; color: var(--muted); line-height: 1.6; }

/* ── Stats grid ──────────────────────────────────────────────────────────── */
.sp-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.sp-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  transition: border-color .2s, background .2s;
}
.sp-stat-card:hover { border-color: var(--accent2); background: var(--surface2); }
.sp-stat-value {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 300;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}
.sp-stat-label { font-size: 10px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }

/* ── Action buttons ──────────────────────────────────────────────────────── */
.sp-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.sp-action-btn:hover { border-color: var(--accent2); background: var(--accent-dim); }
.sp-danger-btn { color: var(--err) !important; }
.sp-danger-btn:hover { border-color: var(--err) !important; background: rgba(224,112,112,.1) !important; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.sp-badge {
  padding: 3px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .06em;
  white-space: nowrap;
  flex-shrink: 0;
}
.sp-badge-green { border-color: rgba(76,175,130,.4); color: var(--ok); background: rgba(76,175,130,.08); }
.sp-badge-yellow { border-color: rgba(212,168,83,.4); color: var(--accent); background: rgba(212,168,83,.08); }

.sp-link-badge {
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 10px;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.sp-link-badge:hover { border-color: var(--accent2); background: var(--accent-dim); }

/* ── Shortcuts ───────────────────────────────────────────────────────────── */
.sp-shortcut-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.sp-shortcut-group-label {
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 20px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.sp-sc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  transition: background .15s;
}
.sp-sc-row:hover { background: rgba(255,255,255,.02); }
.sp-sc-row:last-child { border-bottom: none; }
.sp-sc-row span { color: var(--muted); font-size: 12px; }
.sp-sc-keys { display: flex; gap: 4px; align-items: center; }
.sp-sc-keys kbd, .shortcuts-grid kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 7px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border-focus);
  border-radius: 5px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text);
  min-width: 24px;
  white-space: nowrap;
}

/* ── Account ─────────────────────────────────────────────────────────────── */
.sp-account-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.sp-account-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent2);
  background-size: cover;
  background-position: center;
  color: #0c0e0f;
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(212,168,83,.2);
}
.sp-account-info { display: flex; flex-direction: column; gap: 3px; }
.sp-account-name { font-size: 15px; color: var(--text); font-weight: 500; }
.sp-account-email { font-size: 11px; color: var(--muted); }

/* ── Info card ───────────────────────────────────────────────────────────── */
.sp-info-card {
  display: flex;
  gap: 14px;
  background: var(--accent-dim);
  border: 1px solid rgba(212,168,83,.2);
  border-radius: 12px;
  padding: 16px 20px;
  margin-top: 16px;
}
.sp-info-icon { font-size: 1.4rem; flex-shrink: 0; line-height: 1; }
.sp-info-card strong { display: block; font-size: 12px; color: var(--text); margin-bottom: 4px; }
.sp-info-card p { font-size: 11px; color: var(--muted); line-height: 1.7; margin: 0; }
.sp-link-btn {
  background: none; border: none; color: var(--accent);
  font-family: 'DM Mono', monospace; font-size: 11px;
  cursor: pointer; padding: 0; text-decoration: underline;
}

/* ── About brand ─────────────────────────────────────────────────────────── */
.sp-about-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.sp-about-logo {
  font-family: 'Fraunces', serif;
  font-size: 24px;
  font-weight: 300;
  color: var(--text);
  margin-bottom: 4px;
}
.sp-about-logo span { color: var(--accent); font-weight: 600; font-style: italic; }
.sp-about-version { font-size: 10px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .sp-body { flex-direction: column; }
  .sp-nav {
    width: 100%;
    min-width: 0;
    flex-direction: row;
    overflow-x: auto;
    padding: 10px 8px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    gap: 4px;
  }
  .sp-nav-section-label { display: none; }
  .sp-nav-item { white-space: nowrap; padding: 7px 10px; font-size: 11px; }
  .sp-content { padding: 20px 16px 40px; }
  .sp-response-grid { grid-template-columns: 1fr; }
  .sp-stat-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .sp-font-picker { flex-wrap: wrap; }
}
