/*    STORY EDITOR VIEW
══════════════════════════════════════════════════ */
.editor-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.editor-topbar h2 { flex: 1; font-size: 16px; }

/* ── Editor nav (sidebar + content) ── */
.editor-nav-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.editor-nav-sidebar {
  width: 110px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  overflow-y: auto;
  background: var(--bg2);
}
.editor-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px 8px;
  border: none;
  background: none;
  color: var(--text2);
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 11px;
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.12s, color 0.12s;
  text-align: center;
  line-height: 1.2;
  width: 100%;
  min-height: 54px;
  justify-content: center;
}
.editor-nav-item:hover {
  background: var(--bg3);
  color: var(--text);
}
.editor-nav-item.active {
  background: var(--accent);
  color: var(--text-inverse);
}
.editor-nav-icon {
  font-size: 18px;
  line-height: 1;
}
.editor-nav-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
@media (max-width: 640px) {
  .editor-nav-layout { flex-direction: column; }
  .editor-nav-sidebar {
    width: 100%;
    flex-direction: row;
    padding: 6px 10px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    gap: 4px;
  }
  .editor-nav-sidebar::-webkit-scrollbar { display: none; }
  .editor-nav-item {
    flex-direction: row;
    flex-shrink: 0;
    width: auto;
    gap: 6px;
    padding: 8px 12px;
    min-height: 40px;
    font-size: 13px;
  }
  .editor-nav-icon { font-size: 16px; }
  .editor-nav-content { padding: 16px; }
}

.editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

/* Characters */
.char-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.char-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.char-card.editing { border-color: var(--accent); }
.char-card-info { flex: 1; min-width: 0; }
.char-card-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.char-card-desc { font-size: 13px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-edit-form { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.char-pc-badge { font-size: 11px; padding: 1px 6px; background: var(--accent-glow); color: var(--accent); border-radius: 4px; margin-left: 8px; }

/* Connection status */
.conn-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.conn-row > :first-child { flex: 1; }
.conn-status { font-size: 13px; padding: 4px 0; min-height: 22px; }
.conn-ok { color: var(--success); }
.conn-err { color: var(--danger); }

.model-pull-bar {
  height: 6px; background: var(--border); border-radius: 3px;
  margin: 8px 0 4px; overflow: hidden;
}
.model-pull-fill {
  height: 100%; background: var(--accent); border-radius: 3px;
  width: 0%; transition: width 0.4s ease;
}

/* ══════════════════════════════════════════════════
   SETTINGS VIEW
══════════════════════════════════════════════════ */
.settings-view {
  height: 100%;
  overflow-y: auto;
}
.settings-body {
  max-width: 600px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}
.settings-body h1 { margin-bottom: 28px; }
.settings-section { margin-bottom: 36px; }
.settings-section h2 { margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ── Admin Provider List ── */
.admin-providers-list { display: flex; flex-direction: column; gap: 6px; }
.admin-provider-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: grab; user-select: none;
}
.admin-provider-item.dragging { opacity: 0.5; border-color: var(--accent); }
.admin-provider-drag { color: var(--text3); cursor: grab; font-size: 14px; }
.admin-provider-rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg3); color: var(--text2); font-size: 12px; font-weight: 600;
}
.admin-provider-name { font-weight: 600; color: var(--text1); }
.admin-provider-desc { color: var(--text3); font-size: 12px; margin-left: auto; }

/* ── Admin Table ── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th,
.admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--text3); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; }
.admin-table tr:hover td { background: var(--bg2); }

.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.badge-ok { background: rgba(34,197,94,0.15); color: #22c55e; }
.badge-err { background: rgba(239,68,68,0.15); color: #ef4444; }

/* ── Spinner ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── No sessions ── */
.no-session-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text2);
  font-size: 14px;
}

/* ══════════════════════════════════════════════════
   MODEL PRESET BUTTONS
══════════════════════════════════════════════════ */
.preset-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.preset-btn {
  flex: 1;
  padding: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  transition: all 0.15s;
}
.preset-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.preset-btn small { display: block; color: var(--text3); font-weight: 400; margin-top: 2px; }

/* ══════════════════════════════════════════════════
   PROMPT PREVIEW PANEL
══════════════════════════════════════════════════ */
.prompt-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 12px;
  overflow: hidden;
}
.prompt-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.prompt-preview-header:hover { background: var(--bg3); }
.prompt-preview-body {
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--text2);
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.5;
  border-top: 1px solid var(--border);
}
.prompt-preview-body.collapsed { display: none; }

/* ══════════════════════════════════════════════════
   IMPORT / EXPORT
══════════════════════════════════════════════════ */
.home-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ══════════════════════════════════════════════════
   NARRATOR VOICE SHORTCUTS
══════════════════════════════════════════════════ */
.voice-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  flex-wrap: wrap;
}
.voice-bar-label { font-size: 11px; color: var(--text3); margin-right: 2px; }
.voice-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text2);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.voice-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ══════════════════════════════════════════════════
   IMAGE PROMPT EDITOR
══════════════════════════════════════════════════ */
.img-prompt-editor {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 8px;
}
.img-prompt-editor textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  font-size: 12px;
  font-family: monospace;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 6px 8px;
  box-sizing: border-box;
}
.img-prompt-actions { display: flex; gap: 6px; margin-top: 6px; }

.prompt-provenance {
  margin-top: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text2);
  background: rgba(255,255,255,0.02);
}
.prompt-provenance-head {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
.prompt-provenance-lore {
  margin-top: 4px;
}
.prompt-provenance-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.turn-focus {
  box-shadow: 0 0 0 2px var(--accent) inset;
  transition: box-shadow 0.4s ease;
}

.editor-pane .turn-quality-chip,
.editor-container .turn-quality-chip {
  font-size: 11px;
  border-radius: 10px;
  padding: 1px 7px;
  background: var(--bg4);
  color: var(--text2);
}

.memory-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-height: 70vh;
  overflow-y: auto;
}

.memory-grid textarea {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 4px;
}

.turn-timeline {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.timeline-dot, .timeline-dot.has-image, .timeline-dot.is-bookmark {
  /* canonical definitions live in misc.css */
}

.turn-block.compact-collapsed .narrative-text,
.turn-block.compact-collapsed .turn-image-wrap,
.turn-block.compact-collapsed .prompt-provenance,
.turn-block.compact-collapsed #img-prompt-editor {
  display: none;
}

.turn-image-queue-meta {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════
   IMAGE STYLE PRESETS
══════════════════════════════════════════════════ */
.style-preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.style-preset-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
  color: var(--text2);
}
.style-preset-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ══════════════════════════════════════════════════
   TOKEN COUNTER (prompts tab)
══════════════════════════════════════════════════ */
.token-counter {
  font-size: 11px;
  color: var(--text3);
  text-align: right;
  margin-top: 4px;
}
.token-counter.warn { color: var(--warning); }


