/* ── 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; }
}
/* ════════════════════════════════════════════════════════════════════════
   THEME ADDITIONS — append to the bottom of style.css
   Safe to remove: deleting these rules reverts to original appearance.
   ════════════════════════════════════════════════════════════════════════ */


/* ── 1. NEW CSS CUSTOM PROPERTIES ──────────────────────────────────────── */
:root {
  --font-ui:   'DM Mono', monospace;
  --font-head: 'Fraunces', serif;
}

/* ── 2. FONT VARIABLE APPLICATION ──────────────────────────────────────── */
html, body, button, input, textarea, select,
.msg-body, .hint, .conv-item-title, .conv-item-meta,
.model-option, .tab-btn, .sidebar-settings-btn, .ide-tool-btn,
.ide-ai-chip, .ide-tab, .sp-nav-item, .sp-card-label > span,
.sp-card-label > small, .sp-textarea, .sp-action-btn,
.img-ctrl-label, .img-prov-btn, .input-toggle, .msg-action-btn,
.new-chat-btn, .gen-btn, .speak-btn, .send-btn, .login-btn,
#ide-ai-input, .ide-ai-msg, .lv-user, .lv-ai, .v-tag,
.voice-controls textarea, .img-prompt-ta {
  font-family: var(--font-ui) !important;
}
.CodeMirror, .cm-s-aistudio.CodeMirror { font-family: var(--font-ui) !important; }

header h1, header h1 span, .sidebar-logo, .sidebar-logo span,
.login-logo, .login-logo span, .sp-section-header h2,
.sp-about-logo, .sp-logo-name, .canvas-title,
.live-voice-title, .share-modal-title, .shortcuts-header > span,
.ide-welcome h3, .empty-state h3, .tip h4, .ide-modal-title,
.sp-account-name, .sp-stat-value, h1, h2, h3, h4 {
  font-family: var(--font-head) !important;
}


/* ── 3. DENSITY SYSTEM ─────────────────────────────────────────────────── */
[data-density="compact"] .chat-area            { padding: 14px; gap: 12px; }
[data-density="compact"] .msg-body             { padding: 10px 14px; }
[data-density="compact"] .input-area           { padding: 8px 14px 12px; }
[data-density="compact"] .tab-btn              { padding: 8px 12px; }
[data-density="compact"] .sp-card-row          { padding: 10px 16px; }
[data-density="compact"] .conv-item            { padding: 5px 8px; }
[data-density="compact"] header                { padding: 10px 16px; }
[data-density="compact"] .ide-file-item        { padding: 4px 8px 4px 12px; }

[data-density="spacious"] .chat-area           { padding: 32px 36px; gap: 26px; }
[data-density="spacious"] .msg-body            { padding: 18px 24px; }
[data-density="spacious"] .input-area          { padding: 16px 28px 24px; }
[data-density="spacious"] .tab-btn             { padding: 16px 22px; }
[data-density="spacious"] .sp-card-row         { padding: 20px 24px; }
[data-density="spacious"] .conv-item           { padding: 10px 14px; }
[data-density="spacious"] header               { padding: 18px 28px; }


/* ── 4. BACKGROUND TEXTURES ────────────────────────────────────────────── */
[data-bg-texture="dots"] body::before {
  background-image: radial-gradient(var(--accent) 1px, transparent 1px);
  background-size: 24px 24px; opacity: 0.04;
}
[data-bg-texture="cross"] body::before {
  background-image:
    linear-gradient(var(--accent) 1px, transparent 1px),
    linear-gradient(90deg, var(--accent) 1px, transparent 1px),
    linear-gradient(45deg, var(--accent) 0.5px, transparent 0.5px),
    linear-gradient(-45deg, var(--accent) 0.5px, transparent 0.5px);
  background-size: 32px 32px, 32px 32px, 16px 16px, 16px 16px;
  opacity: 0.035;
}
[data-bg-texture="none"] body::before { display: none; }


/* ── 5. CHAT BUBBLE STYLES ─────────────────────────────────────────────── */
[data-bubble="minimal"] .message.user .msg-body      { background: transparent; }
[data-bubble="minimal"] .message.assistant .msg-body {
  background: transparent; border: none;
  border-left: 2px solid var(--accent2);
  border-radius: 0; padding-left: 16px;
}
[data-bubble="bordered"] .message.assistant .msg-body { border-color: var(--border-focus); border-left: 3px solid var(--accent2); }
[data-bubble="bordered"] .message.user .msg-body      { border-color: var(--accent2); }


/* ── 6. LIGHT THEME OVERRIDES ──────────────────────────────────────────── */
[data-light-theme] body::before {
  background-image:
    linear-gradient(rgba(0,0,0,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px);
  background-size: 40px 40px;
}
[data-light-theme] header          { background: rgba(250,248,245,.98); }
[data-light-theme] .input-area     { background: rgba(245,242,238,.85); }
[data-light-theme] .msg-body       { color: var(--text); }
[data-light-theme] .message.user .msg-body      { background: var(--surface2); }
[data-light-theme] .message.assistant .msg-body { background: var(--surface); }
[data-light-theme] .msg-body.md pre             { background: var(--surface2); border-color: var(--border); }
[data-light-theme] .msg-body.md :not(pre) > code { background: var(--surface2); color: var(--accent2); }
[data-light-theme] .sp-page, [data-light-theme] .sp-nav { background: var(--surface); }
[data-light-theme] .sp-topbar { background: var(--surface2); }
[data-light-theme] .cm-s-aistudio.CodeMirror { background: #f8f6f2; color: #2a2520; }
[data-light-theme] .cm-s-aistudio .CodeMirror-gutters  { background: #f0ece6; }
[data-light-theme] .cm-s-aistudio .cm-string  { color: #2d6a27; }
[data-light-theme] .cm-s-aistudio .cm-number  { color: #1a5c9c; }
[data-light-theme] .cm-s-aistudio .cm-keyword { color: var(--accent2); }


/* ── 7. THEME PICKER — SEARCH ROW ─────────────────────────────────────── */
.nd-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  position: sticky;
  top: 0;
  z-index: 2;
}
.nd-search-row svg { color: var(--muted); flex-shrink: 0; }
.nd-search-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12px;
}
.nd-search-row input::placeholder { color: var(--muted); }
.nd-search-count {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .06em;
  white-space: nowrap;
  flex-shrink: 0;
}


/* ── 8. THEME GROUPS ───────────────────────────────────────────────────── */
.nd-group { border-bottom: 1px solid var(--border); }
.nd-group:last-child { border-bottom: none; }

.nd-group-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background .15s;
}
.nd-group-hdr:hover { background: var(--surface2); }

.nd-group-emoji { font-size: 14px; flex-shrink: 0; }
.nd-group-name  {
  flex: 1;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text);
  font-family: var(--font-ui);
}
.nd-group-count {
  font-size: 10px;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  flex-shrink: 0;
}
.nd-group-chevron {
  color: var(--muted);
  transition: transform .2s;
  flex-shrink: 0;
}
.nd-group-collapsed .nd-group-chevron { transform: rotate(-90deg); }
.nd-group-collapsed .nd-theme-grid    { display: none; }


/* ── 9. THEME SWATCHES GRID ────────────────────────────────────────────── */
.nd-theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 1px;
  background: var(--border);
  padding: 1px;
}

