/* ---------------------------------------------------------
   Storyboard / Approval Tool
   An independent creative studio's production tool —
   Swiss typographic confidence, not a SaaS dashboard.
--------------------------------------------------------- */

/* Pretendard — self-hosted, no external CDN and no local() system-font
   lookup (this project's own bundled files only, always). Trimmed to the
   five weights the design actually requests anywhere in this file — 400
   (the unweighted default used almost everywhere), 500 (weight:450 on
   Page Builder BODY text resolves to the nearest available face at/above
   it per the CSS font-matching spec, which is 500 here), 600
   (.drive-folder-name), 700, and 800 (headings/CUT+PAGE numbers). woff2
   only — every browser this app targets supports it, so no woff fallback
   is carried. */
@font-face {
  font-family: 'Pretendard';
  src: url('assets/fonts/Pretendard/Pretendard-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('assets/fonts/Pretendard/Pretendard-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('assets/fonts/Pretendard/Pretendard-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('assets/fonts/Pretendard/Pretendard-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('assets/fonts/Pretendard/Pretendard-ExtraBold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #FAFAF7;
  --fg: #111111;
  --fg-secondary: #6b6a62;
  --fg-faint: #b3b1a6;
  --hairline: rgba(17, 17, 17, 0.09);
  --hairline-soft: rgba(17, 17, 17, 0.06);
  --surface-whisper: rgba(17, 17, 17, 0.035);
  --surface-hover: rgba(17, 17, 17, 0.045);

  --black: #0d0d0c;
  --white: #fbfbf9;
  --white-strong: rgba(251, 251, 249, 0.82);
  --white-dim: rgba(251, 251, 249, 0.5);
  --white-faint: rgba(251, 251, 249, 0.28);

  --accent: #1DAAFC;
  --accent-ink: #0d0d0c;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, "Pretendard", monospace;
  --sans: "Pretendard", Arial, sans-serif;
  --nav-sans: "Pretendard", Arial, sans-serif;

  --pending: #9a988e;
  --approved: #27A968;
  --revision: #E84A3A;

  --gutter: 48px;
  --gutter-sm: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  min-width: 1180px;
}

body {
  padding-bottom: 100px;
}

button {
  font-family: var(--sans);
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
  color: inherit;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

.hidden { display: none !important; }

/* ---------------- first-run onboarding (no local project yet) ---------------- */

.onboarding-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  background: var(--bg);
}

.onboarding-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 360px;
  text-align: center;
}

.onboarding-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--fg-secondary);
}

.onboarding-desc {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg-secondary);
}

.onboarding-message {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--revision);
}

/* ================= HEADER — black graphic block ================= */

#top-bar {
  background: var(--black);
  color: var(--white);
  padding: 20px var(--gutter) 24px;
  display: flex;
  flex-direction: column;
  min-height: 206px;
}

.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--white);
}

.logo-img {
  height: 32px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  display: block;
}

.wordmark-fallback.hidden {
  display: none;
}

.util-controls {
  display: flex;
  align-items: center;
  gap: 22px;
}

#project-select {
  appearance: none;
  background: transparent;
  border: none;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--white-dim);
  padding: 2px 16px 2px 0;
  max-width: 220px;
  cursor: pointer;
}

.header-top-row .text-btn {
  color: var(--white-dim);
}

.header-top-row .text-btn:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.text-btn {
  background: none;
  border: none;
  color: var(--fg-secondary);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.text-btn:hover {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.text-btn.danger {
  color: var(--revision);
}

/* PDF settings — small anchored panel, not a SaaS modal */

.pdf-settings-control {
  position: relative;
  display: inline-flex;
}

.pdf-settings-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--fg);
  z-index: 30;
  min-width: 210px;
  padding: 16px 16px 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.14);
}

.pdf-settings-panel.hidden {
  display: none;
}

.pdf-settings-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--fg);
  margin-bottom: 14px;
}

.pdf-settings-group {
  margin-bottom: 14px;
}

.pdf-settings-group-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--fg-faint);
  margin-bottom: 6px;
}

.pdf-option {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-secondary);
  padding: 3px 0;
}

.pdf-option:hover {
  color: var(--accent);
}

.pdf-option.active {
  color: var(--fg);
  font-weight: 700;
}

.pdf-settings-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}

#pdf-generate-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 8px 14px;
  transition: opacity 0.15s ease;
}

