/* ==========================================================================
   Shorts Studio · dicekorea.com
   유튜브 쇼츠 대본 + 7요소 AI 영상 프롬프트 빌더
   외부 CDN·폰트 의존성 없음. CSP `default-src 'self'; style-src 'self';
   script-src 'self'` 환경에서 그대로 동작합니다. (인라인 script/style 0개)
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #F4F7FC;
  --surface: #FFFFFF;
  --surface-2: #F8FAFE;
  --ink: #0F172A;
  --ink-2: #3B4A63;
  --muted: #6B7A90;
  --line: #E3E9F4;
  --line-soft: #EEF2F9;
  --brand: #2563EB;
  --brand-dark: #1D4ED8;
  --brand-soft: #EDF3FF;
  --green: #0E9F6E;
  --green-soft: #E7F8F0;
  --amber: #B45309;
  --amber-soft: #FEF5E7;
  --red: #D92D20;
  --red-soft: #FEECEB;
  --violet: #6D28D9;
  --violet-soft: #F3EEFF;
  --radius-lg: 20px;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 18px 38px -28px rgba(15, 23, 42, .45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
          "Malgun Gothic", "Noto Sans KR", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }

.skip {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip:focus { left: 16px; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; height: 64px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand__mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(150deg, #3B82F6, #1D4ED8);
  color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 6px 14px -6px rgba(37, 99, 235, .8);
  letter-spacing: -.02em;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong { font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand__text small { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }

.topbar__actions { display: flex; align-items: center; gap: 10px; }

.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: #EEF2F9; border-radius: 11px;
}
.seg button {
  border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 700; letter-spacing: .02em;
  color: var(--muted); padding: 6px 11px; border-radius: 8px;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.seg button:hover { color: var(--ink-2); }
.seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--brand);
  box-shadow: var(--shadow-sm);
}
.seg--wide { display: flex; flex-wrap: wrap; width: 100%; }
.seg--wide button { flex: 1 1 0; padding: 9px 12px; font-size: 12.5px; text-align: center; }
.seg--three button { font-size: 12px; min-width: 0; padding: 9px 8px; line-height: 1.3; flex: 1 1 calc(33.333% - 4px); }
.seg--quad button { font-size: 12px; min-width: 0; padding: 9px 6px; line-height: 1.3; flex: 1 1 calc(50% - 4px); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer;
  padding: 9px 15px; border-radius: 10px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .1s ease;
}
.btn:hover { border-color: #C8D5EC; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 8px 18px -12px rgba(37, 99, 235, .95);
}
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: #EEF2F9; color: var(--ink-2); }
.btn--sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn--lg { width: 100%; padding: 13px 20px; font-size: 15px; border-radius: 12px; }
.btn--danger { color: var(--red); border-color: #F4D3D0; background: #fff; }
.btn--danger:hover { background: var(--red-soft); border-color: #EFC4C0; }
.btn:disabled { opacity: .6; cursor: progress; }

/* ---------- hero ---------- */

