/* ============================================
   ROXIE — SillyTavern Support Website
   Design System & Global Styles
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Background layers */
  --bg-deepest: #0a0a0f;
  --bg-deep: #0f0f14;
  --bg-base: #141419;
  --bg-surface: #1a1a22;
  --bg-elevated: #22222e;
  --bg-hover: #2a2a38;
  --bg-active: #323244;

  /* Golden Accent Palette */
  --gold-dim: #8a7330;
  --gold: #c9a84c;
  --gold-bright: #d4b85c;
  --gold-light: #e0c872;
  --gold-glow: rgba(201, 168, 76, 0.35);
  --gold-glow-soft: rgba(201, 168, 76, 0.15);

  /* Text */
  --text-primary: #e8e6e3;
  --text-secondary: #a09d97;
  --text-muted: #6b6860;
  --text-gold: #d4b85c;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-gold: rgba(201, 168, 76, 0.3);

  /* Status */
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-gold: 0 0 12px var(--gold-glow);

  /* Sizing */
  --sidebar-width: 64px;
  --sidebar-expanded: 220px;
  --header-height: 0px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Font */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-deepest);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

::selection {
  background: var(--gold);
  color: var(--bg-deepest);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dim);
}

/* --- Layout --- */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-deep);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  z-index: 100;
  transition: width var(--transition-slow);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: var(--bg-deepest);
  margin-bottom: 16px;
  box-shadow: var(--shadow-gold);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 0 8px;
  flex: 1;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.sidebar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-btn.active {
  background: var(--bg-active);
  color: var(--gold);
  box-shadow: inset 3px 0 0 var(--gold);
}

.sidebar-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.sidebar-btn .tooltip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-default);
  z-index: 1000;
}

.sidebar-btn:hover .tooltip {
  opacity: 1;
}

.sidebar-divider {
  width: 32px;
  height: 1px;
  background: var(--border-subtle);
  margin: 8px auto;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

.tab-view {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.tab-view.active {
  display: flex;
}

/* --- Tab Header --- */
.tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  min-height: 60px;
  flex-shrink: 0;
}

.tab-header h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-gold);
  display: flex;
  align-items: center;
  gap: 10px;
}

.tab-header h1 svg {
  width: 24px;
  height: 24px;
  color: var(--gold);
}

.tab-actions {
  display: flex;
  gap: 8px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-gold);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  border-color: var(--gold);
  color: var(--bg-deepest);
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  box-shadow: var(--shadow-gold);
}

.btn-danger {
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: var(--danger);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 6px;
  width: 32px;
  height: 32px;
  justify-content: center;
}

.btn-ghost {
  border: none;
  background: transparent;
}

.btn-ghost:hover {
  background: var(--bg-hover);
}

/* --- Form Controls --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow-soft);
}

.form-textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a09d97' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-hover);
  border-radius: 11px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.toggle input:checked+.toggle-slider {
  background: var(--gold);
}

.toggle input:checked+.toggle-slider::before {
  transform: translateX(18px);
  background: var(--bg-deepest);
}

/* --- Cards / Panels --- */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all var(--transition-base);
  backdrop-filter: blur(8px);
}

.card:hover {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-gold);
  transform: translateY(-1px);
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.15rem;
  color: var(--text-gold);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

/* --- Toast Notification --- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

@keyframes toastIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateX(50%);
  }
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.9rem;
}

/* --- Search Input --- */
.search-box {
  position: relative;
}

.search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.search-box input {
  padding-left: 34px;
  width: 100%;
}

/* --- Tag / Badge --- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tag:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.tag.active {
  background: var(--gold-glow-soft);
  border-color: var(--gold);
  color: var(--gold);
}

/* ============================================
   TAB 1: PRESET EDITOR
   ============================================ */
.preset-editor-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.preset-sidebar {
  width: 260px;
  min-width: 260px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
}

.preset-sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.preset-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.preset-list-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.preset-list-item.active {
  background: var(--bg-active);
  color: var(--gold);
}

.prompt-editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.prompt-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Compact row style — ST-inspired */
.prompt-item {
  background: var(--bg-surface);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.prompt-item:hover {
  background: var(--bg-hover);
}

.prompt-item.disabled {
  opacity: 0.45;
}

.prompt-item.drag-over {
  border-top: 2px solid var(--gold);
}

.prompt-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  min-height: 36px;
}

.prompt-item-header .drag-handle {
  color: var(--text-muted);
  cursor: grab;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: 2px;
}

.prompt-item-header .drag-handle:active {
  cursor: grabbing;
}

