:root {
  --bg:      #F9F8F6;
  --bg-2:    #FFFFFF;
  --text:    #0F0E0C;
  --text-2:  #5C5A56;
  --text-3:  #ABAAA6;
  --accent:  #C4541C;
  --line:    rgba(0,0,0,0.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── HEADER ── */
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 48px;
  background: rgba(249,248,246,0.94);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  font-family: 'DM Mono', monospace;
  font-size: 12px; font-weight: 500; letter-spacing: 0.06em;
  background: var(--text); color: var(--bg);
  padding: 4px 10px; border-radius: 2px;
}
.logo-text {
  font-family: 'DM Mono', monospace;
  font-size: 11px; letter-spacing: 0.08em;
  color: var(--text-2);
}
.header-note {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-3);
}

/* ── MAIN ── */
main {
  padding-top: 57px; /* header height */
  min-height: 100vh;
}

/* ── STATES ── */
.state { display: none; }
.state.active { display: block; }

/* ── IDLE STATE ── */
#state-idle {
  max-width: 880px; margin: 0 auto;
  padding: 80px 48px 100px;
}
.hero-copy { margin-bottom: 56px; }
.hero-h {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 900;
  font-size: clamp(48px, 6.5vw, 88px);
  line-height: 1.0; letter-spacing: -0.03em;
  color: var(--text); margin-bottom: 24px;
}
.hero-h em { color: var(--accent); font-style: italic; }
.hero-sub {
  font-size: 16px; line-height: 1.72;
  color: var(--text-2); max-width: 520px;
}

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 1.5px dashed rgba(0,0,0,0.18);
  border-radius: 6px;
  padding: 56px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 64px;
  background: var(--bg-2);
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(196,84,28,0.03);
}
.upload-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(0,0,0,0.05);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  color: var(--text-2);
  transition: background .2s, color .2s;
}
.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon {
  background: rgba(196,84,28,0.10);
  color: var(--accent);
}
.upload-label {
  font-size: 16px; font-weight: 500; color: var(--text);
  margin-bottom: 8px;
}
.upload-sub { font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.upload-browse {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 14px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 2px;
  font-family: inherit;
}
.upload-limit {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-3);
}

/* ── FEATURES ── */
.features {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
}
.feature {
  padding: 32px 0 32px 0;
  border-right: 1px solid var(--line);
  padding-right: 32px; padding-left: 32px;
}
.feature:first-child { padding-left: 0; border-left: none; }
.feature:last-child { border-right: none; padding-right: 0; }
.feature-num {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 0.16em;
  color: var(--accent); display: block; margin-bottom: 12px;
}
.feature-text {
  font-size: 13px; line-height: 1.65; color: var(--text-2);
}
.feature-text strong { color: var(--text); font-weight: 600; display: block; margin-bottom: 4px; }

/* ── LOADING STATE ── */
#state-loading {
  display: flex; flex-direction: column;
  min-height: calc(100vh - 57px);
}

/* Scene — fixed height so copy sits in the middle, not at bottom */
.loading-scene {
  height: 58vh;
  min-height: 280px;
  max-height: 460px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* Doc slots — position the two documents */
.doc-slot {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.doc-slot-pdf       { left: 20%; }
.doc-slot-portfolio { right: 16%; }

/* PDF document */
.scene-pdf {
  width: clamp(116px, 11vw, 158px);
  background: #fff;
  border-radius: 3px;
  padding: clamp(12px, 1.2vw, 18px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.11), 0 2px 8px rgba(0,0,0,0.07);
  rotate: -3deg;
}

/* Portfolio browser frame */
.scene-portfolio {
  width: clamp(200px, 22vw, 316px);
  background: #fff;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.09), 0 2px 8px rgba(0,0,0,0.06);
  rotate: 2deg;
}

/* Doc slot labels */
.scene-label {
  font-family: 'DM Mono', monospace;
  font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-3);
}

/* ── PDF SKELETON ── */
.sdoc-name {
  font-family: 'Inter', sans-serif;
  font-size: clamp(7px, 0.65vw, 9.5px); font-weight: 700;
  color: var(--text); margin-bottom: 3px;
}
.sdoc-contacts { display: flex; gap: 4px; margin-bottom: 10px; }
.sdoc-sec      { margin-bottom: 8px; }
.sdoc-sec:last-child { margin-bottom: 0; }
.sdoc-sec-head {
  font-family: 'Inter', sans-serif;
  font-size: clamp(5px, 0.45vw, 6.5px); font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text); border-bottom: 1px solid var(--text);
  padding-bottom: 2px; margin-bottom: 5px;
}
.sdoc-lines { display: flex; flex-direction: column; gap: 2.5px; margin-bottom: 5px; }
.sdoc-pills { display: flex; flex-wrap: wrap; gap: 3px; }