.hero { padding: 44px 0 8px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .13em;
  color: var(--brand); text-transform: uppercase;
}
.eyebrow::before {
  content: ""; width: 18px; height: 2px; border-radius: 2px; background: var(--brand);
}
.hero h1 {
  margin-top: 14px;
  font-size: clamp(28px, 4.2vw, 42px);
  line-height: 1.22; letter-spacing: -.035em; font-weight: 700;
  max-width: 20em; word-break: keep-all;
}
.hero h1 em {
  font-style: normal; color: var(--brand);
  background: linear-gradient(transparent 62%, #DCE7FF 62%);
  padding: 0 2px;
}
.hero__sub { margin-top: 14px; max-width: 54em; font-size: 15px; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chips li {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px;
  box-shadow: var(--shadow-sm);
}
.chips li::before { content: "✓"; color: var(--green); font-weight: 700; font-size: 12px; }

/* ---------- studio layout ---------- */

.studio {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 30px;
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 22px;
}
.card__head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.card__num {
  flex: none; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 12.5px; font-weight: 700; margin-top: 1px;
}
.card__title { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.card__hint { margin-top: 2px; font-size: 12.5px; color: var(--muted); }

.card--form { position: relative; }

/* ---------- fields ---------- */

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field > .seg { align-self: flex-start; }

.field > label,
.field .label {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 12.5px; font-weight: 650; color: var(--ink-2);
}

input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  appearance: none; -webkit-appearance: none;
}
input[type="text"], select { height: 42px; padding-top: 0; padding-bottom: 0; }
textarea { resize: vertical; min-height: 92px; line-height: 1.55; }
input:hover, select:hover, textarea:hover { border-color: #CFD9EA; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}
input::placeholder, textarea::placeholder { color: #A6B2C4; }

.fi-note { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.fi-note strong { color: var(--ink-2); font-weight: 650; }

.is-hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.form__foot { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- examples ---------- */

.examples { display: flex; flex-direction: column; gap: 6px; }
.example {
  display: flex; align-items: center; gap: 9px; text-align: left;
  font: inherit; font-size: 12.5px; color: var(--ink-2); cursor: pointer;
  padding: 8px 11px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.example:hover { border-color: #C7D6F2; background: #fff; color: var(--ink); }
.example__num {
  flex: none; display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: 6px;
  background: #fff; border: 1px solid var(--line);
  font-size: 10.5px; font-weight: 700; color: var(--brand);
}
.example__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- pills ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.pill--green { background: var(--green-soft); color: var(--green); }
.pill--amber { background: var(--amber-soft); color: var(--amber); }
.pill--red { background: var(--red-soft); color: var(--red); }
.pill--blue { background: var(--brand-soft); color: var(--brand); }
.pill--violet { background: var(--violet-soft); color: var(--violet); }
.pill--grey { background: #EEF2F9; color: var(--muted); }
.pill__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--engine { font-size: 11.5px; padding: 5px 11px; }
.only-mobile { display: none; }
.pill--engine.is-ai { background: var(--green-soft); color: var(--green); }
.pill--engine.is-template { background: var(--brand-soft); color: var(--brand); }
.pill--engine.is-busy { background: var(--amber-soft); color: var(--amber); }

/* ---------- sections ---------- */

.section { margin-top: 36px; }
.section__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 14px;
}
.section__head > div:first-child { flex: 1 1 380px; min-width: 0; }
.section__title { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.section__desc { margin-top: 3px; font-size: 13px; color: var(--muted); }
.result__note { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }

/* ---------- result ---------- */

.result { min-width: 0; }
.result__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 12px;
}

.stack { display: flex; flex-direction: column; gap: 14px; }

.block { padding: 20px; }
.block__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.block__title { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }

.out-title {
  font-size: 17px; font-weight: 700; letter-spacing: -.015em; line-height: 1.4;
  color: var(--ink); margin-bottom: 10px; word-break: keep-all;
}

.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.tags li {
  font-size: 12px; font-weight: 650; color: var(--brand-dark);
  background: var(--brand-soft); border: 1px solid #DCE7FF;
  border-radius: 999px; padding: 5px 11px;
}

/* hooks */

.hooks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.hook {
  display: flex; flex-direction: column; gap: 8px;
  padding: 13px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.hook.is-active { border-color: #BFD3FF; background: #F6FAFF; box-shadow: 0 0 0 3px rgba(37, 99, 235, .08); }
.hook__top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.hook__kind { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--violet); }
.hook__sec { font-size: 10.5px; font-weight: 700; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; }
.hook__text { font-size: 13.5px; font-weight: 650; line-height: 1.5; color: var(--ink); flex: 1 1 auto; word-break: keep-all; }
.hook__actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* toolbar */

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 4px 2px;
}

/* scenes */

.scenes { display: flex; flex-direction: column; gap: 12px; }

.scene { padding: 0; overflow: hidden; }
.scene__head {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 13px 18px; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #FBFCFE, #FFFFFF);
}
.scene__num {
  flex: none; display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 700;
}
.scene__time {
  font-size: 12.5px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
  background: var(--brand-soft); border-radius: 7px; padding: 3px 9px;
}
.scene__func {
  font-size: 11px; font-weight: 700; color: var(--violet);
  background: var(--violet-soft); border-radius: 999px; padding: 3px 9px;
}
.scene__dur { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scene__head .spacer { flex: 1 1 auto; }

.scene__body { padding: 15px 18px 18px; display: flex; flex-direction: column; gap: 14px; }

.scene__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sc {
  display: flex; flex-direction: column; gap: 4px;
  padding: 11px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.sc__k { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sc__v { font-size: 13px; line-height: 1.55; color: var(--ink-2); word-break: keep-all; }
.sc--narration .sc__v { color: var(--ink); font-weight: 600; }

.elchips { display: flex; flex-wrap: wrap; gap: 6px; }
.elchips li {
  display: inline-flex; align-items: baseline; gap: 6px; max-width: 100%;
  font-size: 11.5px; padding: 5px 9px; border-radius: 9px;
  background: #fff; border: 1px solid var(--line);
}
.elchips__k { font-weight: 800; font-size: 10px; letter-spacing: .04em; color: var(--brand); text-transform: uppercase; white-space: nowrap; }
.elchips__v { color: var(--ink-2); word-break: break-word; }

.prompt {
  border-radius: 14px; overflow: hidden;
  border: 1px solid #16233C; background: #0F172A;
}
.prompt__head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 9px 13px; background: #16233C; border-bottom: 1px solid #223354;
}
.prompt__label { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: #A9BEE0; text-transform: uppercase; }
.prompt__actions { display: flex; gap: 6px; }
.prompt__actions .btn {
  background: #223354; border-color: #2E4166; color: #D7E1F5; font-size: 11.5px; padding: 4px 9px;
}
.prompt__actions .btn:hover { background: #2C3F63; color: #fff; }
.prompt__body {
  margin: 0; padding: 13px 15px;
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  color: #D7E1F5; white-space: pre-wrap; word-break: break-word;
}
.prompt__summary {
  padding: 10px 15px 13px; font-size: 12px; line-height: 1.6;
  color: #9DB1D4; border-top: 1px dashed #223354;
}
.prompt__summary strong { color: #C9D8F2; font-weight: 700; }

.result__foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 2px 2px 0;
}

.empty {
  padding: 34px 20px; text-align: center; color: var(--muted); font-size: 13px;
  border: 1px dashed var(--line); border-radius: var(--radius-lg); background: var(--surface-2);
}
.empty strong { display: block; color: var(--ink-2); font-size: 13.5px; margin-bottom: 4px; }

/* ---------- history ---------- */

.saves { margin-top: 14px; }
.history { display: flex; flex-direction: column; gap: 10px; }
.history__item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.history__main { min-width: 0; flex: 1 1 auto; }
.history__title {
  font-size: 13.5px; font-weight: 650; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history__meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 4px; font-size: 11.5px; color: var(--muted);
}
.history__meta .pill { font-size: 10.5px; padding: 2px 8px; }
.history__actions { display: flex; gap: 6px; flex: none; }

/* ---------- footer ---------- */

.foot {
  margin: 40px 0 0; padding: 24px 0 46px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px; line-height: 1.7;
}
.foot p + p { margin-top: 6px; }
.foot strong { color: var(--ink-2); font-weight: 650; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  background: #0F172A; color: #fff; font-size: 13px; font-weight: 600;
  padding: 11px 18px; border-radius: 12px; z-index: 80;
  box-shadow: 0 18px 34px -18px rgba(15, 23, 42, .8);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  max-width: min(92vw, 520px); text-align: center;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

.clip-helper { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* ---------- responsive ---------- */

@media (max-width: 1080px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .result__head { margin-top: 6px; }
  .hooks { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .scene__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .card { padding: 18px; border-radius: 16px; }
  .fields { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .topbar__inner { height: 58px; }
  .brand__text small { display: none; }
  .pill--engine #modePillText { display: none; }
  .pill--engine .only-mobile { display: inline; }
  .hero { padding-top: 30px; }
  .hero h1 { font-size: 25px; }
  .eyebrow { font-size: 10.5px; letter-spacing: .08em; }
  .hero__sub { font-size: 14px; }
  .section { margin-top: 26px; }
  .btn { padding: 8px 12px; font-size: 13px; }
  .btn--lg { padding: 12px 16px; }
  .brand__mark { width: 30px; height: 30px; border-radius: 10px; font-size: 14px; }
  .brand__text strong { font-size: 14px; }
  .seg button { padding: 6px 9px; }
  .seg--quad, .seg--three { flex-wrap: wrap; }
  .seg--quad button, .seg--three button { flex: 1 1 45%; text-align: center; padding: 9px 8px; font-size: 12px; }
  .scene__grid { grid-template-columns: minmax(0, 1fr); }
  .scene__head { padding: 12px 14px; }
  .scene__body { padding: 13px 14px 16px; }
  .block { padding: 16px; }
  .out-title { font-size: 15.5px; }
  .prompt__body { font-size: 11.5px; }
  .history__item { align-items: flex-start; flex-direction: column; gap: 10px; }
  .history__actions { width: 100%; justify-content: flex-end; }
}

@media (max-width: 420px) {
  .topbar__actions .btn--ghost { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .topbar, .toast, .btn, .chips, .examples, .toolbar { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  .prompt { background: #fff; border-color: #ccc; }
  .prompt__body, .prompt__summary { color: #000; }
  .prompt__head { background: #f4f4f4; }
  .prompt__label { color: #333; }
}