#pdf-generate-btn:hover {
  opacity: 0.82;
}

.header-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 38px 0 10px;
  min-width: 0;
}

.project-title {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(2.25rem, 5vw, 4.375rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 0.92;
  text-transform: uppercase;
  color: var(--white);
  overflow-wrap: anywhere;
}

/* section nav — independent rectangular tabs, production-interface feel */

.section-nav {
  margin-top: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.section-nav-item {
  background: transparent;
  border: 1px solid rgba(251, 251, 249, 0.22);
  border-radius: 4px;
  padding: 8px 16px;
  font-family: var(--nav-sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--white-dim);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.section-nav-item:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.section-nav-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.section-nav-item.active:hover {
  color: var(--accent-ink);
}

.header-bottom-row {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--white-faint);
  flex-wrap: wrap;
}

/* CLIENT is arbitrary user-entered text and may be Korean, unlike the
   V01/date items in this row (always Latin/numeric) — needs Pretendard. */
.header-bottom-row #meta-client-row {
  font-family: var(--sans);
}

.header-bottom-row .meta-item.mono-strong {
  color: var(--white-dim);
  font-weight: 700;
}

/* print-only compact header — built up entirely under @media print below */
.print-header {
  display: none;
}

/* ---------------- Info panel ---------------- */

.info-panel {
  overflow: hidden;
  max-height: 640px;
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
  transition: max-height 0.25s ease;
}

.info-panel.hidden {
  max-height: 0;
  border-bottom: none;
}

.info-panel-inner {
  padding: 26px var(--gutter) 30px;
  display: flex;
  align-items: flex-end;
  gap: 40px;
  flex-wrap: wrap;
}

.info-panel-inner label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--fg-secondary);
}

.info-panel-inner input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--hairline);
  font-size: 17px;
  padding: 4px 2px 8px;
  min-width: 210px;
  font-family: var(--sans);
  transition: border-color 0.15s ease;
}

.info-panel-inner input:hover {
  border-bottom-color: var(--fg-secondary);
}

.info-panel-inner input:focus {
  outline: none;
  border-bottom-color: var(--fg);
}

.info-panel-inner #field-version {
  min-width: 90px;
  font-family: var(--mono);
}

/* -- Google Drive panel, inside the project EDIT panel -- */

.drive-panel {
  padding: 20px var(--gutter) 26px;
  border-top: 1px solid var(--hairline);
}

.drive-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.drive-panel-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--fg-secondary);
}

.drive-status {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--pending);
}

.drive-status.connected {
  color: var(--approved);
}

.drive-hint {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--fg-faint);
}

.drive-panel-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.drive-folder-name {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}

.drive-files {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline-soft);
}

.drive-files-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: 10px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--fg-secondary);
}

.drive-file-row {
  font-family: var(--sans);
  color: var(--fg-secondary);
  text-decoration: none;
  padding: 2px 0;
  transition: color 0.15s ease;
}

.drive-file-row:hover {
  color: var(--accent);
}

/* ================= STORYBOARD GRID ================= */

/* Confirm progress — a thin production review-sheet line, not a widget */
.storyboard-progress {
  padding: 26px var(--gutter) 20px;
  border-bottom: 1px solid var(--hairline);
}

.storyboard-progress-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.storyboard-progress-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--fg-secondary);
}

.storyboard-progress-percent {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.storyboard-progress-track {
  width: 100%;
  height: 3px;
  background: var(--hairline);
  margin-bottom: 12px;
  overflow: hidden;
}

.storyboard-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--approved);
  transition: width 0.2s ease;
}

.storyboard-progress-counts {
  display: flex;
  align-items: center;
  gap: 22px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.storyboard-progress-counts .tag-total {
  color: var(--fg-secondary);
}

.storyboard-progress-counts .count {
  font-family: var(--mono);
  font-weight: 700;
  margin-right: 5px;
}

/* 컨펌완료/수정필요/대기중 — Korean text, needs Pretendard even though the
   row default is mono; the .count number above stays mono regardless. */
.storyboard-progress-counts .tag-approved,
.storyboard-progress-counts .tag-revision,
.storyboard-progress-counts .tag-pending {
  font-family: var(--sans);
}

.storyboard-progress-counts .tag-approved { color: var(--approved); }
.storyboard-progress-counts .tag-revision { color: var(--revision); }
.storyboard-progress-counts .tag-pending  { color: var(--pending); }

#storyboard-grid {
  padding: 34px var(--gutter) 0;
}

