:root {
  --ink: #10110e;
  --ink-soft: #191b16;
  --paper: #f2f1e9;
  --paper-muted: #d4d3ca;
  --line-dark: rgba(16, 17, 14, 0.18);
  --line-light: rgba(242, 241, 233, 0.18);
  --accent: #d9ff43;
  --danger: #ff6a54;
  --topbar-height: 76px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--ink);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 3vw, 48px);
  border-bottom: 1px solid var(--line-light);
  background: var(--ink);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--paper);
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 19px;
  font-style: italic;
}

.brand strong,
.brand small {
  display: block;
  letter-spacing: 0.12em;
}

.brand strong {
  font-size: 15px;
  line-height: 1;
}

.brand small {
  margin-top: 4px;
  color: var(--paper-muted);
  font-size: 9px;
}

.model-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--paper-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(217, 255, 67, 0.08);
}

.meta-divider {
  width: 1px;
  height: 12px;
  background: var(--line-light);
}

.studio-shell {
  display: grid;
  min-height: calc(100svh - var(--topbar-height));
  grid-template-columns: minmax(360px, 0.82fr) minmax(520px, 1.18fr);
}

.composer,
.output-stage {
  min-width: 0;
  padding: clamp(28px, 4vw, 64px);
}

.composer {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  animation: panel-enter 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.output-stage {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: panel-enter 640ms 90ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.section-index,
.eyebrow {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-index {
  color: #6f706a;
}

.composer-heading {
  margin: clamp(34px, 6vh, 72px) 0 clamp(32px, 5vh, 56px);
}

.composer-heading .eyebrow {
  color: #6f706a;
}

.composer-heading h1 {
  max-width: 560px;
  margin: 13px 0 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(52px, 6vw, 88px);
  font-weight: 400;
  letter-spacing: -0.065em;
  line-height: 0.89;
}

.composer-heading > p:last-child {
  max-width: 430px;
  margin: 0;
  color: #565750;
  font-size: 14px;
  line-height: 1.75;
}

#generate-form {
  margin-top: auto;
}

#generate-form > label {
  display: block;
  margin-bottom: 11px;
  font-size: 13px;
  font-weight: 700;
}

.prompt-field {
  position: relative;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

textarea {
  display: block;
  width: 100%;
  min-height: 168px;
  resize: vertical;
  border: 0;
  border-radius: 0;
  padding: 20px 0 35px;
  background: transparent;
  color: var(--ink);
  font-size: clamp(16px, 1.4vw, 19px);
  line-height: 1.65;
}

textarea::placeholder {
  color: #9a9a92;
}

textarea:focus {
  outline: 0;
}

.prompt-field:focus-within {
  border-color: #4e5e00;
  box-shadow: 0 1px 0 #4e5e00, 0 -1px 0 #4e5e00;
}

.char-count {
  position: absolute;
  right: 0;
  bottom: 10px;
  color: #777870;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
}

.field-help,
.field-error {
  min-height: 19px;
  margin: 10px 0 0;
  font-size: 11px;
}

.field-help {
  color: #777870;
}

.field-error {
  color: #b82d1d;
}

.field-error:empty {
  display: none;
}

.prompt-examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin: 24px 0 32px;
}

.prompt-example-guide {
  display: grid;
  width: 100%;
  gap: 3px;
  margin: 0 0 3px;
  color: #777870;
  font-family: inherit;
  letter-spacing: normal;
}

.prompt-example-guide strong {
  font-size: 13px;
}

.prompt-example-guide span {
  font-size: 11px;
  line-height: 1.5;
}

.prompt-examples button {
  border: 1px solid var(--line-dark);
  border-radius: 0;
  padding: 8px 11px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.prompt-examples button:hover {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-2px);
}

.submit-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.fixed-options {
  display: flex;
  gap: 16px;
  color: #777870;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.generate-button {
  display: inline-flex;
  min-width: 208px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border: 0;
  border-radius: 0;
  padding: 17px 18px 17px 20px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.generate-button:hover:not(:disabled) {
  background: var(--accent);
  color: var(--ink);
  transform: translateY(-3px);
}

.generate-button:hover .button-arrow {
  transform: rotate(45deg);
}

.generate-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.button-arrow {
  font-size: 18px;
  transition: transform 180ms ease;
}

.stage-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.stage-topline h2 {
  margin: 9px 0 0;
  font-size: 20px;
  letter-spacing: -0.035em;
}

.output-stage .section-index {
  color: #85867e;
}

.elapsed-time {
  color: #85867e;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.stage-canvas {
  position: relative;
  flex: 1 1 auto;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line-light);
  background-color: var(--ink-soft);
  background-image:
    linear-gradient(var(--line-light) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-light) 1px, transparent 1px);
  background-size: 64px 64px;
  isolation: isolate;
}

.stage-canvas::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: rgba(16, 17, 14, 0.56);
  content: "";
}