.nd-theme-swatch {
  position: relative;
  display: block;
  width: 100%;
  background: var(--surface);
  border: none;
  cursor: pointer;
  transition: background .15s, transform .15s;
  outline: none;
  overflow: hidden;
  text-align: left;
  padding: 0;
}
.nd-theme-swatch:hover { background: var(--surface2); transform: scale(1.03); z-index: 1; }
.nd-theme-swatch.active {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 2;
}
.nd-theme-swatch.active::after {
  content: '✓';
  position: absolute;
  top: 4px; right: 4px;
  width: 14px; height: 14px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 50%;
  font-size: 8px;
  line-height: 14px;
  text-align: center;
  font-weight: 700;
}

/* Colour strip preview — single inline-gradient div, block layout avoids button/flex height bugs */
.nd-ts-preview {
  display: block;
  height: 40px;
  min-height: 40px;
  width: 100%;
  border-bottom: 1px solid rgba(0,0,0,.25);
}

/* Theme label */
.nd-ts-name {
  padding: 5px 6px 6px;
  font-size: 9px;
  letter-spacing: .04em;
  color: var(--muted);
  font-family: var(--font-ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  line-height: 1.3;
}
.nd-theme-swatch.active .nd-ts-name { color: var(--accent); }


/* ── 10. FONT GRID ──────────────────────────────────────────────────────── */
.nd-font-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
}
@media (max-width: 680px) { .nd-font-grid { grid-template-columns: repeat(2, 1fr); } }

.nd-font-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 14px 16px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
  position: relative;
  overflow: hidden;
}
.nd-font-card:hover { background: var(--surface2); }
.nd-font-card.active { background: var(--accent-dim); }
.nd-font-card.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--accent);
}
.nd-fc-sample {
  font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.nd-fc-label {
  font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-family: var(--font-ui);
}


/* ── 11. OPTION ROWS (density / radius / texture / bubble) ─────────────── */
.nd-option-row {
  display: flex;
  background: var(--border);
  gap: 1px;
}

.nd-option-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  transition: background .15s;
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .05em;
}
.nd-option-btn:hover { background: var(--surface2); }
.nd-option-btn.active { background: var(--accent-dim); color: var(--accent); }

/* Density previews */
.nd-density-preview {
  display: flex; flex-direction: column;
  width: 44px; gap: 0;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 3px; overflow: hidden;
}
.nd-density-preview span {
  display: block; background: var(--border-focus); border-bottom: 1px solid var(--border);
}
.nd-density-preview span:last-child { border-bottom: none; }
.nd-preview-compact      span { height: 5px; }
.nd-preview-comfortable  span { height: 8px; }
.nd-preview-spacious     span { height: 12px; }

/* Radius preview */
.nd-radius-preview {
  width: 36px; height: 24px;
  background: var(--border-focus); border: 1px solid var(--accent2);
}

/* Texture previews */
.nd-texture-preview {
  width: 46px; height: 34px; border-radius: 3px;
  border: 1px solid var(--border); background: var(--bg);
}
.nd-tex-grid {
  background-image:
    linear-gradient(var(--border-focus) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-focus) 1px, transparent 1px);
  background-size: 8px 8px;
}
.nd-tex-dots {
  background-image: radial-gradient(var(--border-focus) 1px, transparent 1px);
  background-size: 6px 6px;
}
.nd-tex-cross {
  background-image:
    linear-gradient(var(--border-focus) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-focus) 1px, transparent 1px);
  background-size: 10px 10px; opacity: .8;
}
.nd-tex-none { background: var(--bg); }

/* Bubble style previews */
.nd-bubble-preview {
  width: 64px; height: 38px; display: flex; flex-direction: column;
  gap: 3px; justify-content: center; padding: 3px;
}
.nd-bub-msg {
  font-size: 7px; padding: 2px 5px; border-radius: 3px;
  width: fit-content; font-family: var(--font-ui); color: var(--text);
}
.nd-bub-user { align-self: flex-end; background: var(--surface2); border: 1px solid var(--border); }
.nd-bub-ai   { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.nd-bub-minimal .nd-bub-user  { background: transparent; }
.nd-bub-minimal .nd-bub-ai    { background: transparent; border: none; border-left: 2px solid var(--accent2); border-radius: 0; padding-left: 3px; }
.nd-bub-bordered .nd-bub-ai   { border-color: var(--accent2); border-left: 2px solid var(--accent); }


/* ── 12. RESPONSIVE ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nd-theme-grid   { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .nd-option-row   { flex-wrap: wrap; }
  .nd-option-btn   { min-width: 80px; flex: 1 1 80px; }
  .nd-font-grid    { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   IDE v3 ADDITIONS  —  append to the bottom of style.css
   ═══════════════════════════════════════════════════════════════ */

/* ── Status bar ───────────────────────────────────────────────── */
.ide-statusbar {
  display: flex;
  align-items: center;
  gap: 0;
  height: 22px;
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0 8px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .03em;
  overflow: hidden;
  user-select: none;
}
.ide-sb-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  height: 100%;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.ide-sb-item.ide-sb-lang-btn,
.ide-sb-item.ide-sb-file {
  cursor: pointer;
}
.ide-sb-item.ide-sb-lang-btn:hover,
.ide-sb-item.ide-sb-file:hover {
  background: var(--surface2);
  color: var(--text);
}
.ide-sb-sep {
  color: var(--border-focus);
  padding: 0 2px;
}
.ide-sb-dot {
  font-size: 8px;
}
.ide-sb-saved   { color: var(--ok); }
.ide-sb-unsaved { color: var(--accent); }
.ide-sb-lang    { color: var(--accent2); font-weight: 500; }

/* ── Word wrap & new toolbar buttons ──────────────────────────── */
.ide-wrap-btn,
.ide-tool-btn.ide-panel-btn-active {
  color: var(--accent) !important;
  background: var(--accent-dim) !important;
  border-color: var(--accent2) !important;
}

/* ── Search across files panel ────────────────────────────────── */
.ide-search-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  max-height: 260px;
  animation: fadeUp .18s ease both;
}
.ide-search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ide-search-title {
  flex: 1;
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: .04em;
}
.ide-search-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ide-search-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 12px;
  padding: 5px 8px;
  outline: none;
  transition: border-color .2s;
}
.ide-search-input:focus { border-color: var(--accent2); }
.ide-search-opt-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
  transition: all .15s;
  user-select: none;
}
.ide-search-opt-label:hover { border-color: var(--accent2); color: var(--accent); }
.ide-search-opt-label input { accent-color: var(--accent); }