.prompt-item-header .prompt-role {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.prompt-role.system {
  background: rgba(96, 165, 250, 0.15);
  color: var(--info);
}

.prompt-role.user {
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.prompt-role.assistant {
  background: rgba(201, 168, 76, 0.15);
  color: var(--gold);
}

.prompt-item-header .prompt-name {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
  padding: 2px 4px;
  border-radius: 3px;
}

.prompt-item-header .prompt-name:focus {
  background: var(--bg-deep);
  box-shadow: 0 0 0 1px var(--gold);
}

.prompt-item-header .prompt-actions {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-shrink: 0;
}

.prompt-item-header .prompt-actions .btn-icon {
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.prompt-item-header .prompt-actions .btn-icon:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.prompt-item-header .prompt-actions .btn-icon.btn-danger:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.prompt-item-header .prompt-actions .toggle {
  transform: scale(0.75);
  margin: 0;
}

/* Expanded body */
.prompt-item-body {
  padding: 0 10px 10px;
  display: none;
  border-top: 1px solid var(--border-subtle);
  margin-top: 2px;
}

.prompt-item.expanded .prompt-item-body {
  display: block;
}

.prompt-item.expanded {
  background: var(--bg-surface);
  border-color: var(--border-default);
}

.prompt-item-body textarea {
  width: 100%;
  min-height: 120px;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast);
}

.prompt-item-body textarea:focus {
  border-color: var(--gold);
}

/* Preset editor — yellow translate button */
.pe-translate-go {
  background: var(--gold);
  color: #1a1a1a;
  border: none;
  cursor: pointer;
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-ui);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.pe-translate-go:hover {
  background: #d4b44a;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.3);
}

.pe-translate-go:disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* ============================================
   TAB 2: CHARACTER CARD
   ============================================ */
.character-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.character-gallery {
  width: 280px;
  min-width: 280px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
}

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

.character-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  align-content: start;
}

.char-card-thumb {
  aspect-ratio: 3/4;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  background: var(--bg-surface);
}

.char-card-thumb:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
  transform: scale(1.03);
}

.char-card-thumb.active {
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
}

.char-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.char-card-thumb .char-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  text-align: center;
}

.character-detail {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.char-detail-header {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.char-detail-avatar {
  width: 120px;
  height: 160px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border-gold);
  flex-shrink: 0;
  background: var(--bg-surface);
}

.char-detail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.char-detail-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.char-detail-info h2 {
  font-size: 1.4rem;
  color: var(--text-gold);
}

.char-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Upload dropzone */
.dropzone {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-md);
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-base);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--gold);
  background: var(--gold-glow-soft);
  color: var(--gold);
}

.dropzone svg {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
}

/* ============================================
   TAB 3: PRESET SHOWCASE
   ============================================ */
.showcase-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.showcase-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition-base);
  backdrop-filter: blur(8px);
}

.showcase-card:hover {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-gold);
  transform: translateY(-2px);
}

.showcase-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-gold);
  margin-bottom: 8px;
}

.showcase-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.showcase-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================
   TAB 4: WORLDBOOK / LOREBOOK
   ============================================ */
.worldbook-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.wb-sidebar {
  width: 280px;
  min-width: 280px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
}

/* Sidebar Tabs */
.wb-sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.wb-sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 2px solid transparent;
  font-family: var(--font-ui);
}

.wb-sidebar-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.wb-sidebar-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: var(--bg-active);
}

.wb-sidebar-tab svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Sidebar Panels */
.wb-sidebar-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.wb-sidebar-panel.active {
  display: flex;
}

.wb-sidebar-header {
  padding: 10px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* World List */
.wb-world-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.wb-world-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.wb-world-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.wb-world-item.active {
  background: var(--bg-active);
  color: var(--gold);
}

/* Entry List */
.wb-entry-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wb-entry-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.82rem;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.wb-entry-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.wb-entry-item.active {
  background: var(--bg-active);
  color: var(--gold);
  border-color: var(--border-gold);
}

.wb-entry-item.disabled {
  opacity: 0.5;
}

.wb-entry-item .entry-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
  flex-shrink: 0;
}

.wb-entry-item .entry-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.wb-entry-item .entry-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.wb-entry-item .entry-status.off {
  background: var(--text-muted);
  opacity: 0.4;
}

/* Editor Pane */
.wb-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 24px;
  background: var(--bg-base);
}

.wb-editor>.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.wb-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.wb-editor-header h3 {
  font-size: 1.1rem;
  color: var(--text-gold);
  display: flex;
  align-items: center;
  gap: 8px;
}

.wb-editor-header .editor-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.wb-editor-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.wb-editor-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex-shrink: 0;
}

.wb-editor-fields .form-group {
  margin-bottom: 0;
}

.wb-editor-fields .form-label {
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.wb-editor-content-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  margin-top: 12px;
}

