/* ==========================================================================
   CONNIE STUDIO — global stylesheet
   ========================================================================== */

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

:root {
  --bg:          #0d0d0f;
  --surface:     #16161a;
  --surface-2:   #1e1e24;
  --border:      #2a2a32;
  --accent:      #a855f7;
  --accent-dim:  #7c3aed;
  --accent-glow: rgba(168,85,247,.15);
  --text:        #e8e8f0;
  --text-muted:  #6b6b80;
  --text-dim:    #9191a8;
  --sidebar-w:   260px;
  --header-h:    56px;
  --success:     #22c55e;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --info:        #3b82f6;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── ICONS ────────────────────────────────────────────── */
.icon {
  width: 1.05em;
  height: 1.05em;
  display: inline-block;
  vertical-align: -0.18em;
  flex-shrink: 0;
}
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 40px; height: 40px; }

/* ── TOP BAR ─────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px 0 0;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
}
.topbar-brand {
  width: var(--sidebar-w);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text);
  text-decoration: none;
  border-right: 1px solid var(--border);
  height: 100%;
}
.topbar-brand .logo-dot {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.topbar-brand .logo-dot .icon { width: 16px; height: 16px; }
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-dim);
}
.topbar-badge span { color: var(--accent); font-weight: 600; }
.model-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  outline: none;
}
.avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* ── LAYOUT ──────────────────────────────────────────── */
.layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 16px 0 24px;
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-section { margin-bottom: 6px; }
.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s ease;
  position: relative;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}
.nav-item .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
}
.nav-item .step-num {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-muted);
}
.nav-item.active .step-num {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── LOCKED NAV ──────────────────────────────────────── */
.nav-item.locked {
  opacity: .45;
  cursor: default;
  pointer-events: none;
}
.nav-item.locked .lock-icon {
  margin-left: auto;
  width: 12px; height: 12px;
  opacity: .7;
}
.nav-item.locked .step-num + .lock-icon { margin-left: 6px; }

/* ── LOCKED OVERLAY ──────────────────────────────────── */
.locked-overlay {
  display: none;
  position: fixed;
  top: var(--header-h);
  left: var(--sidebar-w);
  right: 0; bottom: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.locked-overlay.visible { display: flex; }
.locked-overlay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 48px;
  text-align: center;
  pointer-events: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  max-width: 400px;
}
.locked-overlay-card .lock-big {
  width: 40px; height: 40px;
  margin: 0 auto 16px;
  display: block;
  color: var(--text-muted);
}
.locked-overlay-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}
.locked-overlay-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.main.blurred {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
  transition: filter .4s ease;
}

.pipeline-connector {
  width: 2px;
  height: 10px;
  background: var(--border);
  margin: 0 0 0 38px;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 16px;
}

/* ── MAIN CONTENT ────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px 36px;
  min-width: 0;
}

/* ── PAGE HEADER ─────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header .breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.page-header .breadcrumb a { color: var(--text-dim); text-decoration: none; }
.page-header .breadcrumb a:hover { color: var(--text); }
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.4px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-header h1 .icon { width: 26px; height: 26px; color: var(--accent); }
.page-header p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── GRID ────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── PLACEHOLDER / STUB ──────────────────────────────── */
.stub-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 16px;
  gap: 12px;
  color: var(--text-muted);
}
.stub-icon {
  width: 48px; height: 48px;
  opacity: .5;
  color: var(--text-muted);
}
.stub-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dim);
}
.stub-desc {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  max-width: 340px;
  line-height: 1.6;
}
.stub-tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .05em;
}

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s ease;
}
.btn .icon { width: 14px; height: 14px; }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn:disabled, .btn.is-loading {
  opacity: .55;
  cursor: wait;
  pointer-events: none;
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border) !important;
}
.btn.is-loading {
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .55; }
  50%      { opacity: .85; }
}

/* ── STAT PILL ───────────────────────────────────────── */
.stat-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}
.stat-pill .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-pill .value { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -.5px; }
.stat-pill .delta { font-size: 12px; }
.delta.up   { color: var(--success); }
.delta.down { color: var(--danger); }