.sb-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gutter-sm);
  margin-bottom: 26px;
}

.sb-row + .sb-row {
  padding-top: 26px;
  border-top: 1px solid var(--hairline-soft);
}

.cut {
  display: flex;
  flex-direction: column;
}

.cut-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cut-number-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cut-tag {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-ink);
  background: var(--accent);
  padding: 2px 5px;
  transform: translateY(-3px);
}

.cut-number {
  font-family: var(--sans);
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 0.9;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* cut context menu — small, quiet, near the number */

.cut-menu-control {
  position: relative;
  align-self: flex-start;
}

.cut-menu-trigger {
  background: none;
  border: none;
  color: var(--fg-faint);
  font-size: 20px;
  line-height: 1;
  padding: 2px 4px;
  transform: translateY(2px);
  transition: color 0.15s ease;
}

.cut-menu-trigger:hover {
  color: var(--fg-secondary);
}

.cut-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid var(--fg);
  z-index: 10;
  min-width: 130px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.10);
}

.cut-menu.hidden { display: none; }

.cut-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--fg);
}

.cut-menu button:hover {
  background: var(--surface-hover);
}

.cut-menu-delete {
  color: var(--revision) !important;
}

/* status select — every option visible, current pick obvious */

.status-select {
  display: flex;
  align-items: baseline;
  gap: 13px;
  padding-bottom: 4px;
}

.status-option {
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--fg-faint);
  padding: 2px 1px;
  transition: color 0.15s ease;
}

.status-option:hover {
  color: var(--fg-secondary);
}

.status-option .dot {
  font-size: 9px;
  margin-right: 5px;
}

.status-option.active {
  font-weight: 500;
}

.status-option.active[data-value="PENDING"]  { color: var(--pending); }
.status-option.active[data-value="APPROVED"] { color: var(--approved); }
.status-option.active[data-value="REVISION"] { color: var(--revision); }

/* image frame — 16:9, the loudest thing on the page */

.image-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface-whisper);
  overflow: hidden;
  box-sizing: border-box;
}

/* confirmed cuts get a quiet blue outline — inset so it never shifts layout */
.image-frame.confirmed {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.media-slot .image-fill {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* ---- shared Media System: same fill element for every media slot ---- */
/* (Storyboard frames, Page Builder cells, Page Builder backgrounds all
   call ImageSource.mount() into a positioned container, which injects
   one of these two. Swapping media never resizes the container itself.) */

.media-image-el,
.media-video-el {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.media-image-el {
  background-repeat: no-repeat;
}

.media-video-el {
  display: block;
  object-fit: cover;
  pointer-events: none;
}

.media-slot .empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--fg-faint);
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.media-slot.empty:hover .empty-state {
  opacity: 0;
}

.media-slot.empty {
  cursor: pointer;
}

.image-controls {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  opacity: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%);
  transition: opacity 0.18s ease;
}

.media-slot.empty .image-controls {
  align-items: center;
  justify-content: center;
  background: none;
}

.media-slot:hover .image-controls {
  opacity: 1;
}

.image-controls-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
}

.image-controls button {
  background: none;
  border: none;
  color: #fff;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  padding: 4px 0;
}

.media-slot.empty .image-controls button {
  color: var(--fg-secondary);
}

.image-controls button:hover {
  color: var(--accent);
}

.media-slot.empty .image-controls button:hover {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.drive-link-input {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(250, 250, 247, 0.97);
  padding: 0 16px;
  z-index: 6;
}

.drive-link-input.active {
  display: flex;
}

.drive-link-input input {
  flex: 1;
  max-width: 340px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--fg);
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 4px;
}

.drive-link-input input:focus { outline: none; }

.drive-link-input .hint {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--sans);
  font-size: 9.5px;
  color: var(--fg-secondary);
  letter-spacing: 0.05em;
}

.drive-link-input .hint.error {
  color: var(--revision);
}

/* text fields under image — editorial text, not a form */

.cut-text {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
}

.field-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--fg-faint);
  margin-bottom: 6px;
  display: block;
}

.cut-text textarea {
  width: 100%;
  resize: none;
  overflow: hidden;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.6;
  padding: 2px 0 8px;
  min-height: 52px;
  font-family: var(--sans);
  transition: border-color 0.15s ease;
}

.cut-text textarea.dialogue {
  font-style: italic;
  color: var(--fg-secondary);
}

