/* RefReel Studio layout (extends styles.css tokens) */
.studio {
  position: relative; z-index: 1;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto 3rem;
  display: flex; flex-direction: column; gap: 1.1rem;
}
.hidden { display: none !important; }
.step-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .4rem; flex-wrap: wrap; }
.step-head h1, .step-head h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(1.9rem, 4vw, 2.5rem); letter-spacing: -0.01em; }
.step-n {
  width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; border: 1px solid var(--accent-glow);
}
.lede.small { font-size: .92rem; margin-top: 0; }

#prompt {
  width: 100%; resize: vertical; min-height: 7.5rem; margin: .4rem 0 .8rem;
  background: var(--bg-2); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 14px;
  padding: 1rem 1.1rem; font: 500 1.02rem/1.5 var(--font);
}
#prompt:focus, .scene-card textarea:focus, .scene-card input:focus, .field select:focus, .field input:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

.settings {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem 1rem;
  margin: 1.1rem 0 .4rem; align-items: end;
}
.seg { grid-column: 1 / -1; border: 0; padding: 0; margin: 0; }
.seg legend, .field { color: var(--muted); font-size: .8rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.seg-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin-top: .4rem; }
.seg-row label { cursor: pointer; }
.seg-row input { position: absolute; opacity: 0; pointer-events: none; }
.seg-card {
  display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--bg-2); text-transform: none; letter-spacing: 0;
}
.seg-card strong { display: block; color: var(--ink); font-size: .92rem; }
.seg-card em { display: block; font-style: normal; color: var(--muted); font-size: .76rem; font-weight: 500; }
.seg-row input:checked + .seg-card { border-color: var(--accent); background: var(--accent-soft); }
.seg-row input:focus-visible + .seg-card { outline: 2px solid var(--accent); }
.shape { flex: 0 0 auto; border: 2px solid var(--accent); border-radius: 4px; }
.shape.vertical { width: 14px; height: 24px; }
.shape.horizontal { width: 26px; height: 15px; }
.shape.square { width: 20px; height: 20px; }

.field { display: flex; flex-direction: column; gap: .35rem; }
.field select, .field input {
  text-transform: none; letter-spacing: 0; font: 500 .95rem var(--font); color: var(--ink);
  background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: 10px; padding: .6rem .7rem; width: 100%;
}
.toggle { display: flex; align-items: center; gap: .55rem; color: var(--ink); font-weight: 600; font-size: .92rem; padding-bottom: .6rem; }
.toggle input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

.cta-row { display: flex; gap: .7rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.cta-row .btn { min-width: 11rem; }
.llm-line { margin: .8rem 0 0; font-size: .84rem; color: var(--muted); text-align: right; }
.llm-line b { color: var(--ink); }
.llm-line code { background: var(--bg-3); padding: .1rem .35rem; border-radius: 6px; font-size: .8rem; }

/* storyboard */
.board-meta { margin-left: auto; color: var(--muted); font-size: .85rem; }
.sb-global { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; margin-bottom: .6rem; }
.grow { flex: 1 1 260px; }
.palette { display: flex; gap: .4rem; align-items: center; }
.palette label { display: flex; flex-direction: column; align-items: center; gap: .2rem; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.palette input[type=color] { width: 2.2rem; height: 2.2rem; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: none; cursor: pointer; }

.scenes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; counter-reset: sc; }
.scene-card {
  position: relative; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--bg-2);
  padding: .9rem 1rem 1rem 3.1rem;
}
.scene-card::before {
  counter-increment: sc; content: counter(sc); position: absolute; left: .9rem; top: .95rem;
  width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-3); color: var(--accent); font-weight: 700; font-size: .85rem;
}
.sc-top { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; }
.sc-top select { font: 600 .9rem var(--font); color: var(--ink); background: var(--bg-3); border: 1px solid var(--line-strong); border-radius: 8px; padding: .35rem .5rem; }
.sc-tools { margin-left: auto; display: flex; gap: .3rem; }
.icon-btn {
  min-width: 2.1rem; height: 2.1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-3);
  color: var(--muted); cursor: pointer; font: 600 .85rem var(--font); padding: 0 .5rem;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn.danger:hover { color: var(--danger); }