/* ── UTILITIES ───────────────────────────────────────── */
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex   { display: flex; }
.gap-12 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── BADGES (status / source) ────────────────────────── */
.status-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 4px; white-space: nowrap;
}
.st-0 { background: rgba(59,130,246,.1);  border: 1px solid rgba(59,130,246,.3);  color: var(--info); }
.st-1 { background: rgba(168,85,247,.1);  border: 1px solid rgba(168,85,247,.3);  color: #a855f7; }
.st-2, .st-3, .st-4, .st-5, .st-6 {
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.3); color: #f59e0b;
}
.st-7 { background: rgba(34,197,94,.08);  border: 1px solid rgba(34,197,94,.3);  color: var(--success); }
.st-8 { background: rgba(34,197,94,.15);  border: 1px solid rgba(34,197,94,.4);  color: var(--success); }

.source-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 4px;
}
.src-imported { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }
.src-gemini   { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: var(--info); }
.src-manual   { background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.3); color: var(--success); }
.active-badge { background: var(--accent-glow); border: 1px solid var(--accent); color: var(--accent); }

/* ── TABS (idea / script lists) ──────────────────────── */
.idea-tabs {
  display: flex; gap: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.idea-tab {
  padding: 10px 20px;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  user-select: none;
}
.idea-tab:hover { color: var(--text); }
.idea-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.idea-tab .tab-count {
  font-size: 11px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 7px; margin-left: 6px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── CARDS (char + script) ───────────────────────────── */
.char-card, .script-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px; margin: 6px 0;
  cursor: pointer; transition: border-color .15s;
}
.char-card:hover, .script-card:hover { border-color: var(--accent); }
.char-card.active, .script-card.active { border-color: var(--accent); background: var(--accent-glow); }

.card-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.char-title, .card-title-list {
  font-size: 13.5px; font-weight: 700; color: var(--text);
  line-height: 1.3; margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
}

.card-detail {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.char-card.expanded .card-detail,
.script-card.expanded .card-detail { display: block; }
.char-body, .card-body {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.65;
  margin-bottom: 8px;
}
.char-tags, .card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.char-tag, .card-tag {
  font-size: 10px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 4px; padding: 2px 7px;
}

.script-preview {
  font-size: 12px; color: var(--text-dim); line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 8px;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  white-space: pre-wrap; max-height: 120px; overflow: hidden;
}

/* ── RENAME PENCIL ───────────────────────────────────── */
.rename-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 2px 4px; line-height: 1; border-radius: 4px;
  opacity: 0; transition: opacity .15s, color .15s;
}
.rename-btn .icon { width: 13px; height: 13px; }
.char-card.expanded .rename-btn,
.script-card.expanded .rename-btn { opacity: 1; }
.rename-btn:hover { color: var(--accent); }

/* ── SEARCH BOX ──────────────────────────────────────── */
.search-box {
  width: 100%;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
  padding: 9px 14px; outline: none;
  transition: border-color .15s; box-sizing: border-box;
}
.search-box:focus { border-color: var(--accent); }

/* ── MODALS ──────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px;
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 48px rgba(0,0,0,.4);
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 36px;
  width: 100%; max-width: 520px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.modal-box h2 { font-size: 17px; font-weight: 700; color: var(--text); }
.modal-box p  { font-size: 13px; color: var(--text-muted); }
.modal input[type=text], .modal textarea,
.modal-input, .modal-textarea {
  width: 100%;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
  font-family: inherit; padding: 10px 14px; outline: none;
  transition: border-color .15s; box-sizing: border-box;
}
.modal input[type=text]:focus, .modal textarea:focus,
.modal-input:focus, .modal-textarea:focus { border-color: var(--accent); }
.modal textarea, .modal-textarea {
  resize: vertical; line-height: 1.6; min-height: 90px;
}
.modal-close-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; line-height: 1; padding: 0;
}
.modal-close-btn .icon { width: 18px; height: 18px; }
.modal-cancel-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 8px;
  padding: 9px 18px; font-size: 13px; cursor: pointer;
}
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px;
}
.modal-field {
  display: flex; flex-direction: column; gap: 5px;
}
.modal-field > span {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted);
}
.editable-row {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
}
.editable-row input[type=text],
.editable-row textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  font-family: inherit;
  resize: vertical;
}
.editable-row input[type=text]:focus,
.editable-row textarea:focus { border-color: var(--accent); }
.editable-row .name-input { font-weight: 700; }

/* ── EDIT-SCRIPT EDITOR ──────────────────────────────── */
.script-editor {
  width: 100%;
  min-height: 520px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13.5px;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  line-height: 1.8;
  padding: 18px 20px;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.script-editor:focus { border-color: var(--accent); }

.ai-status {
  display: none;
  font-size: 12.5px; color: var(--text-muted);
  align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px;
}
.ai-status.visible { display: flex; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.idea-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.65;
}

.version-tabs {
  display: flex; gap: 0; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.version-tab {
  padding: 7px 14px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent;
  text-decoration: none;
  transition: color .15s, border-color .15s;
  display: flex; align-items: center; gap: 5px;
}
.version-tab:hover { color: var(--text); }
.version-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.version-rename-btn {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 0 2px; line-height: 1;
}
.version-rename-btn .icon { width: 12px; height: 12px; }
.version-rename-btn:hover { color: var(--accent); }

/* ── HOT TOPICS ──────────────────────────────────────── */
.iwc-tabs { display: flex; gap: 6px; }
.iwc-tab {
  padding: 7px 16px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all .15s;
  line-height: 1.4; box-sizing: border-box;
  display: inline-flex; align-items: center; gap: 6px;
}
.iwc-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.iwc-tab:hover:not(.active) { border-color: var(--accent); color: var(--text); }

.iwc-period-btn {
  padding: 7px 16px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  line-height: 1.4;
  display: inline-block;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text-muted);
}
.iwc-period-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.iwc-list { display: none; }
.iwc-list.active { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }

.iwc-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px;
  font-size: 12.5px; transition: border-color .15s;
  text-decoration: none;
}
.iwc-row:hover { border-color: var(--accent); }
.iwc-rank {
  font-size: 11px; font-weight: 800;
  color: var(--accent); background: var(--accent-glow);
  border: 1px solid var(--accent); border-radius: 5px;
  padding: 1px 6px; min-width: 26px; text-align: center;
}
.iwc-info { flex: 1; min-width: 0; }
.iwc-title { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iwc-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 7px;
  padding: 6px 14px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.refresh-btn:hover { border-color: var(--accent); color: var(--accent); }
.refresh-btn.loading { opacity: .6; pointer-events: none; }

.iwc-meta { font-size: 11.5px; color: var(--text-muted); }
.iwc-meta .ok   { color: var(--success); }
.iwc-meta .warn { color: var(--warning); }

.cat-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px;
  font-size: 12.5px;
  transition: border-color .15s, background .15s;
  cursor: pointer; user-select: none;
}
.cat-row:hover { border-color: var(--accent); }
.cat-row.selected { border-color: var(--accent); background: var(--accent-glow); }
.cat-row.selected .iwc-rank { background: var(--accent); color: #fff; }
.cat-row.disabled { opacity: .4; pointer-events: none; }

.gen-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 16px;
  transform: translateY(100%); transition: transform .2s ease;
}
.gen-bar.visible { transform: translateY(0); }
.gen-bar-info { font-size: 13px; color: var(--text-dim); }
.gen-bar-info strong { color: var(--text); }
.gen-bar-btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 10px 22px;
  font-size: 13px; font-weight: 700;
  cursor: pointer; transition: background .15s;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.gen-bar-btn:hover { background: var(--accent-dim); }
.gen-bar-btn:disabled { opacity: .5; pointer-events: none; }

/* ── BANNED PHRASES ──────────────────────────────────── */
.phrase-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; margin: 6px 0;
  font-size: 13px;
}
.phrase-row .phrase { font-weight: 600; color: var(--text); }
.phrase-row .note { font-size: 11.5px; color: var(--text-muted); margin-left: 8px; }
.phrase-row .actions { margin-left: auto; }

