/* === slidegen — pixel-faithful UI === */

@font-face {
  font-family: 'Manrope';
  src: url('/static/fonts/Manrope-VF.ttf') format('truetype-variations');
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  --primary: #1F3FCC;
  --primary-hover: #1933A8;
  --primary-100: #E1E9FF;
  --primary-50: #F0F4FF;
  --border: #C5D2F8;
  --border-soft: #E5E7EB;
  --text: #1F2937;
  --text-muted: #6B7280;
  --orange: #FF7F2E;
  --bg: #F7F8FB;
  --white: #FFFFFF;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Page layout === */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  background: #FAFBFD;
  border-right: 1px solid var(--border-soft);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 16px;
}
.sidebar-logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), #2A4FD9);
  border-radius: 8px;
  color: white;
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 14px;
}
.sidebar-logo-text {
  font-weight: 800;
  color: var(--primary);
  font-size: 16px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--primary-50); text-decoration: none; }
.nav-item.active {
  background: var(--primary-100);
  color: var(--primary);
  font-weight: 700;
}
.nav-divider {
  margin: 18px 0 10px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  padding: 8px 12px;
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: border-color 0.12s, color 0.12s;
}
.history-item:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}
.sidebar-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

/* === Main === */
.main {
  padding: 32px 48px;
  max-width: 1180px;
  width: 100%;
}
.pii-banner {
  background: #FFF1E5;
  border-left: 4px solid var(--orange);
  color: #7A3A00;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 24px;
  font-size: 13px;
  font-weight: 600;
}

/* === Hero === */
.hero {
  margin-bottom: 28px;
}
.hero h1 {
  font-size: 36px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.hero p {
  color: var(--text-muted);
  margin: 0;
  font-size: 16px;
}
.hero b { color: var(--primary); font-weight: 700; }

/* === Section titles === */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 32px 0 14px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  background: transparent;
  color: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 3px rgba(31, 63, 204, 0.2);
}
.btn-primary:hover { background: var(--primary-hover); color: white; }
.btn-secondary {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--primary);
  background: var(--primary-50);
  color: var(--primary);
}
.btn-large { padding: 16px 28px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
}
.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  display: inline-grid;
  place-items: center;
}
.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* Text-label variant: word labels («Обновить», «Скелет», «Пересобрать») need
   auto width — the base .icon-btn is a fixed 30px square sized for single glyphs. */
.icon-btn.has-text {
  width: auto;
  padding: 0 10px;
  white-space: nowrap;
}

/* === CTA row === */
.cta-row {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  align-items: center;
}
.cost-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* «Верстка»: advice that the planned layout may not match what the slide is
   doing. Deliberately quiet — it is a suggestion the user acts on by hand, not
   a warning and not something the app has already done. */
.layout-fit-hint {
  margin-top: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--orange, #d97706);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}

/* === Pills (filters / tones) === */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.pill {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  background: transparent;
  border: none;
  font-family: inherit;
  text-decoration: none;
}
.pill:hover:not(.active) {
  background: var(--primary-50);
  text-decoration: none;
}
.pill.active {
  background: var(--primary-100);
  color: var(--primary);
}
.tone-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.tone-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  background: var(--primary-50);
  color: var(--primary);
  border: 1.5px solid transparent;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  box-sizing: border-box;
}
.tone-pill:hover { text-decoration: none; }
.tone-pill.active {
  background: var(--primary);
  color: white;
}