.sc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .55rem .7rem; }
.sc-grid .full { grid-column: 1 / -1; }
.scene-card label { display: flex; flex-direction: column; gap: .25rem; font-size: .72rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.scene-card input, .scene-card textarea, .scene-card .sc-grid select {
  font: 500 .93rem/1.4 var(--font); color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .6rem; width: 100%; text-transform: none; letter-spacing: 0; resize: vertical;
}
.scene-card .vo textarea { border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.img-pick { display: flex; gap: .4rem; flex-wrap: wrap; }
.img-pick button { width: 4.2rem; height: 4.2rem; border-radius: 8px; border: 2px solid transparent; padding: 0; overflow: hidden; background: var(--bg-3); cursor: pointer; }
.img-pick button.on { border-color: var(--accent); }
.img-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-pick .none { color: var(--muted); font-size: .72rem; }

/* result */
.result .player-wrap video { max-height: 78vh; width: auto; max-width: 100%; display: block; margin: 0 auto; border-radius: 14px; background: #000; }
.result-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; margin: 1rem 0 .4rem; }
.result-actions .btn { text-decoration: none; display: inline-flex; align-items: center; }

.footage summary { cursor: pointer; font-family: var(--display); font-size: 1.5rem; list-style-position: inside; }
.stats-inline { font-family: var(--font); font-size: .85rem; color: var(--muted); margin-left: .6rem; }
.footage[open] summary { margin-bottom: .6rem; }

@media (max-width: 640px) {
  .seg-row { grid-template-columns: 1fr; }
  .scene-card { padding-left: .9rem; padding-top: 2.8rem; }
  .cta-row .btn { flex: 1 1 100%; }
  .llm-line { text-align: left; }
}

/* ───────── full-width layout ───────── */
.top, .foot, .library-page {
  max-width: 1800px;
  width: 100%;
  padding-left: clamp(16px, 2.5vw, 40px);
  padding-right: clamp(16px, 2.5vw, 40px);
}
.studio { width: 100%; max-width: 1800px; padding: 1.2rem clamp(16px, 2.5vw, 40px) 0; margin: 0 auto 2rem; }
.empty-state { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; min-height: 420px; gap: .8rem; }
.empty-state h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 2rem; }
.empty-state p { margin: 0; color: var(--muted); max-width: 34rem; line-height: 1.5; }
.empty-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; width: 100%; max-width: 640px; margin-top: .8rem; }
.empty-steps div { border: 1px dashed var(--line-strong); border-radius: 12px; padding: .9rem .7rem; font-size: .85rem; color: var(--muted); }
.empty-steps b { display: block; color: var(--ink); font-size: .95rem; margin-bottom: .2rem; }
.studio:has(#board:not(.hidden)) #empty, .studio:has(#result:not(.hidden)) #empty { display: none; }

@media (min-width: 1200px) {
  .studio {
    display: grid;
    grid-template-columns: minmax(440px, 0.82fr) minmax(0, 1.18fr);
    gap: 1.2rem;
    align-items: start;
  }
  .studio > .brief { grid-column: 1; grid-row: 1 / span 3; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; scrollbar-width: thin; }
  .studio > #empty, .studio > #result { grid-column: 2; grid-row: 1; }
  .studio > #board { grid-column: 2; grid-row: 2; }
  .studio:not(:has(#result:not(.hidden))) > #board { grid-row: 1; }
  .studio > .footage { grid-column: 1 / -1; }
  .settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result .player-wrap video { max-height: 72vh; }
}
@media (min-width: 1600px) {
  .settings { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* library page: use the width */
.library-layout { grid-template-columns: minmax(360px, 0.8fr) minmax(0, 1.2fr); }
.gallery-grid { max-height: min(78vh, 1000px); }
@media (max-width: 900px) { .library-layout { grid-template-columns: 1fr; } }