.add-form {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 14px;
}
.add-form input[type=text] {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); font-size: 13px;
  padding: 8px 12px; outline: none; transition: border-color .15s;
}
.add-form input[type=text]:focus { border-color: var(--accent); }
.add-form input.phrase-input { max-width: 240px; }

.info-block {
  background: rgba(59,130,246,.06);
  border: 1px solid rgba(59,130,246,.2);
  border-radius: 8px; padding: 10px 14px;
  font-size: 12.5px; color: var(--text-dim);
  margin-bottom: 14px; line-height: 1.55;
  display: flex; align-items: flex-start; gap: 10px;
}
.info-block .icon { color: var(--info); flex-shrink: 0; margin-top: 2px; }

/* ── IMAGE GENERATION ────────────────────────────────── */
.hidden { display: none !important; }

.analysis-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.analysis-section { display: flex; flex-direction: column; gap: 6px; }
.analysis-label {
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent);
}
.analysis-row {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
}
.analysis-row strong { color: var(--text); }

.scene-chip {
  font-size: 10.5px; font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 5px;
  padding: 2px 7px;
  display: inline-flex; align-items: center; gap: 4px;
}
.scene-chip .icon { width: 11px; height: 11px; }

.scene-block { margin-bottom: 8px; }
.scene-block-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 3px;
  display: flex; align-items: center; gap: 5px;
}
.scene-block-label .icon { width: 11px; height: 11px; }
.scene-block-text {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
}
.scene-block-evolution {
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  background: var(--accent-glow);
  border-radius: 0 6px 6px 0;
  padding: 6px 10px;
}
.scene-block-evolution .scene-block-label { color: var(--accent); }