/* Skeleton bars */
.skel {
  display: block; height: 5px;
  background: #D9D5CF; border-radius: 2px; flex-shrink: 0;
}
.skel.dark { background: rgba(0,0,0,0.08); }
.skel.tall { height: 10px; }
.sw-25  { width: 25%; }  .sw-30  { width: 30%; }  .sw-40  { width: 40%; }
.sw-50  { width: 50%; }  .sw-55  { width: 55%; }  .sw-60  { width: 60%; }
.sw-65  { width: 65%; }  .sw-70  { width: 70%; }  .sw-75  { width: 75%; }
.sw-80  { width: 80%; }  .sw-85  { width: 85%; }  .sw-90  { width: 90%; }
.sw-100 { width: 100%; }

.spill      { display: inline-block; height: 13px; width: 34px; background: #D9D5CF; border-radius: 6px; }
.spill.dark { background: rgba(0,0,0,0.07); }

/* ── PORTFOLIO THUMBNAIL ── */
.port-chrome {
  height: 20px; background: #F0EEEB;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  display: flex; align-items: center; gap: 4px; padding: 0 10px;
}
.chrome-dot { width: 6px; height: 6px; border-radius: 50%; }
.dot-r { background: #EDCECE; }
.dot-y { background: #EDE5CE; }
.dot-g { background: #CEEDE0; }
.chrome-addr { flex: 1; height: 8px; background: #E2DFDB; border-radius: 4px; margin: 0 8px; }

.port-body  { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.port-nav   { display: flex; gap: 8px; align-items: center; }
.port-hero  { display: flex; flex-direction: column; gap: 3px; padding-bottom: 8px; border-bottom: 1px solid rgba(0,0,0,0.06); }
.port-cols  { display: flex; gap: 6px; }
.port-sec   { flex: 1; display: flex; flex-direction: column; gap: 3px; }

.port-sec-label {
  font-family: 'Inter', sans-serif;
  font-size: 5.5px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-3);
  margin-bottom: 2px;
  transition: color 0.4s ease;
}
.port-ghost {
  display: flex; flex-direction: column; gap: 3px;
  border: 1px dashed rgba(0,0,0,0.12); border-radius: 3px; padding: 5px 7px;
  transition: border-color 0.5s ease, background 0.5s ease;
}
.port-ghost-pills { flex-direction: row; gap: 4px; align-items: center; }

/* Ghost → filled transition when card lands */
.port-sec.filled .port-sec-label { color: var(--accent); }
.port-sec.filled .port-ghost     { border-color: rgba(196,84,28,0.22); background: rgba(196,84,28,0.04); }
.port-sec.filled .skel.dark      { background: rgba(0,0,0,0.14); transition: background 0.5s; }
.port-sec.filled .spill.dark     { background: rgba(196,84,28,0.18); transition: background 0.5s; }

/* ── FLYING CARDS ── */
.fly-cards {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 10;
}
.fly-wrap { position: absolute; opacity: 0; }
.fly-card {
  width: 128px;
  background: #fff; border-radius: 3px;
  padding: 10px 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.15), 0 3px 10px rgba(0,0,0,0.09);
}
.fly-card-head {
  font-family: 'Inter', sans-serif;
  font-size: 6.5px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text);
  border-bottom: 1px solid var(--text); padding-bottom: 3px; margin-bottom: 6px;
}
.fly-lines { display: flex; flex-direction: column; gap: 3px; }
.fly-pills { display: flex; gap: 3px; flex-wrap: wrap; }

/* ── LOADING COPY (bottom) ── */
.loading-copy {
  padding: 28px 24px 44px;
  text-align: center; flex-shrink: 0;
}
.loading-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin: 0 auto 22px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-stage {
  font-family: 'Playfair Display', serif;
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.01em; color: var(--text);
  margin-bottom: 10px;
}
.loading-hint {
  font-size: 12px; color: var(--text-3);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.04em; line-height: 1.7;
}

/* ── DONE STATE ── */
#state-done { display: flex; flex-direction: column; height: calc(100vh - 57px); }
.done-header {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}
.done-check {
  width: 32px; height: 32px; border-radius: 50%;
  background: #16A34A; color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.done-title { font-size: 14px; font-weight: 600; color: var(--text); }
.done-sub { font-size: 12px; color: var(--text-3); font-family: 'DM Mono', monospace; margin-top: 2px; }
.btn-download {
  margin-left: auto;
  background: var(--text); color: var(--bg);
  border: none; cursor: pointer;
  padding: 10px 24px; border-radius: 3px;
  font-size: 13px; font-weight: 500; font-family: 'Inter', sans-serif;
  letter-spacing: 0.02em;
  transition: background .2s;
}
.btn-download:hover { background: var(--accent); }
.btn-restart {
  background: none; border: 1px solid var(--line);
  color: var(--text-2); cursor: pointer;
  padding: 10px 20px; border-radius: 3px;
  font-size: 13px; font-family: 'Inter', sans-serif;
  transition: border-color .2s, color .2s;
}
.btn-restart:hover { border-color: var(--text-2); color: var(--text); }

/* ── TAB BAR ── */
.tab-bar {
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 10px 24px;
  border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: border-color .2s, background .2s;
  white-space: nowrap; flex-shrink: 0;
  gap: 2px;
}
.tab:hover { background: rgba(0,0,0,0.03); }
.tab.active { border-bottom-color: var(--accent); }
.tab-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  font-family: 'Inter', sans-serif;
  transition: color .2s;
}
.tab.active .tab-name { color: var(--accent); }
.tab-desc {
  font-size: 10px; color: var(--text-3);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.04em;
}

.preview-wrap { flex: 1; overflow: hidden; min-height: 0; }
#preview-frame {
  width: 100%; height: 100%;
  border: none; background: white;
}

/* ── REVIEW STATE ── */
#state-review { display: flex; flex-direction: column; height: calc(100vh - 57px); overflow: hidden; }

.review-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: var(--bg); flex-shrink: 0; gap: 16px;
}
.review-title { font-size: 14px; font-weight: 600; color: var(--text); }
.review-sub   { font-size: 12px; color: var(--text-3); font-family: 'DM Mono', monospace; margin-top: 2px; }
.review-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* Edit / Preview toggle */
.review-toggle {
  display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden;
}
.review-toggle-btn {
  background: none; border: none; cursor: pointer;
  padding: 7px 16px; font-size: 12px; font-weight: 500;
  font-family: 'Inter', sans-serif; color: var(--text-2);
  transition: background .15s, color .15s;
}
.review-toggle-btn:first-child { border-right: 1px solid var(--line); }
.review-toggle-btn.active { background: var(--text); color: var(--bg); }
.review-toggle-btn:not(.active):hover { background: rgba(0,0,0,0.04); color: var(--text); }

/* Preview panel — hidden until toggled */
.review-preview-panel {
  display: none; flex-direction: column; flex: 1; overflow: hidden; min-height: 0;
}
.review-preview-panel.visible { display: flex; }
#review-preview-frame {
  width: 100%; height: 100%; border: none; background: white; flex: 1;
}