.cut-text textarea:focus {
  outline: none;
  border-bottom-color: var(--fg);
}

.cut-text textarea::placeholder {
  color: color-mix(in srgb, var(--fg-faint) 70%, var(--fg-secondary) 30%);
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0;
}

/* revision — a production annotation, not a form field */

.revision-note {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
}

.revision-note.hidden {
  display: none;
}

.revision-label {
  /* "수정 요청" — Korean, unlike DESCRIPTION/DIALOGUE above it, so this
     needs its own override away from .field-label's mono default. */
  font-family: var(--sans);
  color: color-mix(in srgb, var(--revision) 65%, var(--fg-faint));
}

.revision-note-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.revision-arrow {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--revision);
  line-height: 1.5;
  flex-shrink: 0;
}

.revision-note textarea {
  flex: 1;
  width: 100%;
  resize: none;
  overflow: hidden;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  font-size: 14px;
  font-style: italic;
  line-height: 1.5;
  color: var(--revision);
  min-height: 24px;
  font-family: var(--sans);
  padding-bottom: 3px;
  transition: border-color 0.15s ease;
}

.revision-note textarea:focus {
  outline: none;
  border-bottom-color: var(--revision);
}

.revision-note textarea::placeholder {
  color: color-mix(in srgb, var(--revision) 50%, var(--fg-faint));
}

/* ---------------- Empty placeholder sections ---------------- */

.section-empty {
  padding: 72px var(--gutter) 120px;
  min-height: 40vh;
}

.section-empty.hidden {
  display: none;
}

/* Section title (DIRECTOR'S TREATMENT / SYNOPSIS / CHARACTERS) — a clear
   heading, but sized to sit below the project title and above whatever the
   section actually contains, not compete with either. */
.section-empty-title {
  margin: 0;
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(40px, 3.5vw, 56px);
  letter-spacing: -0.02em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--fg);
}

/* ================= Page Builder (Treatment / Synopsis) ================= */

.page-builder-root {
  padding: 40px var(--gutter) 120px;
}

.page-builder-root.hidden {
  display: none;
}

.page-builder-root .section-empty-title {
  margin-bottom: 22px;
}

/* -- toolbar -- */
/* PAGE 01/02/03 carries the same identity as a Storyboard CUT — a small
   blue tag + a large black number — so the two sections read as one tool.
   The number is the thing to read first; the controls are secondary. */

.page-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tp-page-identity {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.tp-page-tag {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-ink);
  background: var(--accent);
  padding: 2px 5px;
  transform: translateY(-3px);
}

.tp-page-number {
  font-family: var(--sans);
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 0.9;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.tp-page-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 5px;
}

.page-toolbar-sep {
  color: var(--fg-faint);
}

.page-toolbar .text-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.page-toolbar .text-btn:disabled:hover {
  color: var(--fg-secondary);
  border-bottom-color: transparent;
}

/* -- shared small anchored panels (layout / background / cell) -- */

.builder-control {
  position: relative;
  display: inline-flex;
}

.builder-panel {
  /* Default (pre-open) position — openFloatingPanel() overrides this with
     inline position:fixed + computed top/left once the panel is shown, so
     it floats above the Cell/Page box instead of clipping against it. */
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid var(--fg);
  z-index: 200;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 14px 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
  box-sizing: border-box;
}

.builder-panel.hidden {
  display: none;
}

.builder-panel-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--fg);
  margin-bottom: 12px;
}

.builder-option-group {
  margin-bottom: 12px;
}

.builder-option-group:last-child {
  margin-bottom: 0;
}

.builder-option-group-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--fg-faint);
  margin-bottom: 5px;
}

.builder-option {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--fg-secondary);
  padding: 3px 0;
}

.builder-option:hover {
  color: var(--accent);
}

.builder-option.active {
  color: var(--fg);
  font-weight: 700;
}

/* -- Drive asset selector — browses the linked project folder in-app -- */

.drive-asset-panel {
  min-width: 300px;
  max-width: min(360px, calc(100vw - 16px));
}

.drive-asset-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.drive-asset-crumb-label {
  color: var(--fg-faint);
  font-weight: 700;
}

.drive-asset-crumb-sep {
  color: var(--fg-faint);
}

/* Folder names in the breadcrumb are arbitrary Drive folder names — often
   Korean — so these get Pretendard even though the trail's "GOOGLE DRIVE"
   label and "/" separators (unaffected, no override here) stay mono. */
