/* ── Design tokens (mirrors PresynthApp.py dark palette) ───────────────── */
:root {
  --navy:       #092C61;
  --navy-hover: #0a3a7a;
  --blue:       #7297C5;
  --gold:       #D4AF37;
  --green:      #398025;
  --green-pale: #3fb950;
  --red:        #C2170A;

  --bg:         #111827;
  --surface:    #1f2937;
  --border:     #374151;
  --text:       #f9fafb;
  --label:      #9ca3af;
  --sublabel:   #6b7280;

  --header-h:   58px;
  --body-pad:   32px;
  --radius:     2px;
  --input-pad:  7px 10px;
  --font:       Arial, sans-serif;
  --mono:       Consolas, 'Courier New', monospace;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; }

/* ── Header ────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  height: var(--header-h);
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.header-accent {
  width: 4px;
  height: 100%;
  background: var(--gold);
  flex-shrink: 0;
}
.header-sep {
  width: 1px;
  height: 38px;
  background: #1E4275;
  margin: 0 12px;
  flex-shrink: 0;
}
.header-subtitle {
  font-size: 9px;
  color: var(--blue);
  white-space: nowrap;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
  padding-right: 22px;
}

/* Pricing date chip */
.pricing-block { display: flex; flex-direction: column; align-items: flex-end; }
.pricing-label {
  font-size: 7px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: .06em;
  margin-bottom: 2px;
}
.pricing-input {
  background: #0e3472;
  border: none;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  text-align: right;
  width: 96px;
  outline: none;
  font-family: var(--font);
}

/* Header logo (gold link, replaces static span) */
.header-logo {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  padding: 0 20px;
  white-space: nowrap;
  text-decoration: none;
}
.header-logo:hover { text-decoration: none; color: #e8c96c; }

/* Auth */
.auth-block { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
}
.auth-name { color: var(--text); font-size: 12px; }
.auth-sep  { color: var(--label); }
.auth-link { color: var(--blue); font-size: 11px; }
.auth-btn {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 3px;
  white-space: nowrap;
  transition: background .15s;
}
.auth-btn:hover { background: rgba(255,255,255,.14); text-decoration: none; }

/* ── Body ───────────────────────────────────────────────────────────────── */
.app-body {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px var(--body-pad) 48px;
}

/* ── Section headers ────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.section-rule {
  width: 3px;
  height: 16px;
  background: var(--gold);
  flex-shrink: 0;
}
.section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Form layout ────────────────────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field-wide { flex: 2; }

.field-label {
  font-size: 8px;
  font-weight: 700;
  color: var(--label);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.sub-label {
  font-size: 8px;
  font-weight: 400;
  color: var(--sublabel);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

.text-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-family: var(--font);
  padding: var(--input-pad);
  border-radius: var(--radius);
  outline: none;
  width: 100%;
  transition: border-color .15s;
}
.text-input:focus { border-color: var(--navy); }
.text-input[type="number"] { -moz-appearance: textfield; }
.text-input[type="number"]::-webkit-inner-spin-button,
.text-input[type="number"]::-webkit-outer-spin-button { opacity: .4; }

/* ── Period selector ────────────────────────────────────────────────────── */
.period-selector {
  display: inline-flex;
  background: var(--surface);
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius);
}
.period-btn {
  padding: 4px 14px;
  font-size: 10px;
  font-weight: 700;
  background: transparent;
  color: var(--label);
  border: none;
  border-radius: 1px;
  transition: background .12s, color .12s;
}
.period-btn:hover:not(.active) { background: var(--border); color: var(--text); }
.period-btn.active { background: var(--navy); color: #fff; }

/* ── Divider ────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0 0;
}

/* ── LBO section ────────────────────────────────────────────────────────── */
.lbo-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
}
.lbo-rule {
  width: 3px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
  transition: background .2s;
}
.lbo-rule.active { background: var(--gold); }
.lbo-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--label);
  text-transform: uppercase;
  letter-spacing: .06em;
  transition: color .2s;
}
.lbo-title.active { color: var(--blue); }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--navy); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* LBO card */
.lbo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 4px;
}
.lbo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 14px;
}
.lbo-field { display: flex; flex-direction: column; gap: 4px; }
.lbo-hint {
  font-size: 8px;
  color: var(--sublabel);
  margin-top: 10px;
  line-height: 1.5;
}

/* ── Action row ─────────────────────────────────────────────────────────── */
.action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 10px;
}
.generate-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 700;
  padding: 9px 24px;
  border-radius: var(--radius);
  transition: background .15s;
  white-space: nowrap;
}
.generate-btn:hover:not(:disabled) { background: var(--navy-hover); }
.generate-btn:disabled { opacity: .55; cursor: not-allowed; }