.scene-prompt-details {
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 6px 0 10px;
}
.scene-prompt-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
}
.scene-prompt-details summary:hover { color: var(--text); }
.scene-prompt-text {
  margin-top: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-dim);
  white-space: pre-wrap;
}


.scene-list { display: flex; flex-direction: column; gap: 14px; }
.scene-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
}
.scene-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.scene-num {
  font-size: 11px; font-weight: 800;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 1px 7px;
  min-width: 30px; text-align: center;
}
.scene-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 10px;
}
.scene-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.scene-actions .btn { font-size: 12px; padding: 7px 14px; }

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.image-tile {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
}
.image-tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.image-tile .img-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  color: #fff;
  font-size: 11px;
  padding: 18px 10px 8px;
  line-height: 1.4;
}
.image-tile .img-delete {
  position: absolute;
  top: 6px; right: 6px;
  margin: 0;
}
.image-tile .img-delete button {
  background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  border-radius: 6px;
  padding: 4px 6px;
  cursor: pointer;
  display: inline-flex; align-items: center;
}
.image-tile .img-delete button:hover { background: var(--danger); }
.image-tile .img-delete .icon { width: 13px; height: 13px; }

.image-tile.placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
}
.image-tile.placeholder .spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ── LIGHTBOX ─────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.93);
  z-index: 1000;
  align-items: center; justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  width: auto; height: auto;
  object-fit: contain;
  border-radius: 8px;
  cursor: default;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.lightbox-close {
  position: absolute;
  top: 20px; right: 24px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  border-radius: 50%;
  width: 38px; height: 38px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.18); }
.lightbox-close .icon { width: 18px; height: 18px; }

/* ── LOGIN PAGE ──────────────────────────────────────── */
.login-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 30px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}
.login-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700;
  color: var(--text);
  margin-bottom: 22px;
}
.login-brand .logo-dot {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.login-brand .logo-dot .icon { width: 16px; height: 16px; }
.login-title {
  font-size: 20px; font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  letter-spacing: -.3px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.login-form input[type=text],
.login-form input[type=password] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
  padding: 11px 14px;
  outline: none;
  transition: border-color .15s;
}
.login-form input:focus { border-color: var(--accent); }
.login-submit {
  margin-top: 8px;
  width: 100%;
  justify-content: center;
  padding: 11px 16px;
}
.login-error {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.3);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}

/* ── TOPBAR USER ─────────────────────────────────────── */
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
}
.topbar-user .username { color: var(--text); font-weight: 600; }
.topbar-user .badge-admin {
  font-size: 9px; font-weight: 800;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.logout-btn {
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex; align-items: center;
  padding: 4px 6px;
  border-radius: 5px;
}
.logout-btn:hover { color: var(--danger); }
.logout-btn .icon { width: 14px; height: 14px; }