/* === Cards grid === */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.card {
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
}
.card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(31, 63, 204, 0.08);
  transform: translateY(-1px);
}
.card-thumb {
  height: 160px;
  background: var(--primary-50);
  color: var(--primary);
  padding: 16px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: background 0.2s, color 0.2s;
}
.card:hover .card-thumb {
  background: linear-gradient(135deg, #1F3FCC 0%, #2A4FD9 100%);
  color: white;
}
.card-thumb-meta { font-size: 11px; opacity: 0.7; font-weight: 500; }
.card:hover .card-thumb-meta { opacity: 0.85; }
.card-thumb.light {
  background: var(--primary-50);
  color: var(--primary);
}
.card-thumb.lib-image {
  background: linear-gradient(135deg, #C5DAF7, #E1E9FF);
  color: var(--primary);
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 0;
}
.card-thumb.lib-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.card-tag {
  display: inline-block;
  padding: 3px 8px;
  background: var(--primary-100);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  width: fit-content;
  text-transform: lowercase;
}
.card-tag.orange { background: #FFF1E5; color: var(--orange); }
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.card-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.card-actions {
  padding: 0 16px 14px;
  display: flex;
  gap: 8px;
}

/* === Form card === */
.form-card {
  background: white;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid var(--border-soft);
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.form-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.form-textarea {
  width: 100%;
  min-height: 220px;
  padding: 16px 18px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  border: 1.5px solid var(--border-soft);
  border-radius: 12px;
  resize: vertical;
  line-height: 1.6;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: white;
}
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
.form-textarea::placeholder { color: #9CA3AF; }
.form-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1.5px solid var(--border-soft);
  border-radius: 10px;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
.form-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  margin: 20px 0;
  align-items: start;
}
.form-select {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1.5px solid var(--border-soft);
  border-radius: 10px;
  background: white;
  appearance: none;
  cursor: pointer;
}

/* === Stage progress === */
.stage-progress {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  padding: 6px;
  background: var(--primary-50);
  border-radius: 12px;
}
.stage-step {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
}
.stage-step:hover { text-decoration: none; }
.stage-step.disabled {
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}
.stage-step.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stage-step.done { color: var(--primary); }
.stage-step .num {
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--border-soft);
  color: white;
  text-align: center;
  line-height: 22px;
  font-size: 12px;
  vertical-align: middle;
}
.stage-step.active .num,
.stage-step.done .num { background: var(--primary); }

/* === Slide cards === */
.slide-card {
  background: white;
  border: 1.5px solid var(--border-soft);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 14px;
  transition: border-color 0.15s;
}
.slide-card:hover { border-color: var(--border); }
.slide-card.attention { border-color: var(--primary); }
.slide-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.slide-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.slide-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.slide-title-input {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  border: none;
  background: transparent;
  font-family: inherit;
  color: var(--text);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  min-width: 0;
}
.slide-title-input:focus {
  outline: none;
  border-bottom-color: var(--primary);
}
.slide-layout-chip {
  background: var(--primary-50);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.slide-bullets-edit {
  width: 100%;
  min-height: 110px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.7;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
}
.slide-bullets-edit:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
.slide-notes-edit {
  width: 100%;
  min-height: 60px;
  background: transparent;
  border: 1px dashed var(--border-soft);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  font-family: inherit;
  resize: vertical;
  margin-top: 10px;
}
.slide-notes-edit:focus {
  outline: none;
  border-color: var(--primary);
  border-style: solid;
  color: var(--text);
  font-style: normal;
}
.slide-field-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 12px;
  margin-top: 10px;
  align-items: center;
}
.slide-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: space-between;
  align-items: center;
}

/* === Library upload zone === */
.upload-zone {
  display: block;
  background: var(--primary-50);
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 24px;
  cursor: pointer;
  transition: all 0.15s;
}
.upload-zone:hover {
  background: var(--primary-100);
  border-color: var(--primary);
}
.upload-zone-icon {
  display: block;
  font-size: 32px;
  margin-bottom: 8px;
}
.upload-zone-text {
  display: block;
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
}
.upload-zone-hint {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
}
.upload-zone input[type="file"] { display: none; }
.upload-form { margin-bottom: 32px; }
.upload-form-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
  margin-top: 12px;
  align-items: end;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 13px;
}

/* === Expander === */
.expander {
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  margin-bottom: 12px;
}
.expander > summary {
  padding: 14px 18px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.expander > summary::-webkit-details-marker { display: none; }
.expander > summary::before {
  content: '▸';
  display: inline-block;
  transition: transform 0.15s;
  font-size: 12px;
}
.expander[open] > summary::before {
  transform: rotate(90deg);
}
.expander-body { padding: 0 18px 16px; }

/* === Alerts / flash === */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
}
.alert-success { background: #ECFDF5; color: #065F46; border-left: 4px solid #10B981; }
.alert-error { background: #FEF2F2; color: #7F1D1D; border-left: 4px solid #EF4444; }
.alert-info { background: var(--primary-50); color: var(--primary); border-left: 4px solid var(--primary); }

/* === Settings === */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
}
.settings-row:last-child { border-bottom: none; }
.settings-key { font-weight: 600; color: var(--text); }
.settings-val {
  font-family: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  color: var(--text-muted);
  font-size: 13px;
}

/* === Inline checkbox list === */
.checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.checkbox-list input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

/* === Utilities === */
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mb-0 { margin-bottom: 0 !important; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-24 { margin-top: 24px; }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state .icon { font-size: 32px; opacity: 0.5; margin-bottom: 8px; }

/* === Design tokens settings (FEAT-10) === */

.design-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 1100px) {
  .design-layout { grid-template-columns: 1fr; }
}

.design-section { margin-bottom: 28px; }
.design-section h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.design-section-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -6px 0 14px;
}

.token-row {
  display: grid;
  grid-template-columns: 120px 56px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.token-row:last-child { border-bottom: none; }
.token-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.token-label-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 1px;
}
.token-color {
  width: 44px; height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  cursor: pointer;
  padding: 0;
  background-clip: content-box;
}
.token-color::-webkit-color-swatch-wrapper { padding: 0; }
.token-color::-webkit-color-swatch { border: none; border-radius: 7px; }
.token-hex {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  width: 110px;
  text-transform: uppercase;
}
.token-hex:focus {
  outline: none;
  border-color: var(--primary);
}

.token-pt {
  display: grid;
  grid-template-columns: 120px 1fr 60px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.token-pt:last-child { border-bottom: none; }
.token-pt input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}
.token-pt-value {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  width: 60px;
  text-align: right;
}

.design-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.preview-card {
  position: sticky;
  top: 24px;
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
}
.preview-card-header {
  background: var(--bg);
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.preview-card-body { padding: 14px; }
.preview-card-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 14px 14px;
}

/* Slide preview — driven entirely by --p-* CSS vars set inline + via JS */
.slide-preview {
  aspect-ratio: 16 / 9;
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.slide-preview-title-band {
  background: var(--p-primary, #2354D6);
  color: white;
  padding: calc(var(--p-heading-pt, 24) * 0.4px) calc(var(--p-heading-pt, 24) * 0.5px);
  font-weight: 700;
  font-size: calc(var(--p-heading-pt, 24) * 0.85px);
  line-height: 1.2;
}
.slide-preview-body {
  flex: 1;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slide-preview-bullet {
  font-size: calc(var(--p-body-pt, 18) * 0.7px);
  color: #1F2937;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.slide-preview-bullet::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--p-primary, #2354D6);
  border-radius: 50%;
  margin-top: 7px;
  flex: 0 0 auto;
}
.slide-preview-footer {
  padding: 6px 16px;
  background: var(--p-extra3, #F4F6FA);
  font-size: calc(var(--p-note-pt, 12) * 0.7px);
  color: #6B7280;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.slide-preview-accent-pill {
  background: var(--p-accent, #FF7900);
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 9px;
}

/* === FEAT-25a: placeholder picker (Add empty cube) === */

.placeholder-picker {
  margin: 18px 0 8px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.placeholder-picker .field-label {
  margin: 0 0 10px;
  color: var(--primary);
}
.placeholder-picker select,
.placeholder-picker input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: white;
}

/* === FEAT-21: polymorphic editors (Stage 2) === */

.editor-section { margin-top: 14px; }
.editor-section:first-child { margin-top: 0; }

.field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 12px 0 4px;
}

/* Designer-reference slots: one field per place for text on the designer's
   slide. A reference can carry up to 114 of them, so the list is a scrollable
   two-column grid instead of one endless column. */
.reference-slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
  padding: 2px 6px 2px 2px;
}

.reference-slot {
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface, #FFF);
}

.reference-slot.is-filled { border-left-color: var(--brand-primary, #1F4FD8); }

.reference-slot-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.reference-slot-input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  padding: 6px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  resize: vertical;
}

.reference-slot-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* Row list (metrics rows / process steps) */
.row-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
/* Column captions, on the same track list as the rows below them. */
.row-list-head {
  display: grid;
  gap: 8px;
  align-items: end;
  padding: 0 10px 2px;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.25;
}
.row-list-head span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-list-row {
  display: grid;
  /* The real track list is written inline by editor_row_list.html — one track
     per element the row actually renders. This is only the fallback for markup
     that predates it (the structured-brief theses list, which is display:block
     anyway). A fixed four-track grid here is what pushed the 5th, 6th and 7th
     element of a row onto a second line. */
  grid-template-columns: 100px 1fr 130px 32px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.row-list-row input,
.row-list-row select {
  padding: 6px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  /* Grid items default to min-content width; without this a long value makes
     the input refuse to shrink and the whole row overflows its card. */
  min-width: 0;
  width: 100%;
}
/* Accent radio: its own narrow track, centred. */
.row-list-row .emph-pick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.row-list-row .emph-pick input {
  width: auto;
  min-width: 0;
  margin: 0;
}
.row-list-row input:focus,
.row-list-row select:focus {
  outline: none;
  border-color: var(--primary);
}

/* FEAT-01: structured-brief theses — each thesis matches «Контекст»
   (.form-textarea), full-width, with a thin semi-transparent border and a
   delete ✕ pinned to the top-right corner. Block layout (NOT the shared
   metrics grid) so the field is never squeezed into a narrow column. */
#theses-list .row-list-row {
  display: block;
  position: relative;
  background: none;
  border: none;
  padding: 0;
}
#theses-list .form-textarea {
  min-height: 84px;            /* ~2 lines by default; still drag-resizable */
  padding-right: 48px;         /* keep text clear of the ✕ button */
  border: 1px solid rgba(31, 41, 55, 0.14);  /* thin, semi-transparent */
}
#theses-list .form-textarea:focus {
  border-color: var(--primary);
}
#theses-list .icon-btn-danger {
  position: absolute;
  top: 8px;
  right: 8px;
  background: white;
}

/* Step rows (process layout) — same track list as any other row, plus a
   numbered circle in a leading track. The step fields used to be stacked in a
   nested one-column grid, which left the outer grid with more children than
   tracks and pushed the delete button onto a second line. */
.row-list-row.step-row .step-num {
  width: 30px; height: 30px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 13px;
}
/* === Drop-downs outside a row (editor_select.html, «Тип верстки») ===
   These used to borrow .slide-bullets-edit — the multi-line text style, with
   min-height: 110px — so a one-line choice was drawn three lines tall. */
.editor-select {
  display: block;
  width: 100%;
  max-width: 280px;
  min-height: 0;
  height: 34px;
  padding: 6px 10px;
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.3;
  font-family: inherit;
  color: var(--text);
}
.editor-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
/* Pickers whose option text is long (image names, эталон names). */
.editor-select-wide { max-width: none; }

/* === Field groups (editor_nested_object.html) ===
   «Было» / «Стало», the matrix quadrants, «Первая цифра» / «Вторая цифра».
   The markup has always carried these class names; the stylesheet never
   defined them, so the browser fell back to its default 2px inset border and
   a ~20-character input. */
.nested-object {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}
.nested-object > .field-label { margin-top: 0; }
.nested-object-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nested-field-row {
  display: grid;
  grid-template-columns: minmax(90px, 34%) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.nested-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.3;
}
/* One-line text fields, inside a group (.nested-field-input) and outside it
   (.editor-input, from editor_text.html). The outside ones used to borrow
   .slide-title-input — the borderless 18px bold style that belongs to the
   slide heading — so «Дельта», «Подпись / источник», «Единица измерения» and
   the matrix axes rendered as bold text with no box and did not read as
   editable at all. Same look as a cell in a row: 34px, 1px border, 6px radius. */
.editor-input,
.nested-field-input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 6px 10px;
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}
.editor-input:focus,
.nested-field-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
/* A checkbox names itself next to the box — it gets no separate label cell,
   otherwise the caption is printed twice on the same line. */
.nested-field-row-checkbox { grid-template-columns: 1fr; }
.nested-field-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.nested-field-checkbox-label input { flex-shrink: 0; margin: 0; }

/* Groups that belong together — «Было»/«Стало», the two big numbers, the four
   matrix quadrants — sit side by side instead of in one tall column.
   Exactly two columns, never auto-fit: with auto-fit a wide window fitted
   three matrix quadrants on the first row and pushed «низ-лево» up into it,
   which for a quadrant matrix reads as the wrong quadrant. Two columns give
   «Было»/«Стало» and the two big numbers a pair, and the matrix a real 2x2 in
   quadrant order. */
.nested-object-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.nested-object-pair > .editor-section { margin-top: 0; }
/* Below this the two columns are narrower than the label + input pair inside
   them, so the groups stack instead. */
@media (max-width: 900px) {
  .nested-object-pair { grid-template-columns: 1fr; }
}

.row-list-add {
  align-self: flex-start;
  margin-top: 6px;
  padding: 6px 14px;
  font-size: 12px;
  background: white;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
}
.row-list-add:hover {
  background: var(--primary-50);
  border-style: solid;
}

/* === Skeleton slot editor (editor_skeleton_slots.html) === */
.slot-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slot-row {
  border: 1px solid var(--border-soft, #e5e5ea);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-1, #fafafb);
}
.slot-row-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.slot-kind {
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid var(--border-soft, #e5e5ea);
  border-radius: 6px;
  font-family: inherit;
}
.slot-pos {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted, #888);
}
.slot-pos input {
  width: 48px;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid var(--border-soft, #e5e5ea);
  border-radius: 6px;
  font-family: inherit;
}
.slot-row-top .icon-btn-danger {
  margin-left: auto;
}
.slot-row-content {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slot-content {
  width: 100%;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border-soft, #e5e5ea);
  border-radius: 6px;
  font-family: inherit;
  box-sizing: border-box;
}

/* Tag list (section_with_tabs.tabs) */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0;
}
.tag-list-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 12px;
  background: var(--primary-50);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.tag-list-pill input[data-tag] {
  background: transparent;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  padding: 2px 4px;
  width: 110px;
  font-family: inherit;
}
.tag-list-pill input[data-tag]:focus {
  outline: none;
  background: white;
  border-radius: 4px;
}
.tag-list-pill .x-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.6;
  font-family: inherit;
}
.tag-list-pill .x-btn:hover {
  opacity: 1;
  color: #DC2626;
}

.tag-list-active-row {
  margin-top: 8px;
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.tag-list-active-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

/* Image picker preview */
.image-picker-preview {
  width: 200px;
  min-height: 90px;
  background: var(--bg);
  border: 1px dashed var(--border-soft);
  border-radius: 6px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.image-picker-preview img {
  max-width: 100%;
  max-height: 120px;
  display: block;
}

/* === Mode switcher (FEAT-19) === */

.sidebar-mode-switcher {
  margin: 0 0 14px;
  padding: 0;
}
.sidebar-mode-switcher-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 6px 4px;
}
.mode-pills {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
}
.mode-pill {
  flex: 1;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  text-align: center;
  transition: all 0.12s;
  display: block;
  width: 100%;
}
.mode-pill:hover:not(.active) {
  background: white;
  color: var(--text);
  text-decoration: none;
}
.mode-pill.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  cursor: default;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--primary-50);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 10px;
}
.mode-badge.designer {
  background: #FDF4FF;
  border-color: #E9D5FF;
  color: #6D28D9;
}
.mode-badge .mode-badge-icon { font-size: 15px; }

/* === Sessions (FEAT-17b) === */

.sidebar-active-session {
  margin: 12px 0 18px;
  padding: 12px;
  background: var(--primary-50);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.sidebar-active-session.empty {
  opacity: 0.6;
  background: var(--white);
  border-color: var(--border-soft);
}
.sidebar-active-session-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.sidebar-active-session-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sidebar-active-session-name.muted {
  color: var(--text-muted);
  font-weight: 500;
}
.sidebar-active-session-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.sidebar-active-session-link:hover { text-decoration: underline; }

.sessions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.session-card { display: flex; flex-direction: column; }
.session-card .card-thumb {
  height: auto;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.session-card.active .card-thumb {
  background: linear-gradient(135deg, var(--primary) 0%, #2A4FD9 100%);
  color: white;
}
.session-card.active:hover .card-thumb {
  background: linear-gradient(135deg, var(--primary-hover) 0%, #1F3FCC 100%);
}
.session-card.active .card-body { background: var(--primary-50); }
.session-card.active .status-badge {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.session-name-input {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 6px;
  width: 100%;
  font-family: inherit;
  margin: -2px -6px;
}
.session-name-input:hover { border-color: var(--border-soft); }
.session-name-input:focus {
  border-color: var(--primary);
  outline: none;
  background: white;
  color: var(--text);
}
.session-name-input.on-active {
  color: white;
}
.session-name-input.on-active:hover { border-color: rgba(255,255,255,0.35); }
.session-name-input.on-active:focus {
  background: white;
  color: var(--text);
}

.session-card-actions {
  padding: 0 16px 14px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.session-card-actions .btn { flex: 1; padding: 8px 12px; font-size: 13px; }

.icon-btn-danger {
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--text-muted);
  flex: 0 0 auto;
  transition: all 0.12s;
  display: grid;
  place-items: center;
  font-family: inherit;
  font-size: 13px;
  padding: 0;
}
.icon-btn-danger:hover {
  border-color: #DC2626;
  color: #DC2626;
  background: #FEE2E2;
}

/* Status badges — 5 variants. Contrast >= AA on all. */
.status-badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  text-transform: lowercase;
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex: 0 0 auto;
}
.status-badge.draft     { background: #E5E7EB; color: #4B5563; }
.status-badge.designer  { background: #EDE9FE; color: #6D28D9; }
.status-badge.vp_review { background: #FFEDD5; color: #C2410C; }
.status-badge.vp_edits  { background: #FEF3C7; color: #92400E; }
.status-badge.done      { background: #D1FAE5; color: #047857; }

/* Status select (FEAT-17c) — editable dropdown mirroring .status-badge palette */
.status-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 4px 22px 4px 9px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  border: none;
  text-transform: lowercase;
  letter-spacing: 0.01em;
  cursor: pointer;
  font-family: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='currentColor' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  max-width: 160px;
  flex: 0 0 auto;
  transition: filter 0.12s;
}
.status-select:hover { filter: brightness(0.95); }
.status-select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.status-select.draft     { background-color: #E5E7EB; color: #4B5563; }
.status-select.designer  { background-color: #EDE9FE; color: #6D28D9; }
.status-select.vp_review { background-color: #FFEDD5; color: #C2410C; }
.status-select.vp_edits  { background-color: #FEF3C7; color: #92400E; }
.status-select.done      { background-color: #D1FAE5; color: #047857; }
.session-card.active .status-select {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

/* Filter pill count badge (FEAT-17c) — small chip inside .pill */
.pill .pill-count {
  display: inline-block;
  padding: 0 6px;
  margin-left: 4px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}
.pill.active .pill-count {
  background: rgba(31, 63, 204, 0.18);
  color: var(--primary);
}

/* === Loading overlay (long generations) === */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 63, 204, 0.18);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 18px;
}
.loading-overlay[hidden] { display: none; }
.spinner {
  width: 56px;
  height: 56px;
  border: 5px solid rgba(255, 255, 255, 0.85);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-pill {
  color: var(--primary);
  font-weight: 700;
  font-size: 15px;
  background: white;
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(31, 63, 204, 0.18);
  max-width: 80%;
  text-align: center;
}
.loading-hint {
  color: var(--primary-100);
  font-weight: 500;
  font-size: 13px;
  background: rgba(31, 63, 204, 0.85);
  padding: 4px 12px;
  border-radius: 999px;
}

/* === Background generation panel (W3-К) ===
   Sits over the page while a queued job runs. Everything it shows comes from
   the server — there is no drawn progress here on purpose. */
.job-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(31, 63, 204, 0.18);
  font-size: 13px;
  color: var(--text);
}
.job-panel[hidden] { display: none; }
.job-panel.is-failed { border-left-color: #C0392B; }
.job-panel.is-interrupted { border-left-color: var(--orange); }
.job-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.job-panel-title {
  font-weight: 700;
  flex: 1;
}
.job-panel-status {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.job-panel-spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--primary-100);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.job-panel-spinner[hidden] { display: none; }
.job-track {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.job-track-step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}
.job-track-mark {
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--border-soft);
  font-size: 10px;
  line-height: 13px;
  text-align: center;
  color: var(--white);
}
.job-track-step.is-done { color: var(--text); }
.job-track-step.is-done .job-track-mark {
  background: var(--primary);
  border-color: var(--primary);
}
.job-track-step.is-active {
  color: var(--primary);
  font-weight: 700;
}
.job-track-step.is-active .job-track-mark {
  border-color: var(--primary);
  background: var(--primary-100);
  animation: job-pulse 1.4s ease-in-out infinite;
}
@keyframes job-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.job-panel-note {
  color: var(--text);
  background: var(--primary-50);
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 8px;
}
.job-panel.is-failed .job-panel-note,
.job-panel.is-interrupted .job-panel-note {
  background: #FDEDEC;
}
.job-panel-note[hidden] { display: none; }

/* === Responsiveness === */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .main { padding: 24px 20px; }
}

/* === FEAT-35: LLM Context Profile === */

.llm-ctx-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 24px;
  padding-bottom: 0;
}
.llm-ctx-tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  margin-bottom: -1px;
}
.llm-ctx-tab:hover { color: var(--primary); background: var(--primary-50); }
.llm-ctx-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.llm-ctx-tab-panel { display: none; }
.llm-ctx-tab-panel.active { display: block; }

.field-group { margin-bottom: 24px; }
.field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text);
}
.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-style: italic;
}
.field-input,
.field-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  resize: vertical;
}
.field-input:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
.field-input::placeholder,
.field-textarea::placeholder { color: #9CA3AF; }
.field-textarea { min-height: 96px; line-height: 1.5; }

.field-subsection {
  background: var(--bg);
  border-left: 3px solid var(--primary);
  padding: 16px 20px;
  border-radius: 0 6px 6px 0;
  margin-top: 8px;
}
.field-subsection-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--primary);
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.token-meter {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.token-meter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}
.token-meter-bar {
  flex: 1;
  height: 8px;
  background: var(--border-soft);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.token-meter-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}
.token-meter-fill.warn { background: var(--orange); }
.token-meter-fill.danger { background: #DC2626; }
.token-meter-value {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
  min-width: 140px;
  text-align: right;
}
.token-meter-value.danger { color: #DC2626; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
}

/* Sub-nav under sidebar Settings menu */
.sidebar-subnav {
  margin-left: 18px;
  margin-top: 4px;
  margin-bottom: 4px;
}
.sidebar-subnav .nav-item {
  font-size: 13px;
  padding: 6px 12px;
}

/* === FEAT-25b: Template library === */

.layout-chip {
  display: inline-block;
  padding: 2px 7px;
  background: var(--primary-100);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 0.04em;
  font-family: 'SF Mono', Monaco, monospace;
}

/* Native <dialog> styling for save/insert template modals.
   Kept minimal — relies on browser defaults for focus trap + backdrop. */
.slide-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(520px, 92vw);
  background: white;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
}
.slide-dialog::backdrop {
  background: rgba(20, 25, 45, 0.32);
}
.slide-dialog-inner {
  display: flex;
  flex-direction: column;
}
.slide-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-soft);
}
.slide-dialog-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.slide-dialog-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
}
.slide-dialog-close:hover {
  background: var(--bg);
  color: var(--text);
}
.slide-dialog-body {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
}
.slide-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--border-soft);
}

/* Wizard cards for .pptx import. */
.import-slide-card {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 14px;
}
.import-slide-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.import-slide-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 4px 0 12px;
}
.import-slide-bullets {
  margin: 4px 0 0;
  padding-left: 22px;
  color: var(--text);
  font-size: 13px;
}
.import-slide-bullets li {
  margin-bottom: 2px;
}
.import-slide-warning {
  font-size: 12px;
  color: #B45309;       /* matches .flash-warning amber */
  background: #FEF3C7;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 8px;
  display: none;
}

/* === FEAT-20: Handoff bar + change log === */

.handoff-bar {
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px 18px;
  margin: 14px 0 18px;
}
.handoff-bar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.handoff-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.handoff-bar-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.handoff-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.handoff-bar-terminal {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* Export group (FEAT-23) */
.handoff-bar-export {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-soft);
}
.btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}