.btn-generate {
  background: var(--text); color: var(--bg);
  border: none; cursor: pointer;
  padding: 10px 24px; border-radius: 3px;
  font-size: 13px; font-weight: 500; font-family: 'Inter', sans-serif;
  letter-spacing: 0.02em; transition: background .2s;
}
.btn-generate:hover { background: var(--accent); }

.review-body {
  flex: 1; overflow-y: auto;
  padding: 40px 48px 100px;
  max-width: 900px; margin: 0 auto; width: 100%;
}

.review-section {
  margin-bottom: 44px; padding-bottom: 44px;
  border-bottom: 1px solid var(--line);
}
.review-section:last-child { border-bottom: none; }

.review-section-title {
  font-family: 'DM Mono', monospace; font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}
.review-section-note {
  font-size: 9px; color: var(--text-3); letter-spacing: 0.1em;
  background: rgba(196,84,28,0.07); padding: 2px 7px; border-radius: 2px;
}

.review-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.review-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.review-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.review-field:last-child { margin-bottom: 0; }

.review-label {
  font-size: 11px; font-weight: 500; color: var(--text-2);
  font-family: 'DM Mono', monospace; letter-spacing: 0.05em;
  display: flex; align-items: baseline; gap: 8px;
}
.review-hint {
  font-size: 10px; color: var(--text-3); letter-spacing: 0.02em;
  font-family: 'Inter', sans-serif; font-weight: 400;
}

