:root {
  --ink: #20252b;
  --ink-soft: #53606b;
  --paper: #fffdf7;
  --canvas: #f6f1e7;
  --yellow: #f9c74f;
  --yellow-soft: #fff2bd;
  --coral: #f27668;
  --coral-dark: #cc5148;
  --blue: #4e9fcf;
  --mint: #74c6b1;
  --line: #262b30;
  --soft-line: #d9d2c4;
  --shadow: 7px 8px 0 rgba(32, 37, 43, .10);
  --radius: 22px;
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .45;
  background-image: radial-gradient(#c8bfae 1px, transparent 1px);
  background-size: 22px 22px;
}
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 4px solid rgba(78, 159, 207, .28); outline-offset: 3px;
}
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-150%); background: #fff; color: var(--ink); padding: 10px 14px; border: 2px solid var(--ink); border-radius: 10px; }
.skip-link:focus { transform: none; }

.site-header { max-width: 1400px; margin: 0 auto; padding: 22px 34px 8px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 11px; font-size: 1.12rem; font-weight: 900; letter-spacing: -.04em; }
.brand-mark { width: 36px; aspect-ratio: 1; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; rotate: -4deg; }
.brand-mark i { display: block; border: 2px solid var(--ink); border-radius: 3px; background: var(--yellow); }
.brand-mark i:nth-child(2) { background: var(--coral); }
.brand-mark i:nth-child(3) { background: var(--blue); }
.brand-mark i:nth-child(4) { background: var(--mint); }
.model-pill { display: inline-flex; gap: 7px; align-items: center; padding: 7px 12px; border: 1px solid #c9c1b4; border-radius: 999px; color: var(--ink-soft); background: rgba(255,255,255,.66); font-size: .78rem; }
.model-pill b { color: var(--ink); }

main { max-width: 1400px; margin: 0 auto; padding: 0 34px 70px; }
.hero { min-height: 310px; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); align-items: center; gap: 70px; padding: 42px 3vw 34px; }
.eyebrow { margin: 0 0 12px; font-size: .8rem; font-weight: 900; letter-spacing: .15em; color: var(--coral-dark); text-transform: uppercase; }
.hero h1 { max-width: 760px; margin: 0; font-size: clamp(3.1rem, 6.3vw, 6rem); line-height: .92; letter-spacing: -.08em; font-weight: 950; }
.hero h1 em { position: relative; z-index: 0; font-style: normal; }
.hero h1 em::after { content: ""; position: absolute; z-index: -1; left: -.02em; right: -.08em; bottom: .05em; height: .25em; background: var(--yellow); rotate: -1deg; border-radius: 3px; }
.hero-copy > p:last-child { max-width: 650px; margin: 26px 0 0; color: var(--ink-soft); font-size: 1.05rem; line-height: 1.78; word-break: keep-all; }
.hero-comic { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; rotate: 3deg; filter: drop-shadow(10px 12px 0 rgba(32,37,43,.10)); }
.hero-comic div { position: relative; aspect-ratio: 1.25; display: grid; place-items: center; border: 3px solid var(--ink); background: #fff; overflow: hidden; }
.hero-comic div::after { content: ""; position: absolute; width: 90px; height: 90px; border: 18px solid currentColor; border-radius: 50%; opacity: .12; }
.hero-comic div:nth-child(1) { color: #d59c00; background: #fff6d9; }
.hero-comic div:nth-child(2) { color: #d34d40; background: #fff0ed; }
.hero-comic div:nth-child(3) { color: #287eae; background: #eaf6fc; }
.hero-comic div:nth-child(4) { color: #23866d; background: #eaf8f4; }
.hero-comic span { position: absolute; top: 7px; left: 9px; font-size: .7rem; font-weight: 900; }
.hero-comic b { position: relative; z-index: 1; color: var(--ink); font-size: 1.1rem; }

.pipeline { list-style: none; margin: 12px 0 26px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); border: 2px solid var(--ink); border-radius: 16px; overflow: hidden; background: #fff; box-shadow: 4px 5px 0 rgba(32,37,43,.08); }
.pipeline li { min-height: 64px; position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; color: #80878d; border-right: 2px solid var(--ink); background: #fff; }
.pipeline li:last-child { border-right: 0; }
.pipeline li::after { content: ""; position: absolute; right: -9px; width: 14px; height: 14px; z-index: 2; background: inherit; border-top: 2px solid var(--ink); border-right: 2px solid var(--ink); rotate: 45deg; }
.pipeline li:last-child::after { display: none; }
.pipeline span { font-size: .68rem; font-weight: 900; }
.pipeline b { font-size: .9rem; }
.pipeline li.active, .pipeline li.done { color: var(--ink); }
.pipeline li.active { background: var(--yellow); }
.pipeline li.done { background: var(--yellow-soft); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(430px, .95fr); gap: 24px; align-items: start; }
.work-column { display: grid; gap: 22px; }
.paper-card { background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius); padding: clamp(20px, 3vw, 34px); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.section-heading p { margin: 0 0 3px; color: var(--ink-soft); font-size: .74rem; font-weight: 800; }
.section-heading h2 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.65rem); letter-spacing: -.04em; }
.heading-number { width: 48px; aspect-ratio: 1; display: grid; place-items: center; flex: none; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow); font-size: .8rem; font-weight: 950; box-shadow: 3px 3px 0 var(--ink); }
.heading-number.blue { background: #bfe6f7; }

.field { position: relative; display: grid; gap: 8px; min-width: 0; }
.field.wide { margin-bottom: 18px; }
.field > span { font-size: .86rem; font-weight: 850; }
.field small { margin-left: 5px; color: var(--coral-dark); font-size: .68rem; }
.field input, .field textarea, .field select { width: 100%; border: 1.5px solid #bcb4a8; border-radius: 12px; background: #fff; color: var(--ink); padding: 13px 14px; transition: border-color .15s, box-shadow .15s; }
.field textarea { resize: vertical; line-height: 1.55; }
.field input:hover, .field textarea:hover, .field select:hover { border-color: #7e776d; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(78,159,207,.13); outline: 0; }
.field output { position: absolute; right: 10px; bottom: 8px; padding: 2px 5px; color: #8c847a; background: rgba(255,255,255,.88); font-size: .66rem; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.privacy-note { display: flex; gap: 8px; margin: 16px 0; color: #71695f; font-size: .76rem; }
.privacy-note span { color: var(--mint); }

.primary-button, .secondary-button, .download-button { min-height: 48px; border: 2px solid var(--ink); border-radius: 12px; font-weight: 900; transition: transform .15s, box-shadow .15s, opacity .15s; }
.primary-button { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; color: var(--ink); background: var(--yellow); box-shadow: 4px 5px 0 var(--ink); }
.primary-button.coral { background: #ff9f92; }
.secondary-button { padding: 0 16px; background: #fff; box-shadow: 3px 3px 0 var(--ink); }
.download-button { display: inline-flex; align-items: center; justify-content: space-between; gap: 22px; padding: 0 17px; color: #fff; background: var(--ink); }
.primary-button:not(:disabled):hover, .secondary-button:not(:disabled):hover, .download-button:not(:disabled):hover { transform: translate(-1px, -2px); }
.primary-button:not(:disabled):active, .secondary-button:not(:disabled):active, .download-button:not(:disabled):active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
button:disabled { cursor: not-allowed; opacity: .52; box-shadow: none; }

.story-panels { display: grid; gap: 12px; }
.story-panel { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 15px; border: 1.5px solid var(--soft-line); border-radius: 15px; background: #fff; }
.story-panel > b { width: 38px; height: 38px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow-soft); font-size: .8rem; }
.story-panel-fields { display: grid; gap: 10px; }
.story-panel .mini-field { display: grid; gap: 4px; }
.story-panel .mini-field span { color: var(--ink-soft); font-size: .7rem; font-weight: 800; }
.story-panel input, .story-panel textarea { width: 100%; border: 0; border-bottom: 1px solid #d6d0c6; background: transparent; padding: 7px 2px; color: var(--ink); }
.story-panel textarea { resize: vertical; line-height: 1.45; }
.story-panel input:focus, .story-panel textarea:focus { outline: 0; border-color: var(--blue); }
.story-actions { display: grid; grid-template-columns: auto minmax(220px, 1fr); gap: 12px; margin-top: 20px; }
.cost-note { margin: 14px 0 0; color: #81786e; font-size: .7rem; text-align: right; }

.preview-sticky { position: sticky; top: 18px; }
.preview-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin: 0 4px 12px; }
.preview-head p { margin: 0 0 3px; color: var(--coral-dark); font-size: .68rem; font-weight: 950; letter-spacing: .15em; }
.preview-head h2 { margin: 0; font-size: 1.35rem; }
.save-warning { color: #776f65; font-size: .68rem; }
.comic-sheet { padding: 14px; border: 3px solid var(--ink); background: #fff; box-shadow: 10px 12px 0 rgba(32,37,43,.12); rotate: -.35deg; }
.comic-titlebar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 9px 12px; border-bottom: 3px solid var(--ink); }
.comic-titlebar h3 { margin: 0; max-width: 72%; font-size: clamp(1.12rem, 2.2vw, 1.65rem); letter-spacing: -.05em; }
.comic-titlebar span { color: #848a8f; font-size: .56rem; font-weight: 900; letter-spacing: .12em; }
.comic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; padding-top: 8px; }
.comic-panel { position: relative; overflow: hidden; aspect-ratio: 1; border: 2px solid var(--ink); background: #eef0ec; isolation: isolate; }
.comic-panel img { width: 100%; height: 100%; display: block; object-fit: cover; }
.panel-placeholder { position: absolute; inset: 0; z-index: -1; display: grid; place-items: center; color: #8b918e; background: repeating-linear-gradient(135deg, #f4f4ef 0 12px, #ecece6 12px 24px); font-size: .72rem; font-weight: 800; }
.panel-number { position: absolute; top: 7px; left: 7px; width: 25px; height: 25px; z-index: 3; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow); font-size: .65rem; font-weight: 950; }
.narration { position: absolute; z-index: 2; top: 7px; right: 7px; max-width: calc(100% - 46px); padding: 4px 7px; border: 1.5px solid var(--ink); background: #fff8d9; font-size: clamp(.52rem, 1.1vw, .7rem); font-weight: 800; }
.speech { position: absolute; z-index: 2; left: 50%; bottom: 9px; width: max-content; max-width: 88%; transform: translateX(-50%); margin: 0; padding: 7px 10px; border: 2px solid var(--ink); border-radius: 50%; background: #fff; font-size: clamp(.6rem, 1.3vw, .8rem); font-weight: 850; text-align: center; line-height: 1.25; box-shadow: 2px 2px 0 rgba(32,37,43,.2); }
.speech::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 10px; height: 10px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); background: #fff; transform: translateX(-50%) rotate(45deg); }
.panel-loading { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(255,253,247,.85); font-size: .75rem; font-weight: 900; }
.panel-loading::after { content: ""; width: 28px; height: 28px; position: absolute; border: 4px solid #ddd3c4; border-top-color: var(--coral); border-radius: 50%; animation: spin .8s linear infinite; }
.panel-loading span { margin-top: 60px; }
.comic-footer { display: flex; justify-content: space-between; padding: 10px 5px 0; color: #777e82; font-size: .58rem; }
.comic-footer b { color: var(--ink); }

.generation-status { min-height: 54px; display: flex; align-items: center; gap: 10px; margin-top: 20px; padding: 11px 13px; border: 1px solid #cec6ba; border-radius: 12px; background: rgba(255,255,255,.56); }
.status-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: #a8aca9; }
.generation-status.working .status-dot { background: var(--coral); box-shadow: 0 0 0 7px rgba(242,118,104,.13); animation: pulse 1s ease infinite; }
.generation-status.success .status-dot { background: #319276; }
.generation-status.error { color: #9e352d; border-color: #e6a69f; background: #fff1ef; }
.generation-status.error .status-dot { background: #d8493e; }
.generation-status p { margin: 0; font-size: .76rem; line-height: 1.45; }
.result-actions { display: grid; grid-template-columns: 112px 1fr auto; gap: 9px; margin-top: 12px; }
.panel-select { display: grid; grid-template-columns: 1fr; gap: 3px; }
.panel-select span { font-size: .64rem; color: var(--ink-soft); }
.panel-select select { min-height: 40px; border: 1.5px solid #bcb4a8; border-radius: 9px; background: #fff; padding: 0 8px; }
.result-actions button { min-height: 44px; font-size: .76rem; }
.site-footer { max-width: 1400px; margin: 0 auto; padding: 0 34px 34px; color: #777066; font-size: .72rem; text-align: center; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 2px rgba(242,118,104,.04); } }

@media (max-width: 1040px) {
  .hero { gap: 34px; }
  .workspace { grid-template-columns: 1fr; }
  .preview-column { grid-row: 1; }
  .preview-sticky { position: static; max-width: 680px; margin: 0 auto 12px; }
}

@media (max-width: 720px) {
  .site-header { padding: 16px 16px 4px; }
  main { padding: 0 16px 50px; }
  .hero { min-height: auto; grid-template-columns: 1fr; padding: 45px 4px 30px; }
  .hero h1 { font-size: clamp(3.2rem, 16vw, 5rem); }
  .hero-comic { display: none; }
  .pipeline li { min-height: 54px; gap: 4px; flex-direction: column; }
  .pipeline li b { font-size: .68rem; }
  .model-pill { font-size: .66rem; }
  .paper-card { border-radius: 18px; box-shadow: 5px 6px 0 rgba(32,37,43,.1); }
  .field-row { grid-template-columns: 1fr; }
  .story-actions { grid-template-columns: 1fr; }
  .story-actions .primary-button { grid-row: 1; }
  .result-actions { grid-template-columns: 92px 1fr; }
  .result-actions .download-button { grid-column: 1 / -1; }
  .save-warning { display: none; }
  .site-footer { padding-inline: 16px; }
}

@media (max-width: 440px) {
  .brand { font-size: .96rem; }
  .brand-mark { width: 30px; }
  .model-pill { padding: 6px 8px; }
  .pipeline b { display: none; }
  .pipeline li { min-height: 42px; }
  .section-heading { align-items: flex-start; }
  .heading-number { width: 42px; }
  .story-panel { grid-template-columns: 1fr; }
  .story-panel > b { width: 32px; height: 32px; }
  .comic-sheet { padding: 9px; }
  .comic-grid { gap: 4px; }
  .speech { bottom: 6px; padding: 5px 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