/* Collapsible log block */
.handoff-bar-log {
  margin-top: 12px;
  border-top: 1px dashed var(--border-soft);
  padding-top: 10px;
}
.handoff-bar-log > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.handoff-bar-log > summary::-webkit-details-marker { display: none; }
.handoff-bar-log > summary::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s;
  margin-right: 4px;
}
.handoff-bar-log[open] > summary::before {
  transform: rotate(90deg);
}

.handoff-log-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.handoff-log-entry {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
}
.handoff-log-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.handoff-log-time {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.handoff-log-action {
  font-weight: 700;
  color: var(--text);
}
.handoff-log-actor {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.handoff-log-diff {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.handoff-log-diff-chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary-100);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  margin-right: 6px;
}
.handoff-log-diff-chip.plus  { background: #D1FAE5; color: #047857; }
.handoff-log-diff-chip.minus { background: #FEE2E2; color: #B91C1C; }
.handoff-log-diff-chip.change { background: #FEF3C7; color: #92400E; }
.handoff-log-top {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.handoff-log-top-item { font-style: italic; }
.handoff-log-comment {
  margin-top: 8px;
  padding: 6px 10px;
  background: white;
  border-left: 3px solid var(--primary);
  font-size: 13px;
  font-style: italic;
  color: var(--text);
}

/* Dialog-specific bits (reuse .slide-dialog* from FEAT-25b) */
.handoff-dialog-diff {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
}
.handoff-dialog-diff-list {
  margin: 4px 0 0;
  padding-left: 20px;
  font-size: 13px;
}
.handoff-dialog-diff-list li { margin-bottom: 2px; }
.handoff-dialog-diff-list li.muted { color: var(--text-muted); }
.handoff-dialog-no-diff {
  color: #B45309;
  background: #FEF3C7;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0;
}
.handoff-comment-counter {
  text-align: right;
  margin: 4px 2px 0;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
}

/* === FEAT-01: Brief input modes === */

.brief-mode-tabs {
  margin: 14px 0 18px;
}
.brief-mode-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.brief-mode-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.brief-mode-pill-form {
  margin: 0;
}
.brief-mode-pill {
  background: white;
  border: 1.5px solid var(--border-soft);
  color: var(--text);
}
.brief-mode-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Hybrid mode — split source/structured. */
.hybrid-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.hybrid-source,
.hybrid-structured {
  margin: 0;
}
.hybrid-source-textarea {
  min-height: 280px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  line-height: 1.5;
}
.hybrid-parsed-hint {
  background: var(--primary-50);
  color: var(--primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
}
@media (max-width: 900px) {
  .hybrid-split { grid-template-columns: 1fr; }
}

/* Ready Storyline — monospace textarea matches paste-list look. */
.ready-textarea {
  min-height: 260px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  line-height: 1.5;
}

/* === FEAT-04: Brief templates library === */

.templates-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 22px;
  flex-wrap: wrap;
}
.templates-tabs-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.templates-tabs .tone-pill {
  text-decoration: none;
  font-size: 13px;
  height: 36px;
  padding: 0 16px;
}

.brief-template-card .brief-template-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}
.brief-template-card .brief-template-summary {
  font-size: 11px;
  color: var(--text);
  font-weight: 600;
  opacity: 0.85;
}
.brief-template-card .brief-template-summary.muted {
  color: var(--text-muted);
  font-weight: 500;
  opacity: 0.9;
}

/* Wrapper around Hybrid right column so the brief-template loader can live
   above the form-card without breaking the 1fr/1fr grid alignment. */
.hybrid-structured-wrap {
  display: flex;
  flex-direction: column;
}

/* === FEAT-27: Grid section in /settings/design + /builder/design === */

.token-margin-row {
  display: grid;
  grid-template-columns: auto 100px 1ch auto 100px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.token-margin-row label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.token-margin-row input[type="number"] {
  width: 80px;
  padding: 6px 10px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  background: white;
}
#grid-computed-line {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'SF Mono', Monaco, monospace;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 6px;
}
#grid-computed-line.grid-warning {
  background: #FEF3C7;
  color: #B45309;
  font-weight: 600;
}

/* === FEAT-37 — Semantic edits telemetry dashboard === */

/* Stat cards row */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 8px;
}
.stat-card {
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stat-card-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-card-value.accent { color: var(--primary); }
.stat-card-value.cost { color: var(--orange); }
.stat-card-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 6px;
}
.stat-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Data table (per-stage / by-kind / recent feed) */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.data-table th.num, .data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table td.mono {
  font-family: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 13px;
  color: var(--text-muted);
}
.data-table td.cost {
  font-family: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 13px;
  color: var(--orange);
  font-weight: 600;
}
.data-table .stage-tag {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.data-table tbody tr:hover { background: var(--primary-50); }

/* Outcome badge */
.outcome-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.outcome-badge.accepted { background: #D1FAE5; color: #047857; }
.outcome-badge.undone   { background: #FEE2E2; color: #B91C1C; }
.outcome-badge.neutral  { background: #E5E7EB; color: #4B5563; }

/* Deck filter bar */
.telemetry-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.telemetry-filter label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.telemetry-filter .form-select { width: auto; min-width: 280px; }

/* Empty state */
.telemetry-empty {
  background: white;
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 56px 32px;
  text-align: center;
}
.telemetry-empty-icon { font-size: 40px; margin-bottom: 12px; }
.telemetry-empty h3 { margin: 0 0 8px; font-size: 18px; color: var(--text); }
.telemetry-empty p {
  margin: 0 auto;
  max-width: 440px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/* % accepted mini progress bar */
.accept-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border-soft);
  margin-top: 12px;
  overflow: hidden;
}
.accept-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

/* === FEAT-08: table grid editor === */
.grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 6px 0 10px;
}
.grid-toolbar .spacer { flex: 1; }
.btn-tiny {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--primary);
  font-weight: 600;
}
.btn-tiny:hover { background: var(--primary-50); }
.tbl-grid-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.tbl-grid { border-collapse: collapse; width: 100%; min-width: 480px; }
.tbl-grid th,
.tbl-grid td { border: 1px solid var(--border-soft); padding: 0; }
.tbl-grid thead th { background: var(--primary-50); position: relative; }
.tbl-grid th input,
.tbl-grid td input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}
.tbl-grid thead th input { font-weight: 700; color: var(--primary); padding-right: 20px; }
.tbl-grid input:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: var(--white); }
.tbl-grid .rownum {
  width: 30px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  background: #FBFCFE;
  font-weight: 600;
}
.tbl-grid .col-del,
.tbl-grid .cell-del {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}
.tbl-grid .cell-del { padding: 4px 8px; }
.tbl-grid thead th .col-del { position: absolute; top: 3px; right: 3px; padding: 0 2px; }
.tbl-grid .col-del:hover,
.tbl-grid .cell-del:hover { color: #DC2626; }