.ide-search-results {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.ide-search-hint {
  padding: 14px 14px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.ide-search-group {
  border-bottom: 1px solid var(--border);
}
.ide-search-file-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
  background: var(--surface2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.ide-search-count {
  margin-left: auto;
  background: var(--accent-dim);
  border: 1px solid var(--accent2);
  color: var(--accent);
  border-radius: 10px;
  font-size: 9px;
  padding: 1px 7px;
}
.ide-search-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 12px 4px 20px;
  cursor: pointer;
  font-size: 11px;
  transition: background .1s;
}
.ide-search-row:hover { background: var(--surface2); }
.ide-search-lineno {
  color: var(--muted);
  font-size: 10px;
  flex-shrink: 0;
  min-width: 26px;
  text-align: right;
}
.ide-search-text {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ide-search-hl {
  background: rgba(212,168,83,.35);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
}
.ide-search-more {
  padding: 3px 20px 6px;
  font-size: 10px;
  color: var(--muted);
  font-style: italic;
}

/* ── Language picker ──────────────────────────────────────────── */
.ide-lang-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.ide-lang-picker {
  background: var(--surface);
  border: 1px solid var(--border-focus);
  border-radius: 10px;
  padding: 16px;
  min-width: 220px;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
  animation: fadeUp .15s ease both;
}
.ide-lang-picker-title {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.ide-lang-opt {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all .15s;
  margin-bottom: 2px;
}
.ide-lang-opt:hover { background: var(--surface2); border-color: var(--border); }
.ide-lang-cancel { color: var(--muted); }
.ide-lang-cancel:hover { color: var(--err); border-color: var(--err); }

/* ── Live preview button (only shown for HTML) ────────────────── */
.ide-tool-btn[id="ide-preview-btn"] {
  color: var(--ok);
}
.ide-tool-btn[id="ide-preview-btn"]:hover {
  border-color: var(--ok);
  color: var(--ok);
  background: rgba(76,175,130,.1);
}

/* ── Fold / go-to-line button ─────────────────────────────────── */
.ide-tool-btn[id="ide-fold-btn"],
.ide-tool-btn[id="ide-gotoline-btn"] {
  color: var(--muted);
}

/* ── Tab icon (small, before filename) ───────────────────────── */
.ide-tab-icon { font-size: 11px; flex-shrink: 0; }

/* ── Unsaved dot more prominent ──────────────────────────────── */
.ide-tab-dot {
  color: var(--accent);
  font-size: 10px;
  animation: pulse 2s ease-in-out infinite;
}

/* ── Editor column — status bar at very bottom ───────────────── */
.ide-editor-col {
  display: flex;
  flex-direction: column;
}
/* Push statusbar to the absolute bottom, above output */
.ide-editor-col > .ide-statusbar {
  order: 99;
}

/* ── Context-menu style file-tree tooltip ───────────────────── */
.ide-file-item .ide-file-actions {
  display: none;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}
.ide-file-item:hover .ide-file-actions { display: flex; }

/* ── Search & format buttons in toolbar separator ────────────── */
.ide-toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}
/* ── File tree: rename + delete actions ──────────────────────────── */
.ide-file-actions {
  display: none;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  margin-left: auto;
}
.ide-file-item:hover .ide-file-actions { display: flex; }

/* ═══════════════════════════════════════════════════════════════
   ide-v4.css  — append to bottom of style.css
   ═══════════════════════════════════════════════════════════════ */

/* ══════════════════════════
   TOOLBAR REDESIGN
   Two-row layout:
   Row 1 = tabs + panel toggles (right-aligned)
   Row 2 = compact icon-only action bar
   ══════════════════════════ */

/* Row 1: tab list + panel toggles */
.ide-topbar {
  display: flex;
  align-items: stretch;
  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; }

/* Panel toggles — right side of topbar */
.ide-panel-toggles {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 3px 6px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

.ide-ptoggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 44px;
  height: 30px;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--font-ui,'DM Mono',monospace);
  font-size: 8px;
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.ide-ptoggle:hover { color: var(--text); background: var(--surface2); }
.ide-ptoggle.ide-panel-btn-active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent2);
}
.ide-ptoggle svg { width: 13px; height: 13px; flex-shrink: 0; }

/* Row 2: compact icon-only action bar */
.ide-actionbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  min-height: 32px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ide-actionbar::-webkit-scrollbar { display: none; }

.ide-ab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--font-ui,'DM Mono',monospace);
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .12s;
  position: relative;
}
.ide-ab-btn:hover { color: var(--text); background: var(--surface2); border-color: var(--border); }
.ide-ab-btn.ide-ab-active { color: var(--accent); background: var(--accent-dim); border-color: var(--accent2); }

/* Run button is slightly more prominent */
.ide-ab-btn.ide-ab-run { color: var(--ok); }
.ide-ab-btn.ide-ab-run:hover { background: rgba(76,175,130,.12); border-color: var(--ok); }

/* Preview = gold */
.ide-ab-btn.ide-ab-preview { color: var(--accent); }
.ide-ab-btn.ide-ab-preview:hover { background: var(--accent-dim); border-color: var(--accent2); }

.ide-ab-sep {
  width: 1px; height: 16px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 3px;
}

/* Tooltip via CSS (no JS needed for simple tooltips) */
.ide-ab-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 10px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  letter-spacing: .03em;
}

/* ══════════════════════════
   EXPLORER PANEL REDESIGN
   ══════════════════════════ */