.idle-art {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: opacity 280ms ease, transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

.idle-art p {
  position: relative;
  z-index: 2;
  margin: 0;
  color: var(--paper);
  font-family: Georgia, serif;
  font-size: clamp(44px, 7vw, 100px);
  font-style: italic;
  letter-spacing: -0.07em;
  line-height: 0.72;
  text-align: center;
}

.target-ring {
  position: absolute;
  border: 1px solid var(--line-light);
  border-radius: 50%;
}

.target-ring-large {
  width: min(62%, 520px);
  aspect-ratio: 1;
}

.target-ring-small {
  width: min(28%, 220px);
  aspect-ratio: 1;
  border-color: rgba(217, 255, 67, 0.48);
}

.crosshair {
  position: absolute;
  display: block;
  background: var(--line-light);
}

.crosshair-x {
  width: 80%;
  height: 1px;
}

.crosshair-y {
  width: 1px;
  height: 80%;
}

.working-view {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(28px, 5vw, 64px);
  animation: content-reveal 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.queue-figure > span {
  display: block;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: clamp(96px, 15vw, 220px);
  font-style: italic;
  letter-spacing: -0.09em;
  line-height: 0.72;
}

.queue-figure small {
  color: #85867e;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.14em;
}

.working-copy {
  max-width: 520px;
}

.working-copy .eyebrow {
  color: var(--accent);
}

.working-detail-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 7px;
}

.working-detail-row .elapsed-time {
  flex: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
}

.working-copy h3,
.error-view h3 {
  margin: 12px 0 10px;
  font-size: clamp(24px, 3vw, 42px);
  letter-spacing: -0.055em;
}

.working-copy > p:last-child,
.error-view > p:not(.eyebrow) {
  margin: 0;
  color: #b3b4aa;
  font-size: 13px;
  line-height: 1.7;
}

.scan-line {
  position: absolute;
  z-index: 3;
  top: -2px;
  right: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  box-shadow: 0 0 20px rgba(217, 255, 67, 0.5);
}

.stage-canvas[data-state="submitting"] .idle-art,
.stage-canvas[data-state="queued"] .idle-art,
.stage-canvas[data-state="running"] .idle-art,
.stage-canvas[data-state="completed"] .idle-art,
.stage-canvas[data-state="error"] .idle-art {
  opacity: 0;
  transform: scale(1.08);
  pointer-events: none;
}

.stage-canvas[data-state="submitting"] .scan-line,
.stage-canvas[data-state="queued"] .scan-line,
.stage-canvas[data-state="running"] .scan-line {
  opacity: 1;
  animation: scan 2.4s ease-in-out infinite;
}

.result-view {
  position: absolute;
  z-index: 4;
  inset: 0;
  margin: 0;
  background: #090a08;
  animation: image-reveal 780ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.result-view img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.error-view {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(28px, 5vw, 64px);
  background: var(--ink-soft);
  animation: content-reveal 420ms ease both;
}

.error-view > span {
  position: absolute;
  top: 26px;
  right: 32px;
  color: var(--danger);
  font-family: Georgia, serif;
  font-size: clamp(100px, 15vw, 220px);
  font-style: italic;
  line-height: 1;
}

.error-view .eyebrow {
  color: var(--danger);
}

.error-view button,
.result-actions button,
.result-actions a {
  border: 0;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
  padding: 7px 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 11px;
  text-decoration: none;
}

.error-view button {
  align-self: flex-start;
  margin-top: 24px;
}

.queue-progress {
  margin-top: 22px;
}

.progress-track {
  height: 1px;
  background: var(--line-light);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.queue-progress ol {
  display: grid;
  margin: 11px 0 0;
  padding: 0;
  grid-template-columns: repeat(4, 1fr);
  list-style: none;
}

.queue-progress li {
  color: #62635d;
  font-size: 10px;
  transition: color 240ms ease;
}

.queue-progress li span {
  margin-right: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 8px;
}

.queue-progress li.is-active,
.queue-progress li.is-done {
  color: var(--paper);
}

.queue-progress li.is-active {
  font-weight: 750;
}

.result-actions {
  display: flex;
  min-height: 49px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 14px;
}

.result-actions p {
  max-width: 580px;
  margin: 0;
  color: #85867e;
  font-size: 10px;
  line-height: 1.6;
}

.result-copy {
  display: grid;
  max-width: 580px;
  gap: 4px;
}

.result-actions > div:last-child {
  display: flex;
  flex: none;
  gap: 16px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(20px, 3vw, 48px);
  border-top: 1px solid var(--line-light);
  color: #85867e;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.site-footer p {
  margin: 0;
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes content-reveal {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scan {
  0%,
  100% {
    top: 0;
  }
  50% {
    top: calc(100% - 2px);
  }
}

@keyframes image-reveal {
  from {
    clip-path: inset(0 0 100% 0);
    filter: saturate(0.25);
  }
  to {
    clip-path: inset(0 0 0 0);
    filter: saturate(1);
  }
}

@media (max-width: 980px) {
  .studio-shell {
    grid-template-columns: 1fr;
  }

  .composer,
  .output-stage {
    min-height: auto;
  }

  .composer-heading {
    margin-top: 38px;
  }

  .composer-heading h1 {
    font-size: clamp(58px, 13vw, 88px);
  }

  .stage-canvas {
    min-height: min(78vw, 720px);
  }
}

@media (max-width: 620px) {
  :root {
    --topbar-height: 66px;
  }

  .topbar {
    padding-inline: 18px;
  }

  .model-meta span:last-child,
  .meta-divider {
    display: none;
  }

  .composer,
  .output-stage {
    padding: 28px 18px 34px;
  }

  .composer-heading {
    margin: 42px 0 38px;
  }

  .composer-heading h1 {
    font-size: 58px;
  }

  textarea {
    min-height: 188px;
  }

  .submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .fixed-options {
    order: 2;
  }

  .generate-button {
    width: 100%;
  }

  .stage-canvas {
    min-height: 112vw;
    max-height: 620px;
  }

  .working-view,
  .error-view {
    padding: 26px;
  }

  .queue-figure > span {
    font-size: 31vw;
  }

  .result-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-footer {
    flex-direction: column;
    padding-inline: 18px;
  }
}

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