.wb-editor-content-wrap .form-label {
  font-size: 0.78rem;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.wb-editor-content-wrap .form-textarea {
  flex: 1;
  min-height: 180px;
  resize: vertical;
}

.wb-editor-toggles {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.wb-editor-toggles label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.wb-editor-toggles label:hover {
  color: var(--text-primary);
}

/* --- Translate Bar (compact inline) --- */
.translate-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.translate-bar .translate-lang-select {
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 3px 8px;
  outline: none;
  cursor: pointer;
  font-family: var(--font-ui);
  min-width: 100px;
}

.translate-bar .translate-lang-select:focus {
  border-color: var(--gold);
  color: var(--text-primary);
}

.translate-bar .translate-go-btn {
  background: rgba(201, 168, 76, 0.1);
  border: 1px solid var(--border-gold);
  color: var(--gold);
  cursor: pointer;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--transition-fast);
  font-family: var(--font-ui);
  white-space: nowrap;
}

.translate-bar .translate-go-btn:hover {
  background: rgba(201, 168, 76, 0.2);
}

.translate-bar .translate-go-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.translate-bar .translate-settings-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 4px;
  font-size: 0.8rem;
  transition: color var(--transition-fast);
  line-height: 1;
}

.translate-bar .translate-settings-btn:hover {
  color: var(--gold);
}

/* Character card translate-all bar */
.cc-translate-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(201, 168, 76, 0.05);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
}

.cc-translate-bar .translate-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cc-translate-bar .translate-lang-select {
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding: 4px 10px;
  outline: none;
  cursor: pointer;
  font-family: var(--font-ui);
}

.cc-translate-bar .translate-lang-select:focus {
  border-color: var(--gold);
}

.cc-translate-bar .translate-go-btn {
  background: rgba(201, 168, 76, 0.15);
  border: 1px solid var(--gold);
  color: var(--text-gold);
  cursor: pointer;
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
  font-family: var(--font-ui);
  white-space: nowrap;
}

.cc-translate-bar .translate-go-btn:hover {
  background: rgba(201, 168, 76, 0.25);
}

.cc-translate-bar .translate-go-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.cc-translate-bar .translate-settings-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 0.85rem;
  transition: color var(--transition-fast);
  margin-left: auto;
}

.cc-translate-bar .translate-settings-btn:hover {
  color: var(--gold);
}

/* --- Translation Settings Modal --- */
.translate-settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.translate-settings-overlay.active {
  display: flex;
}

.translate-settings-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 560px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.translate-settings-modal h3 {
  font-size: 1rem;
  color: var(--text-gold);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.translate-settings-modal .form-textarea {
  min-height: 140px;
  font-size: 0.85rem;
  font-family: var(--font-mono, monospace);
}

.translate-settings-modal .hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

.translate-settings-modal .modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ============================================
   TAB 5: PLAYGROUND
   ============================================ */
.playground-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.playground-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.playground-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 80%;
  animation: messageIn 0.3s ease;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.message.user .message-avatar {
  background: var(--gold-glow-soft);
  color: var(--gold);
}

.message-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.message.user .message-bubble {
  background: var(--bg-elevated);
  border-color: var(--border-gold);
}

.playground-input {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.playground-input textarea {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 42px;
  line-height: 1.5;
}

.playground-input textarea:focus {
  border-color: var(--gold);
}

.playground-settings {
  width: 320px;
  min-width: 320px;
  border-left: 1px solid var(--border-subtle);
  background: var(--bg-deep);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.playground-settings h3 {
  font-size: 0.9rem;
  color: var(--text-gold);
  margin-bottom: 4px;
}

.playground-settings.collapsed {
  display: none;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   TAB 6: USER PERSONA
   ============================================ */
.persona-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.persona-sidebar {
  width: 260px;
  min-width: 260px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
}

.persona-sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.persona-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.persona-list-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.persona-list-item.active {
  background: var(--bg-active);
  color: var(--gold);
}

.persona-list-item .persona-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-hover);
  overflow: hidden;
  flex-shrink: 0;
}

.persona-list-item .persona-avatar-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.persona-editor {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.persona-avatar-upload {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px dashed var(--border-default);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin: 0 auto 20px;
  position: relative;
  background: var(--bg-surface);
}

.persona-avatar-upload:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.persona-avatar-upload img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.persona-avatar-upload .upload-icon {
  z-index: 1;
}

.persona-templates {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.template-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition-base);
}

.template-card:hover {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-gold);
}

/* --- Utility --- */
.flex {
  display: flex;
}

.flex-1 {
  flex: 1;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: 6px;
}

.gap-md {
  gap: 12px;
}

.gap-lg {
  gap: 20px;
}

.text-gold {
  color: var(--text-gold);
}

.text-muted {
  color: var(--text-muted);
}

.mt-auto {
  margin-top: auto;
}

.hidden {
  display: none !important;
}

/* --- Auto-save indicator --- */
.autosave-indicator {
  position: fixed;
  bottom: 16px;
  right: 16px;
  padding: 6px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition-base);
  z-index: 500;
}

.autosave-indicator.show {
  opacity: 1;
}

.autosave-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}