/* Project header row */
.ide-proj-header {
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ide-proj-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 6px;
}
.ide-proj-icon { color: var(--accent2); flex-shrink: 0; }
.ide-proj-name {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  cursor: text;
  min-width: 0;
}
.ide-proj-name:focus {
  background: var(--surface2);
  border-radius: 3px;
  padding: 0 4px;
}
.ide-proj-menu-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.ide-proj-menu-btn:hover { color: var(--accent); background: var(--accent-dim); }

/* Explorer quick action row */
.ide-explorer-actions {
  display: flex;
  gap: 3px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ide-exp-act-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--font-ui,'DM Mono',monospace);
  font-size: 9px;
  letter-spacing: .04em;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.ide-exp-act-btn:hover { color: var(--accent); border-color: var(--accent2); background: var(--accent-dim); }

/* ══════════════════════════
   VS CODE-STYLE FILE TREE
   ══════════════════════════ */

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

.ide-tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  cursor: pointer;
  padding-right: 6px;
  position: relative;
  user-select: none;
  border-radius: 0;
  transition: background .1s;
}
.ide-tree-row:hover { background: rgba(255,255,255,.04); }
.ide-tree-row.active { background: var(--accent-dim); }
.ide-tree-row.active .ide-tree-name { color: var(--accent); }

.ide-tree-folder.active { background: rgba(255,255,255,.06); }

.ide-tree-chevron {
  font-size: 9px;
  color: var(--muted);
  width: 12px;
  text-align: center;
  flex-shrink: 0;
  transition: transform .15s;
}
.ide-tree-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  line-height: 1;
}
.ide-tree-name {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.ide-tree-dot {
  font-size: 8px;
  color: var(--accent);
  flex-shrink: 0;
}

/* Hover actions on tree rows */
.ide-tree-actions {
  display: none;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}
.ide-tree-row:hover .ide-tree-actions { display: flex; }

.ide-tree-act {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
  line-height: 1;
  transition: color .12s, background .12s;
}
.ide-tree-act:hover { background: var(--surface2); color: var(--text); }
.ide-tree-del:hover { color: var(--err) !important; }

/* Indentation line (like VS Code) */
.ide-tree-row[data-path]::before {
  content: '';
  position: absolute;
  left: calc(var(--tree-depth, 0) * 14px + 14px);
  top: 0; bottom: 0;
  width: 1px;
  background: transparent;
}

/* ══════════════════════════
   CONTEXT MENU
   ══════════════════════════ */
.ide-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border-focus);
  border-radius: 8px;
  padding: 4px;
  min-width: 180px;
  box-shadow: 0 8px 32px rgba(0,0,0,.65);
  animation: popIn .12s ease both;
}
.ide-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: none;
  border: none;
  border-radius: 5px;
  color: var(--text);
  font-family: var(--font-ui,'DM Mono',monospace);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background .1s;
  white-space: nowrap;
}
.ide-ctx-item:hover { background: var(--surface2); }
.ide-ctx-item.ide-ctx-danger { color: var(--err); }
.ide-ctx-item.ide-ctx-danger:hover { background: rgba(224,112,112,.1); }
.ide-ctx-ico { font-size: 12px; width: 16px; text-align: center; flex-shrink: 0; }
.ide-ctx-sep { height: 1px; background: var(--border); margin: 3px 4px; }

/* ══════════════════════════
   STATUS BAR
   ══════════════════════════ */