/* Status pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 500;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.status-idle    { background: var(--surface); color: var(--label); }
.status-idle    .status-dot { background: #4b5563; }
.status-running { background: #1e3a5f; color: var(--blue); }
.status-running .status-dot { background: var(--navy); animation: blink 1.2s ease-in-out infinite; }
.status-building{ background: #2d2410; color: var(--gold); }
.status-building .status-dot { background: var(--gold); animation: blink 1.2s ease-in-out infinite; }
.status-done    { background: #14291a; color: var(--green-pale); }
.status-done    .status-dot { background: var(--green); }
.status-error   { background: #2d1515; color: var(--red); }
.status-error   .status-dot { background: var(--red); }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.35} }

/* Ready label */
.ready-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--green-pale);
  animation: pulse-green 1.4s ease-in-out infinite;
}
@keyframes pulse-green {
  0%,100% { opacity: 1; }
  50%      { opacity: .45; }
}

/* ── Log section ────────────────────────────────────────────────────────── */
.log-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 8px 0;
  color: var(--label);
  width: 100%;
  text-align: left;
}
.log-toggle:hover { color: var(--text); }
.log-arrow { font-size: 10px; transition: transform .15s; }
.log-toggle[aria-expanded="true"] .log-arrow { transform: rotate(90deg); }

.log-panel { margin-top: 6px; }
.log-output {
  background: #0a0f1a;
  color: #E6EDF3;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.6;
  padding: 10px 14px;
  height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Preview section ────────────────────────────────────────────────────── */
.preview-section { margin-top: 4px; }

.section-header { align-items: center; }
.slide-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  width: 30px; height: 30px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.nav-btn:hover:not(:disabled) { background: var(--border); }
.nav-btn:disabled { opacity: .3; cursor: default; }
.slide-counter { font-size: 10px; color: var(--label); min-width: 50px; text-align: center; }

.slide-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-top: 10px;
  position: relative;
}
.slide-img {
  max-width: 100%;
  max-height: 500px;
  display: block;
  object-fit: contain;
}
.no-preview {
  padding: 32px;
  text-align: center;
  color: var(--label);
  font-size: 12px;
  line-height: 2;
}

/* Download row */
.download-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}
.download-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 700;
  padding: 9px 22px;
  border-radius: var(--radius);
  transition: background .15s;
  white-space: nowrap;
}
.download-btn:hover { background: var(--navy-hover); }
.freemium-note { font-size: 0.8rem; color: var(--sublabel); }

/* ── Inline session tabs (embedded in form body) ─────────────────────────── */
.session-tabs-section { margin-bottom: 6px; }

.session-tabs-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.session-count-chip {
  font-size: 9px;
  color: var(--sublabel);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 99px;
}
.session-manage-link {
  margin-left: auto;
  font-size: 10px;
  color: var(--blue);
  text-decoration: none;
}
.session-manage-link:hover { color: var(--gold); text-decoration: none; }

.session-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
  align-items: center;
}
.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--label);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  padding: 4px 6px 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.session-pill:hover:not(.active) { background: var(--border); color: var(--text); }
.session-pill.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.session-pill-date { font-size: 8px; font-weight: 400; opacity: .7; }
.session-pill-delete {
  background: none;
  border: none;
  color: inherit;
  font-size: 10px;
  opacity: .55;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  font-family: var(--font);
}
.session-pill-delete:hover { opacity: 1; }
.session-empty-tip { font-size: 10px; color: var(--sublabel); font-style: italic; }

/* ── App-level banner (replaces log for user-facing errors) ─────────────── */
.app-banner {
  display: none;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 11px;
  line-height: 1.5;
  margin-top: 12px;
}
.app-banner.visible { display: flex; }
.app-banner-error { background: #2d1515; border: 1px solid var(--red);  color: #f4a0a0; }
.app-banner-warn  { background: #2d2410; border: 1px solid var(--gold); color: #e8d5a3; }
.app-banner-info  { background: #0d1e30; border: 1px solid var(--blue); color: #a0c0e0; }
.app-banner-msg { flex: 1; }
.app-banner-close {
  background: none;
  border: none;
  color: inherit;
  opacity: .6;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
  font-family: var(--font);
}
.app-banner-close:hover { opacity: 1; }

/* ── Secondary page shared styles ───────────────────────────────────────── */
.secondary-body {
  background: #0d1b2a;
  color: #d0d8e4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}
.secondary-header {
  background: #0a1628;
  border-bottom: 2px solid var(--gold);
  padding: 0.9rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.secondary-header .logo-link {
  text-decoration: none;
  color: var(--gold);
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
}
.secondary-header .logo-link:hover { color: #e8c96c; text-decoration: none; }
.secondary-header .breadcrumb { color: #4a6a8a; font-size: 0.875rem; }
.secondary-header .hdr-right {
  margin-left: auto;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
.secondary-header .hdr-right a {
  color: #4a6a8a;
  font-size: 0.875rem;
  text-decoration: none;
}
.secondary-header .hdr-right a:hover { color: var(--gold); }

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

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --body-pad: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .lbo-grid  { grid-template-columns: repeat(2, 1fr); }
  .header-subtitle { display: none; }
  .auth-name { display: none; }
}
