/* ── Variables ──────────────────────────────────────────────────── */
:root {
  --flame-dark:   #3f5439;
  --flame-mid:    #57705a;
  --flame-light:  #7c9473;
  --bg:           #faf7f1;
  --bg-panel:     #f2ecdf;
  --bg-card:      #ffffff;
  --bg-input:     #f5f0e6;
  --border:       #e3ddcc;
  --border-dim:   #ece5d4;
  --text:         #2b2e28;
  --text-dim:     #565b4f;
  --text-muted:   #8a8f80;
  --accent:       #57705a;
  --accent-hover: #3f5439;
  --radius:       12px;
  --radius-sm:    8px;
}

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

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────── */
#app-header {
  background: linear-gradient(135deg, var(--flame-dark) 0%, var(--flame-mid) 50%, var(--flame-light) 100%);
  border-bottom: 1px solid rgba(0,0,0,0.3);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  text-decoration: none;
}

.brand > div {
  min-width: 0;
}

.brand img {
  height: 2.5rem;
  width: 2.5rem;
  object-fit: contain;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.03em;
}

/* ── Header ad ──────────────────────────────────────────────────── */
.header-ad {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}

@media (max-width: 900px) { .header-ad { display: none; } }

/* ── Loading overlay ─────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--border);
  border-top-color: var(--flame-mid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Main ───────────────────────────────────────────────────────── */
main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ── Upload screen ──────────────────────────────────────────────── */
#upload-screen {
  max-width: 640px;
  margin: 3rem auto 0;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
  text-align: center;
}

#drop-zone:hover,
#drop-zone.dragging {
  border-color: var(--accent);
  background: rgba(87,112,90,0.08);
}

#drop-zone svg {
  width: 3.5rem;
  height: 3.5rem;
  color: var(--text-muted);
  stroke: currentColor;
}

#drop-zone .drop-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

#drop-zone .drop-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── SEO block ──────────────────────────────────────────────────── */
.seo-block { text-align: center; }

.seo-block h1 {
  font-family: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.seo-block p {
  font-size: 0.825rem;
  color: var(--text-dim);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto 1rem;
}

.format-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.format-chips span {
  font-size: 0.7rem;
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border-dim);
}

/* ── Player screen ──────────────────────────────────────────────── */
.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.player-header span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.player-header a {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
}

.player-header a:hover { color: var(--text); }

#editor-screen {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  #editor-screen { grid-template-columns: 1fr; }
}

/* ── Video ──────────────────────────────────────────────────────── */
.video-wrap {
  background: var(--bg-panel);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 16rem;
}

#video {
  width: 100%;
  max-height: 60vh;
  display: block;
  object-fit: contain;
}

/* ── Controls panel ─────────────────────────────────────────────── */
#controls-panel {
  background: #ffffff;
  border: 1px solid #e3ddcc;
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* ── Meta row ───────────────────────────────────────────────────── */
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.frame-counter {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.fps-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border-dim);
}

/* ── Ctrl sections ──────────────────────────────────────────────── */
.ctrl-section { display: flex; flex-direction: column; gap: 0.6rem; }

.ctrl-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

hr.ctrl-divider { border: none; border-top: 1px solid var(--border-dim); }

/* ── Playback buttons ───────────────────────────────────────────── */
.playback-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

/* ── Range slider ───────────────────────────────────────────────── */
input[type="range"] {
  width: 100%;
  height: 4px;
  background: var(--bg-input);
  border-radius: 999px;
  border: none;
  accent-color: var(--accent);
  padding: 0;
  cursor: pointer;
}

.range-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.range-header .range-val { color: var(--accent); font-family: monospace; }

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Format radios ──────────────────────────────────────────────── */
.format-row {
  display: flex;
  gap: 1.5rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.radio-option input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

.radio-title {
  font-size: 0.8rem;
  color: var(--text);
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.8rem;
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-dim);
}

.btn-secondary:hover { background: #ece5d4; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  box-shadow: 0 4px 20px rgba(87,112,90,0.35);
  margin-top: 0.5rem;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Ad placeholder ─────────────────────────────────────────────── */
.ad-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
}

.ad-placeholder span {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
}

/* ── Footer ─────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border-dim);
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Utility ─────────────────────────────────────────────────────── */
[hidden] { display: none !important; }

/* ── Sticky global header ─────────────────────────────────────── */
.global-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.global-header a {
  font-family: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
}

.global-header a:hover {
  color: var(--accent);
}