button.drive-asset-crumb {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-secondary);
}

button.drive-asset-crumb:hover {
  color: var(--accent);
}

span.drive-asset-crumb.current {
  font-family: var(--sans);
  color: var(--fg);
  font-weight: 700;
}

.drive-asset-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--fg-secondary);
}

.drive-asset-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline-soft);
}

.drive-asset-row:last-child {
  border-bottom: none;
}

.drive-asset-thumb {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  background: var(--surface-whisper);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.drive-asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.drive-asset-badge {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
}

.drive-asset-info {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drive-asset-name {
  font-family: var(--sans);
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-asset-type {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
}

.drive-asset-row .text-btn {
  flex: 0 0 auto;
}

button.drive-asset-row-folder {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline-soft);
  padding: 6px 0;
  text-align: left;
  cursor: pointer;
}

button.drive-asset-row-folder:last-child {
  border-bottom: none;
}

button.drive-asset-row-folder:hover .drive-asset-name {
  color: var(--accent);
}

.drive-asset-folder-arrow {
  flex: 0 0 auto;
  color: var(--fg-faint);
  font-size: 14px;
}

.builder-color-input {
  width: 100%;
  height: 32px;
  border: 1px solid var(--hairline);
  padding: 2px;
  background: none;
  cursor: pointer;
}

.builder-image-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.builder-image-actions .text-btn {
  font-size: 10.5px;
}

/* -- layout picker -- */

.layout-count-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.layout-count-btn {
  width: 26px;
  height: 26px;
  background: none;
  border: 1px solid var(--hairline);
  font-family: var(--sans);
  font-size: 11px;
  color: var(--fg-secondary);
}

.layout-count-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.layout-preset-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.layout-preset-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  text-align: left;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--fg-secondary);
  padding: 4px;
}

.layout-preset-item:hover {
  background: var(--surface-hover);
}

.layout-preset-item.active {
  color: var(--accent);
}

.layout-thumb {
  width: 56px;
  height: 38px;
  display: grid;
  gap: 2px;
  flex-shrink: 0;
  border: 1px solid var(--hairline);
  padding: 3px;
  box-sizing: border-box;
}

.layout-thumb-cell {
  background: var(--fg-faint);
}

.layout-preset-item.active .layout-thumb-cell {
  background: var(--accent);
}

/* -- page canvas -- */

.page-canvas {
  position: relative;
  display: grid;
  gap: 3px;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--hairline);
}