.ide-statusbar {
  display: flex;
  align-items: center;
  height: 22px;
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0 8px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .03em;
  overflow: hidden;
  user-select: none;
  gap: 0;
}
.ide-sb-item {
  display: flex;
  align-items: center;
  padding: 0 6px;
  height: 100%;
  white-space: nowrap;
}
.ide-sb-name   { color: var(--text); font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.ide-sb-lang   { cursor: pointer; color: var(--accent2); }
.ide-sb-lang:hover { color: var(--accent); background: var(--surface2); }
.ide-sb-sep    { color: var(--border-focus); font-size: 12px; }
.ide-sb-saved  { color: var(--ok); font-size: 8px; margin-right: 4px; }
.ide-sb-unsaved{ color: var(--accent); font-size: 8px; margin-right: 4px; }

/* ══════════════════════════
   SEARCH PANEL
   ══════════════════════════ */
.ide-search-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  max-height: 280px;
  animation: fadeUp .18s ease both;
}
.ide-search-header { display:flex; align-items:center; gap:8px; padding:7px 12px; border-bottom:1px solid var(--border); flex-shrink:0; }
.ide-search-title  { flex:1; font-size:11px; color:var(--text); font-weight:500; letter-spacing:.04em; }
.ide-search-input-row { display:flex; align-items:center; gap:6px; padding:7px 12px; border-bottom:1px solid var(--border); flex-shrink:0; }
.ide-search-input  { flex:1; background:var(--surface2); border:1px solid var(--border); border-radius:5px; color:var(--text); font-family:var(--font-ui,'DM Mono',monospace); font-size:12px; padding:5px 8px; outline:none; transition:border-color .2s; }
.ide-search-input:focus { border-color:var(--accent2); }
.ide-search-opt-label { display:flex; align-items:center; gap:4px; font-size:10px; color:var(--muted); cursor:pointer; padding:3px 7px; border:1px solid var(--border); border-radius:4px; user-select:none; transition:all .15s; }
.ide-search-opt-label:hover { border-color:var(--accent2); color:var(--accent); }
.ide-search-opt-label input { accent-color:var(--accent); }
.ide-search-results { flex:1; overflow-y:auto; scrollbar-width:thin; scrollbar-color:var(--border) transparent; }
.ide-search-hint    { padding:14px; font-size:11px; color:var(--muted); text-align:center; }
.ide-search-group   { border-bottom:1px solid var(--border); }
.ide-search-file-label { display:flex; align-items:center; gap:6px; padding:5px 12px; font-size:11px; color:var(--text); font-weight:500; background:var(--surface2); position:sticky; top:0; z-index:1; }
.ide-search-count   { margin-left:auto; background:var(--accent-dim); border:1px solid var(--accent2); color:var(--accent); border-radius:10px; font-size:9px; padding:1px 7px; }
.ide-search-row     { display:flex; align-items:baseline; gap:8px; padding:4px 12px 4px 20px; cursor:pointer; font-size:11px; transition:background .1s; }
.ide-search-row:hover { background:var(--surface2); }
.ide-search-lineno  { color:var(--muted); font-size:10px; flex-shrink:0; min-width:26px; text-align:right; }
.ide-search-text    { color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ide-search-more    { padding:3px 20px 6px; font-size:10px; color:var(--muted); font-style:italic; }

/* ══════════════════════════
   LANG PICKER
   ══════════════════════════ */
.ide-lang-picker-overlay { position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:9000; display:flex; align-items:center; justify-content:center; backdrop-filter:blur(3px); }
.ide-lang-picker { background:var(--surface); border:1px solid var(--border-focus); border-radius:10px; padding:16px; min-width:220px; box-shadow:0 16px 48px rgba(0,0,0,.6); animation:fadeUp .15s ease both; }
.ide-lang-picker-title { font-size:11px; letter-spacing:.1em; text-transform:uppercase; color:var(--muted); margin-bottom:10px; }
.ide-lang-opt { display:block; width:100%; padding:8px 12px; background:none; border:1px solid transparent; border-radius:6px; color:var(--text); font-family:var(--font-ui,'DM Mono',monospace); font-size:12px; cursor:pointer; text-align:left; transition:all .15s; margin-bottom:2px; }
.ide-lang-opt:hover { background:var(--surface2); border-color:var(--border); }

/* ══════════════════════════
   FILE OPS PANEL (AI)
   ══════════════════════════ */
.ide-fop-panel      { background:var(--surface2); border:1px solid var(--accent2); border-radius:10px; overflow:hidden; animation:fadeUp .2s ease both; flex-shrink:0; }
.ide-fop-header     { display:flex; align-items:center; gap:8px; padding:9px 13px; background:rgba(212,168,83,.06); border-bottom:1px solid var(--border); }
.ide-fop-title      { flex:1; font-size:11px; font-weight:500; color:var(--accent); }
.ide-fop-apply-all-btn { padding:4px 12px; background:var(--accent); border:none; border-radius:5px; color:#0c0e0f; font-family:var(--font-ui,'DM Mono',monospace); font-size:10px; font-weight:600; cursor:pointer; transition:background .15s; }
.ide-fop-apply-all-btn:hover { background:#e0b96a; }
.ide-fop-apply-all-btn:disabled { opacity:.6; cursor:default; }
.ide-fop-card       { padding:9px 13px; border-bottom:1px solid var(--border); }
.ide-fop-card:last-child { border-bottom:none; }
.ide-fop-row        { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.ide-fop-badge      { font-size:10px; padding:2px 7px; border-radius:4px; flex-shrink:0; font-weight:500; }
.ide-fop-create .ide-fop-badge { background:rgba(76,175,130,.15); color:var(--ok); }
.ide-fop-modify .ide-fop-badge { background:rgba(212,168,83,.12); color:var(--accent); }
.ide-fop-delete .ide-fop-badge { background:rgba(224,112,112,.12); color:var(--err); }
.ide-fop-rename .ide-fop-badge { background:rgba(100,150,255,.12); color:#8eb4ff; }
.ide-fop-filename   { font-size:11px; color:var(--text); flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ide-fop-arrow      { font-size:10px; color:var(--muted); flex-shrink:0; }
.ide-fop-btns       { display:flex; gap:4px; flex-shrink:0; }
.ide-fop-btn        { padding:3px 9px; background:var(--surface); border:1px solid var(--border); border-radius:4px; color:var(--muted); font-family:var(--font-ui,'DM Mono',monospace); font-size:10px; cursor:pointer; transition:all .15s; }
.ide-fop-btn:hover  { border-color:var(--accent2); color:var(--accent); background:var(--accent-dim); }
.ide-fop-btn:disabled { opacity:.5; cursor:default; }
.ide-fop-apply-btn:hover { background:var(--accent); color:#0c0e0f; border-color:var(--accent); }
.ide-fop-preview-line { margin-top:5px; font-size:10px; color:var(--muted); font-family:var(--font-ui,'DM Mono',monospace); background:var(--bg); padding:4px 8px; border-radius:4px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ══════════════════════════
   MISC FIXES
   ══════════════════════════ */

/* Remove the OLD ide-toolbar (replaced by ide-actionbar) */
.ide-toolbar { display: none !important; }

/* Tab icon sizing */
.ide-tab-icon { font-size: 11px; flex-shrink: 0; }
.ide-tab-dot  { color:var(--accent); font-size:10px; }

/* History divider in AI panel */
.ide-ai-history-divider { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:6px 10px; background:var(--surface2); border:1px solid var(--border); border-radius:6px; font-size:10px; color:var(--muted); margin-bottom:4px; flex-shrink:0; }
.ide-ai-history-divider button { background:none; border:1px solid var(--border); border-radius:4px; color:var(--muted); font-family:var(--font-ui,'DM Mono',monospace); font-size:10px; padding:2px 7px; cursor:pointer; }
.ide-ai-history-divider button:hover { color:var(--err); border-color:var(--err); }

/* Project list in modal */
.ide-proj-list { display:flex; flex-direction:column; gap:3px; margin-bottom:14px; max-height:260px; overflow-y:auto; scrollbar-width:thin; scrollbar-color:var(--border) transparent; }
.ide-proj-item { width:100%; padding:9px 14px; background:var(--surface2); border:1px solid var(--border); border-radius:7px; color:var(--text); font-family:var(--font-ui,'DM Mono',monospace); font-size:12px; cursor:pointer; text-align:left; transition:border-color .15s,background .15s; }
.ide-proj-item:hover { border-color:var(--accent2); background:var(--accent-dim); color:var(--accent); }

/* @keyframes already defined in main style.css: fadeUp, popIn */
/* Add popIn if missing */
@keyframes popIn {
  from { opacity:0; transform:scale(.97) translateY(4px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}

/* Dragging cursor during resize */
body.ide-dragging-x * { cursor:col-resize !important; user-select:none !important; }
body.ide-dragging-y * { cursor:row-resize !important; user-select:none !important; }

/* Resize handles */
.ide-resize-handle-x { width:5px; flex-shrink:0; background:transparent; cursor:col-resize; position:relative; z-index:20; transition:background .15s; }
.ide-resize-handle-x:hover,.ide-resize-handle-x:active { background:var(--accent2); }
.ide-resize-handle-y { height:5px; flex-shrink:0; background:transparent; cursor:row-resize; position:relative; z-index:20; transition:background .15s; }
.ide-resize-handle-y:hover,.ide-resize-handle-y:active { background:var(--accent2); }

/* Panel hidden */
.ide-panel-hidden { display:none !important; }

/* Panel toggle buttons (for ide-panels.js — same elements but new class) */
.ide-toggle-btn.ide-panel-btn-active { color:var(--accent) !important; background:var(--accent-dim) !important; border-color:var(--accent2) !important; }

/* Terminal panel */
.ide-terminal-panel { display:none; flex-direction:column; flex-shrink:0; border-top:1px solid var(--border); background:#0a0b0c; min-height:120px; }
.ide-term-header { display:flex; align-items:center; gap:8px; padding:5px 10px; background:var(--surface); border-bottom:1px solid var(--border); flex-shrink:0; }
.ide-term-title  { flex:1; display:flex; align-items:center; gap:6px; font-size:10px; letter-spacing:.1em; text-transform:uppercase; color:var(--muted); }
.ide-term-body   { flex:1; overflow:hidden; min-height:0; background:#0a0b0c; }
.xterm { height:100%; padding:6px 10px; }
.xterm-viewport { scrollbar-width:thin; scrollbar-color:#2a2c2e transparent; }

/* Explorer footer stays at bottom */
.ide-explorer-footer { border-top:1px solid var(--border); padding:8px 10px; flex-shrink:0; }
.ide-tpl-label { font-size:9px; letter-spacing:.14em; 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:var(--font-ui,'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); }

/* ide-apply-btn on AI code blocks */
.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:var(--font-ui,'DM Mono',monospace); font-size:9px; cursor:pointer; transition:background .15s; z-index:10; }
.ide-apply-btn:hover { background:var(--accent-dim); }

/* ═══════════════════════════════════════════════════════════════
   SINGLE-BAR TOOLBAR  — add to bottom of style.css
   (Overrides the two-row layout from ide-v4.css)
   ═══════════════════════════════════════════════════════════════

   Layout of the single bar:
   [ tabs ············ ] [ sep ] [ icons ] [ sep ] [ Files | Output | AI ]
        flex: 1                  compact           right-aligned toggles
   ═══════════════════════════════════════════════════════════════ */

/* ── Kill the second row entirely ─────────────────────────────── */
.ide-actionbar {
  display: none !important;
}

/* ── Single unified bar ────────────────────────────────────────── */
.ide-topbar {
  display: flex;
  align-items: stretch;
  height: 36px;
  min-height: 36px;
  max-height: 36px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

/* Tabs get all leftover space */
.ide-tabs-list {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.ide-tabs-list::-webkit-scrollbar { display: none; }

/* ── Inline action buttons (icon-only, 26×26) ─────────────────── */
.ide-topbar-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px 6px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
}

.ide-tba-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color .12s, background .12s, border-color .12s;
  position: relative;
}
.ide-tba-btn:hover {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border);
}
.ide-tba-btn.ide-tba-run:hover  { color: var(--ok);    background: rgba(76,175,130,.1);  border-color: var(--ok); }
.ide-tba-btn.ide-tba-save:hover { color: var(--accent); background: var(--accent-dim);   border-color: var(--accent2); }
.ide-tba-btn.ide-ab-active      { color: var(--accent); background: var(--accent-dim);   border-color: var(--accent2); }

/* CSS tooltips — above the button */
.ide-tba-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1c1e;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 10px;
  font-family: var(--font-ui, 'DM Mono', monospace);
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  letter-spacing: .03em;
}

/* Separator between button groups */
.ide-tba-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 3px;
  align-self: center;
}

/* ── Panel toggles — right side ───────────────────────────────── */
.ide-panel-toggles {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px 6px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

.ide-ptoggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 40px;
  height: 28px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 7.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .12s;
  flex-shrink: 0;
}
.ide-ptoggle:hover {
  color: var(--text);
  background: var(--surface2);
}
.ide-ptoggle.ide-panel-btn-active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent2);
}
.ide-ptoggle svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.ide-file-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1;
  transition: color .15s, background .15s;
}
.ide-file-btn:hover { background: var(--surface2); }
.ide-file-rename:hover { color: var(--accent); }
.ide-file-del:hover    { color: var(--err); }

/* ── Project switcher list ───────────────────────────────────────── */
.ide-proj-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 14px;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.ide-proj-item {
  width: 100%;
  padding: 9px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.ide-proj-item:hover { border-color: var(--accent2); background: var(--accent-dim); color: var(--accent); }

/* ── AI history divider ──────────────────────────────────────────── */
.ide-ai-history-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .04em;
  margin-bottom: 4px;
  flex-shrink: 0;
}
.ide-ai-history-divider button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 10px;
  padding: 2px 7px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.ide-ai-history-divider button:hover { color: var(--err); border-color: var(--err); }

/* ── File ops panel ──────────────────────────────────────────────── */
.ide-fop-panel {
  background: var(--surface2);
  border: 1px solid var(--accent2);
  border-radius: 10px;
  overflow: hidden;
  animation: fadeUp .2s ease both;
  flex-shrink: 0;
}

.ide-fop-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  background: rgba(212,168,83,.06);
  border-bottom: 1px solid var(--border);
}
.ide-fop-title {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: .04em;
}
.ide-fop-apply-all-btn {
  padding: 4px 12px;
  background: var(--accent);
  border: none;
  border-radius: 5px;
  color: #0c0e0f;
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.ide-fop-apply-all-btn:hover    { background: #e0b96a; }
.ide-fop-apply-all-btn:disabled { opacity: .6; cursor: default; }

.ide-fop-card {
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  animation: fadeUp .15s ease both;
}
.ide-fop-card:last-child { border-bottom: none; }

.ide-fop-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ide-fop-badge {
  font-size: 10px;
  letter-spacing: .06em;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  font-weight: 500;
}
.ide-fop-create .ide-fop-badge { background: rgba(76,175,130,.15);  color: var(--ok); }
.ide-fop-modify .ide-fop-badge { background: rgba(212,168,83,.12);  color: var(--accent); }
.ide-fop-delete .ide-fop-badge { background: rgba(224,112,112,.12); color: var(--err); }
.ide-fop-rename .ide-fop-badge { background: rgba(100,150,255,.12); color: #8eb4ff; }

.ide-fop-filename {
  font-size: 11px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ide-fop-arrow {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
}

.ide-fop-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.ide-fop-btn {
  padding: 3px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 10px;
  cursor: pointer;
  transition: all .15s;
}
.ide-fop-btn:hover       { border-color: var(--accent2); color: var(--accent); background: var(--accent-dim); }
.ide-fop-btn:disabled    { opacity: .5; cursor: default; }
.ide-fop-apply-btn:hover { background: var(--accent); color: #0c0e0f; border-color: var(--accent); }

.ide-fop-preview-line {
  margin-top: 5px;
  font-size: 10px;
  color: var(--muted);
  font-family: var(--font-ui, 'DM Mono', monospace);
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Terminal panel ──────────────────────────────────────────────── */
.ide-terminal-panel {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  height: 280px;
  min-height: 160px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  position: relative;
}

.ide-term-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ide-term-title {
  flex: 1;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.ide-term-body {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #0a0b0c;
}

.ide-term-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.ide-term-ph-icon {
  font-size: 1.8rem;
  opacity: .4;
}
.ide-term-ph-path {
  font-size: 10px;
  color: var(--muted);
}
.ide-term-ph-path code {
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
  font-size: 10px;
}
.ide-term-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── "Include all files" toggle row ─────────────────────────────── */
.ide-ai-ctx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ide-ctx-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.ide-ctx-label input { accent-color: var(--accent); }

/* ── Project & Terminal toolbar buttons ─────────────────────────── */
#ide-project-btn,
#ide-terminal-btn {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── Puter FS sync indicator (tiny dot) ─────────────────────────── */
.ide-pfs-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(76,175,130,.5);
}
.ide-pfs-dot.syncing { background: var(--accent); animation: blink 1s ease-in-out infinite; }
.ide-pfs-dot.offline { background: var(--muted); box-shadow: none; }

/* ── Resize handle for terminal panel ───────────────────────────── */
.ide-term-resize-handle {
  height: 4px;
  cursor: ns-resize;
  background: transparent;
  flex-shrink: 0;
  transition: background .15s;
}
.ide-term-resize-handle:hover { background: var(--accent2); }

/* ── AI thinking dots in IDE (enhanced) ─────────────────────────── */
.ide-thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 6px 0;
}

/* ── Modal: project list scrollable ─────────────────────────────── */
.ide-modal {
  max-height: 80vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
/* ═══════════════════════════════════════════════════════════════════════
   IDE PANEL RESIZE & TOGGLE  — append to bottom of style.css
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Global dragging cursors ───────────────────────────────────────────── */
body.ide-dragging-x * { cursor: col-resize !important; user-select: none !important; }
body.ide-dragging-y * { cursor: row-resize !important; user-select: none !important; }

/* ── Resize handles ────────────────────────────────────────────────────── */
.ide-resize-handle-x {
  width: 5px;
  flex-shrink: 0;
  background: transparent;
  cursor: col-resize;
  position: relative;
  z-index: 20;
  transition: background .15s;
}
.ide-resize-handle-x:hover,
.ide-resize-handle-x:active {
  background: var(--accent2);
}
.ide-resize-handle-x::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: -3px; right: -3px; /* wider hit area */
}

.ide-resize-handle-y {
  height: 5px;
  flex-shrink: 0;
  background: transparent;
  cursor: row-resize;
  position: relative;
  z-index: 20;
  transition: background .15s;
}
.ide-resize-handle-y:hover,
.ide-resize-handle-y:active {
  background: var(--accent2);
}
.ide-resize-handle-y::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: -3px; bottom: -3px; /* wider hit area */
}

/* ── Panel hidden state ────────────────────────────────────────────────── */
.ide-panel-hidden {
  display: none !important;
}

/* ── Panel toggle buttons in the toolbar ──────────────────────────────── */
.ide-panel-toggle-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-right: 1px solid var(--border);
  padding-right: 8px;
  margin-right: 4px;
}

.ide-toggle-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 10px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.ide-toggle-btn:hover {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border);
}
.ide-toggle-btn.ide-panel-btn-active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: var(--accent2);
}
.ide-toggle-btn svg {
  flex-shrink: 0;
  opacity: .7;
  transition: opacity .15s;
}
.ide-toggle-btn.ide-panel-btn-active svg {
  opacity: 1;
}

/* ── Explorer — collapsed state ────────────────────────────────────────── */
#ide-explorer {
  transition: width .2s ease, min-width .2s ease;
  overflow: hidden;
}

/* ── AI panel — collapsed state ────────────────────────────────────────── */
#ide-ai-panel {
  transition: width .2s ease, min-width .2s ease;
  overflow: hidden;
}

/* ── Output panel ──────────────────────────────────────────────────────── */
#ide-output {
  transition: height .15s ease;
}

/* ── Terminal panel ────────────────────────────────────────────────────── */
#ide-terminal-panel {
  overflow: hidden;
  transition: height .15s ease;
}
.ide-terminal-panel {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: #0a0b0c;
  min-height: 120px;
}
.ide-term-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ide-term-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.ide-term-body {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  background: #0a0b0c;
}

/* ── xterm overrides ───────────────────────────────────────────────────── */
.xterm {
  height: 100%;
  padding: 6px 10px;
}
.xterm-viewport { scrollbar-width: thin; scrollbar-color: #2a2c2e transparent; }
.xterm-viewport::-webkit-scrollbar { width: 5px; }
.xterm-viewport::-webkit-scrollbar-thumb { background: #2a2c2e; border-radius: 3px; }

/* ── Terminal placeholder (before xterm loads) ─────────────────────────── */
.ide-term-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.ide-term-ph-icon { font-size: 1.8rem; opacity: .4; }
.ide-term-ph-path {
  font-size: 10px;
  color: var(--muted);
}
.ide-term-ph-path code {
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 10px;
}
.ide-term-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Responsive: hide AI panel on narrow viewports ─────────────────────── */
@media (max-width: 900px) {
  #ide-ai-panel.ide-panel-hidden {
    display: none !important;
  }
  .ide-panel-toggle-row { display: none; } /* too cramped on mobile */
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN REDESIGN  — NeuralDock Machined Aesthetic
   Replaces the existing login-card styles.
   Append this block to style.css (or replace the existing
   "── 16. LOGIN OVERLAY ──" section).
   ═══════════════════════════════════════════════════════════════ */

/* ── Overlay ─────────────────────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  background: #0a0908;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow: hidden;
}
#login-screen::before { display: none; } /* remove grid overlay on login */

/* Radial amber glow behind card */
#login-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(217,119,6,.06) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

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

/* ── Card wrapper ────────────────────────────────────────────────── */
.login-card {
  position: relative;
  z-index: 2;
  background: #1a1815;
  border: 1px solid rgba(163,140,124,.1);
  border-radius: 6px;
  width: 100%;
  max-width: 420px;
  margin: 0 24px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,.4);
  /* remove old card-rise / border-glow animations */
  animation: nd-card-in .5s cubic-bezier(.22,1,.36,1) both;
}
@keyframes nd-card-in {
  from { opacity:0; transform:translateY(24px) scale(.98); }
  to   { opacity:1; transform:translateY(0) scale(1); }
}

/* Gold calibration line along top edge */
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(217,119,6,.4) 20%,
    rgba(217,119,6,.7) 50%,
    rgba(217,119,6,.4) 80%,
    transparent 100%);
  z-index: 1;
}

/* ── Card inner padding ──────────────────────────────────────────── */
.login-card-inner {
  padding: 36px 32px 28px;
}

/* ── Brand header ────────────────────────────────────────────────── */
.login-logo {
  font-family: var(--font-head, 'Fraunces', serif);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: #e6e1df;
  margin-bottom: 0;
  line-height: 1;
  text-align: center;
}
.login-logo span {
  color: #d97706;
  font-weight: 700;
  font-style: normal;
  animation: none; /* override old orbit-glow */
  filter: none;
}
.login-tagline {
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 9px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(230,225,223,.4);
  text-align: center;
  margin: 8px 0 28px;
  max-width: none;
}

/* ── Primary Puter button ────────────────────────────────────────── */
.login-btn {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #d97706;
  color: #0a0908;
  border: none;
  border-radius: 3px;
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .03em;
  cursor: pointer;
  transition: background .2s;
  margin-bottom: 0;
  position: relative;
  overflow: hidden;
}
.login-btn::after { display: none; } /* remove old shimmer */
.login-btn:hover { background: #b45309; box-shadow: none; }
.login-btn:active { transform: scale(.99); }

/* ── Divider ─────────────────────────────────────────────────────── */
.login-divider-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: rgba(230,225,223,.25);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 9px;
  letter-spacing: .2em;
  text-transform: uppercase;
}
.login-divider-line::before,
.login-divider-line::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(163,140,124,.08);
}

/* ── Social buttons ──────────────────────────────────────────────── */
.login-social-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 0;
}
.login-social-sm {
  width: 100%;
  flex: unset;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(43,42,40,.3);
  border: 1px solid rgba(163,140,124,.1);
  border-radius: 3px;
  color: #dbc2b0;
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  white-space: nowrap;
}
.login-social-sm:hover {
  border-color: rgba(217,119,6,.5);
  background: rgba(43,42,40,.6);
  transform: none;
  box-shadow: none;
}
.login-social-sm svg { flex-shrink: 0; }

/* ── Email form ──────────────────────────────────────────────────── */
.login-email-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 0;
  animation: fadeUp .2s ease both;
}
.login-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: rgba(43,42,40,.4);
  border: 1px solid rgba(163,140,124,.12);
  border-radius: 3px;
  color: #e6e1df;
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 12px;
  outline: none;
  transition: border-color .2s;
}
.login-input:focus { border-color: rgba(217,119,6,.5); }
.login-input::placeholder { color: rgba(230,225,223,.3); }
.login-form-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}
.login-text-btn {
  background: none;
  border: none;
  color: rgba(230,225,223,.35);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 10px;
  cursor: pointer;
  padding: 0;
  transition: color .15s;
}
.login-text-btn:hover { color: #d97706; }

/* ── Status text ─────────────────────────────────────────────────── */
.login-status {
  margin-top: 14px;
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 11px;
  color: rgba(230,225,223,.4);
  min-height: 18px;
  text-align: center;
}

/* ── Fallback button ─────────────────────────────────────────────── */
.login-fallback {
  display: none;
  margin-top: 10px;
  width: 100%;
  background: none;
  border: 1px solid rgba(163,140,124,.15);
  color: rgba(230,225,223,.4);
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 10px;
  padding: 7px 14px;
  border-radius: 3px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.login-fallback.visible { display: block; }
.login-fallback:hover { color: #e6e1df; border-color: rgba(217,119,6,.4); }

/* ── Card footer metadata ────────────────────────────────────────── */
.login-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  border-top: 1px solid rgba(163,140,124,.07);
  background: rgba(10,9,8,.3);
}
.login-status-dot {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 9px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: rgba(230,225,223,.35);
}
.login-status-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0d9488;
  flex-shrink: 0;
  box-shadow: 0 0 5px rgba(13,148,136,.6);
}
.login-card-version {
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 9px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: rgba(230,225,223,.2);
}

/* ── External links below card ───────────────────────────────────── */
.login-ext-links {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 20px;
  margin-top: 20px;
}
.login-ext-links a {
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: rgba(230,225,223,.25);
  text-decoration: none;
  transition: color .15s;
}
.login-ext-links a:hover { color: #d97706; }

/* ── Bottom data ticker ──────────────────────────────────────────── */
.login-ticker {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: rgba(17,16,9,.8);
  border-top: 1px solid rgba(163,140,124,.06);
  display: flex;
  align-items: center;
  overflow: hidden;
  z-index: 3;
  pointer-events: none;
  user-select: none;
}
.login-ticker-track {
  display: flex;
  gap: 48px;
  white-space: nowrap;
  opacity: .18;
  animation: ticker-scroll 28s linear infinite;
}
@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.login-ticker-item {
  font-family: var(--font-ui, 'DM Mono', monospace);
  font-size: 10px;
  letter-spacing: .1em;
}
.login-ticker-item.tk-green  { color: #0d9488; }
.login-ticker-item.tk-gold   { color: #d97706; }
.login-ticker-item.tk-white  { color: #e6e1df; }

/* ── Shake animation (unchanged) ────────────────────────────────── */
@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: nd-card-in 0s, shake .45s ease both; }

/* ── Polling dots ────────────────────────────────────────────────── */
.polling-dots::after {
  content: '';
  animation: polling-anim 1.5s steps(4,end) infinite;
}
@keyframes polling-anim {
  0%  { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* ── Mobile tweaks ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  .login-card-inner { padding: 28px 20px 20px; }
  .login-card-footer { padding: 12px 20px; }
}

/* Palette: Micro-UX Clipboard Feedback */
.copy-success {
  color: var(--ok) !important;
  border-color: var(--ok) !important;
}