.review-input, .review-textarea {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 4px; padding: 9px 12px;
  font-family: 'Inter', sans-serif; font-size: 13px; color: var(--text);
  transition: border-color .15s; width: 100%;
}
.review-input:focus, .review-textarea:focus {
  outline: none; border-color: var(--accent);
}
.review-textarea { resize: vertical; min-height: 72px; line-height: 1.6; }

.review-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 20px 22px; margin-bottom: 14px;
}
.review-card-label {
  font-family: 'DM Mono', monospace; font-size: 9px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 14px;
}
.review-principle-num {
  font-family: 'DM Mono', monospace; font-size: 10px;
  color: var(--accent); letter-spacing: 0.1em; margin-bottom: 10px;
}
.review-principles-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}

/* ── RATE LIMIT STATE ── */
#state-ratelimit { display: flex; justify-content: center; align-items: flex-start; min-height: calc(100vh - 57px); }
.rl-wrap {
  max-width: 560px; width: 100%;
  padding: 80px 48px 100px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
}
.rl-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 16px;
}
.rl-h {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 900; font-size: clamp(36px, 5vw, 56px);
  line-height: 1.05; letter-spacing: -0.02em;
  color: var(--text); margin-bottom: 16px;
}
.rl-sub {
  font-size: 15px; line-height: 1.7; color: var(--text-2);
  margin-bottom: 28px;
}
.rl-divider {
  width: 100%; display: flex; align-items: center; gap: 16px;
  margin: 48px 0 40px;
  color: var(--text-3);
}
.rl-divider::before, .rl-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.rl-divider span {
  font-family: 'DM Mono', monospace;
  font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase;
  white-space: nowrap;
}
.rl-game { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 24px; }
.rl-game-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3);
}
.rl-card-wrap { width: 100%; perspective: 800px; }
.rl-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 32px 36px;
  min-height: 140px; display: flex; align-items: center; justify-content: center;
  transition: transform .15s, opacity .15s;
}
.rl-card.flip { transform: rotateX(8deg) scale(0.97); opacity: 0; }
.rl-card-text {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(16px, 2.2vw, 20px); font-style: italic;
  line-height: 1.55; color: var(--text);
  text-align: center;
}
.rl-btns { display: flex; gap: 12px; }
.rl-btn {
  padding: 11px 28px; border-radius: 4px; border: 1px solid var(--line);
  font-size: 13px; font-weight: 500; font-family: 'Inter', sans-serif;
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
  background: var(--bg-2); color: var(--text);
}
.rl-btn:hover { border-color: var(--text-2); transform: translateY(-1px); }
.rl-btn:active { transform: translateY(0); }
.rl-btn-no:hover { border-color: var(--accent); color: var(--accent); }
.rl-tally {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 0.08em; color: var(--text-3);
}