.page-canvas-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.page-cell {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page-cell-menu {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.page-cell:hover .page-cell-menu {
  opacity: 1;
}

.page-cell-menu:has(.builder-panel:not(.hidden)) {
  opacity: 1;
}

.page-cell-menu-trigger {
  background: rgba(255, 255, 255, 0.85);
  border: none;
  font-size: 16px;
  line-height: 1;
  padding: 2px 7px;
  color: var(--fg-secondary);
}

.page-canvas.on-dark .page-cell-menu-trigger {
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

/* Empty cell — the entry point when neither MEDIA nor TEXT has been added
   yet. Always visible (not hover-gated), equal-weight text controls, no
   button/card chrome. */
.page-cell-empty-entry {
  width: 100%;
  flex: 1 1 0;
  min-height: 100px;
  background: var(--surface-whisper);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  box-sizing: border-box;
}

.page-cell-empty-entry button {
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--fg-secondary);
}

.page-cell-empty-entry button:hover {
  color: var(--accent);
}

/* When a cell carries both MEDIA and TEXT, stack them so each keeps its
   own box — media on top, text panel below. */
.page-cell > .page-cell-image + .page-cell-text-panel,
.page-cell > .page-cell-text-panel + .page-cell-image {
  margin-top: 3px;
}

/* MEDIA cell — same box the Storyboard frame uses, sized by the grid cell
   instead of a fixed 16:9 ratio. renderMediaFrame() fills it identically. */
.page-cell-image {
  position: relative;
  width: 100%;
  flex: 1 1 0;
  overflow: hidden;
  min-height: 80px;
  background: var(--surface-whisper);
}

/* TEXT cell — an independent panel with its own background + one or more
   stacked text blocks (TITLE/BODY/CAPTION/QUOTE), each editable in place. */
/* TEXT cell — its own background layer (image/video included, via the
   shared Media System) with a TITLE field and a BODY field on top. Either
   can be left blank; the field itself never disappears. */
.page-cell-text-panel {
  position: relative;
  width: 100%;
  flex: 1 1 0;
  min-height: 80px;
  overflow: hidden;
}

.tp-text-bg-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.tp-text-content {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.tp-text-field-label {
  display: block;
  color: currentColor;
  opacity: 0.5;
  margin-bottom: 6px;
}

.page-cell-text {
  width: 100%;
  background: none;
  border: none;
  resize: none;
  overflow: hidden;
  padding: 0;
  font-family: var(--sans);
  color: inherit;
}

.page-cell-text:focus {
  outline: none;
}

.page-cell-text::placeholder {
  color: currentColor;
  opacity: 0.32;
}

/* TITLE reads as a graphic element, not "BODY but bigger" */
.tp-text-field-title .page-cell-text {
  font-weight: 800;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.tp-text-field-body .page-cell-text {
  font-weight: 450;
  font-size: clamp(1rem, 1.3vw, 1.25rem);
  line-height: 1.6;
}

/* -- continuous vertical Treatment/Synopsis document -- */

.tp-page {
  margin-bottom: 64px;
}

.tp-page + .tp-page {
  padding-top: 48px;
  border-top: 1px solid var(--hairline);
}

.tp-add-page-row {
  display: flex;
  justify-content: center;
  padding: 12px 0 40px;
}

/* Reusable "add new content" primary action — same visual system as
   Storyboard's #add-row-btn (+ ADD 3 CUTS), for any section that needs one
   (Treatment/Synopsis's + ADD PAGE today, e.g. a future + ADD CHARACTER). */
.add-content-button {
  background: none;
  border: 1px solid var(--fg);
  border-radius: 0;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 15px 44px;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.add-content-button:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ---------------- Footer ---------------- */

#page-footer {
  display: flex;
  justify-content: center;
  padding: 24px 0 60px;
}

#add-row-btn {
  background: none;
  border: 1px solid var(--fg);
  color: var(--fg);
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 15px 44px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

#add-row-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* file input hidden helper */
.hidden-file-input {
  display: none;
}

/* ================= PRINT — clean storyboard submission doc ================= */

@media print {
  /* default page setup — overridden per export by #dynamic-print-settings,
     injected right before window.print() based on the PDF 설정 panel */
  @page {
    size: A4 landscape;
    margin: 12mm;
  }

  :root {
    --gutter: 20px;
    --gutter-sm: 10px;
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html, body {
    min-width: 0;
    background: #fff;
  }

  body {
    padding-bottom: 0;
  }

  /* orientation actually changes the storyboard layout, not just the page
     box: landscape keeps the usual 3-column grid, portrait drops to 2 so
     images and text don't get squeezed onto a narrower page */
  html.print-portrait #storyboard-grid .sb-row {
    grid-template-columns: repeat(2, 1fr);
  }

  html.print-landscape #storyboard-grid .sb-row {
    grid-template-columns: repeat(3, 1fr);
  }

  /* the big editorial header is a screen thing — print gets a compact one */
  #top-bar {
    display: none;
  }

  /* CONFIRM PROGRESS is a screen-only working aid — PDF keeps only
     each CUT's own status (border color / revision note) */
  #storyboard-progress {
    display: none;
  }

  .print-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 10px;
    margin-bottom: 18px;
    border-bottom: 1px solid #ccc;
  }

  .print-header-logo {
    height: 20px;
    width: auto;
    max-width: 140px;
    object-fit: contain;
    display: block;
  }

  .print-header-fallback.hidden {
    display: none;
  }

  .print-header-fallback {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.16em;
    color: #111;
  }

  .print-header-text {
    font-family: var(--sans);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.01em;
    color: #111;
  }

  /* interactive-only chrome never belongs on paper */
  #project-info-panel,
  #page-footer,
  .cut-menu-control,
  .image-controls,
  .drive-link-input,
  .hidden-file-input {
    display: none !important;
  }

  /* status becomes a plain readout — only the current pick shows */
  .status-select {
    gap: 0;
  }

  .status-option {
    display: none;
  }

  .status-option.active {
    display: inline-flex;
    align-items: center;
    padding: 0;
  }

  .cut-text textarea,
  .revision-note textarea {
    border-bottom: none !important;
  }

  /* keep a CUT — and its whole row — off the page break */
  .sb-row {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .cut {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