/* ── ERROR TOAST ── */
.error-toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 300;
  background: var(--text); color: var(--bg);
  padding: 14px 20px 14px 20px;
  border-radius: 6px;
  display: flex; align-items: flex-start; gap: 14px;
  max-width: min(520px, calc(100vw - 40px));
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.error-toast.visible {
  opacity: 1; pointer-events: all;
  transform: translateX(-50%) translateY(0);
}
.error-toast-msg {
  font-size: 13px; line-height: 1.6; flex: 1;
  font-family: 'Inter', sans-serif;
}
.error-toast-close {
  background: none; border: none; color: rgba(255,255,255,0.5);
  cursor: pointer; font-size: 13px; flex-shrink: 0;
  padding: 0; line-height: 1;
  transition: color .15s;
}
.error-toast-close:hover { color: #fff; }

/* ── TEMPLATES SHOWCASE ── */
.tpl-section {
  margin-top: 72px;
  padding-top: 64px;
  border-top: 1px solid var(--line);
  padding-bottom: 120px;
}
.tpl-section-header { margin-bottom: 48px; }
.tpl-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px;
}
.tpl-h {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700; font-size: clamp(28px, 3.5vw, 44px);
  line-height: 1.1; letter-spacing: -0.02em;
  color: var(--text); margin-bottom: 14px;
}
.tpl-sub {
  font-size: 14px; line-height: 1.7; color: var(--text-2); max-width: 440px;
}

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.tpl-card-shell {
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-2);
  transition: box-shadow .2s, transform .2s, border-color .2s;
}
.tpl-card-shell:hover {
  box-shadow: 0 8px 32px rgba(0,0,0,0.10);
  transform: translateY(-2px);
  border-color: rgba(0,0,0,0.16);
}

.tpl-preview-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #f0efed;
  /* height set by JS */
}
.tpl-loading-bar {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
}
.tpl-loading-bar::after {
  content: '';
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.08); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
.tpl-preview-frame {
  position: absolute;
  top: 0; left: 0;
  width: 1280px;
  border: none;
  pointer-events: none;
  transform-origin: top left;
  opacity: 0;
  transition: opacity .4s;
}
.tpl-preview-frame.loaded { opacity: 1; }

.tpl-info {
  display: flex; align-items: baseline; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.tpl-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  font-family: 'Inter', sans-serif;
}
.tpl-desc {
  font-family: 'DM Mono', monospace;
  font-size: 9px; letter-spacing: 0.06em; color: var(--text-3);
}

/* ── TEMPLATE MODAL ── */
.tpl-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  background: #fff;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.tpl-modal.open { opacity: 1; pointer-events: all; }
.tpl-modal-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: var(--bg); flex-shrink: 0;
}
.tpl-modal-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  font-family: 'Inter', sans-serif;
}
.tpl-modal-desc {
  font-family: 'DM Mono', monospace;
  font-size: 10px; letter-spacing: 0.06em; color: var(--text-3);
}
.tpl-modal-close {
  margin-left: auto;
  background: none; border: 1px solid var(--line);
  color: var(--text-2); cursor: pointer;
  width: 32px; height: 32px; border-radius: 4px;
  font-size: 13px; display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.tpl-modal-close:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.tpl-modal-frame {
  flex: 1; width: 100%; border: none; background: white;
}

/* ── MOBILE ── */
@media (max-width: 768px) {
  header { padding: 14px 20px; }
  #state-idle { padding: 48px 20px 80px; }
  .features { grid-template-columns: 1fr; }
  .feature { border-right: none; border-bottom: 1px solid var(--line); padding: 24px 0; }
  .feature:last-child { border-bottom: none; }
  .tpl-grid { grid-template-columns: 1fr; }

  /* Loading scene: stack vertically */
  .loading-scene {
    height: auto;
    min-height: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 56px;
    padding: 32px 24px 24px;
  }
  .doc-slot {
    position: relative;
    top: auto; left: auto; right: auto;
    transform: none;
  }
  .doc-slot-pdf       { order: 1; }
  .doc-slot-portfolio { order: 2; }
  .loading-copy { padding-top: 40px; }
  .review-body { padding: 24px 20px 80px; }
  .review-row-3, .review-row-2, .review-principles-grid { grid-template-columns: 1fr; }
  .review-header { flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .review-actions { width: 100%; }
  .btn-generate { width: 100%; text-align: center; }
  .done-header { flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .btn-download { margin-left: 0; width: 100%; text-align: center; }
  .btn-restart { width: 100%; text-align: center; }
  .tab { padding: 10px 16px; }
  .tab-desc { display: none; }
}
