@font-face {
  font-family: Newsreader;
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url('/assets/fonts/newsreader-normal.woff2') format('woff2');
}

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/assets/fonts/inter-normal.woff2') format('woff2');
}

:root {
  --paper: #f6f3ec;
  --paper-deep: #ece6da;
  --surface: #fcfaf5;
  --ink: #26231f;
  --muted: #6c655d;
  --rule: #d4ccbe;
  --accent: #7a2828;
  --accent-hover: #5f1e1e;
  --night: #14171a;
  --night-soft: #21252a;
  --green: #2f7655;
  --blue: #356b88;
  --amber: #94621f;
  --red: #a13c35;
  --serif: Newsreader, 'Iowan Old Style', Georgia, serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea { font: inherit; }

button,
textarea,
input { color: inherit; }

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

a { color: inherit; }

[hidden] { display: none !important; }

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

.skip-link {
  position: fixed;
  top: -80px;
  left: 16px;
  z-index: 20;
  padding: 9px 14px;
  background: var(--ink);
  color: var(--paper);
}

.skip-link:focus { top: 12px; }

.app-header {
  border-bottom: 1px solid var(--rule);
  background: rgba(246, 243, 236, 0.96);
}

.app-header__inner {
  display: flex;
  width: min(100%, 1320px);
  min-height: 72px;
  align-items: center;
  gap: 18px;
  margin: 0 auto;
  padding: 11px clamp(18px, 3vw, 42px);
}

.back-link {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.back-link:hover { color: var(--accent); }

.back-link span { margin-right: 5px; }

.header-rule {
  width: 1px;
  height: 30px;
  flex: 0 0 auto;
  background: var(--rule);
}

.identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.model-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  font: 600 11px/1 var(--mono);
}

.identity h1 {
  margin: 0;
  font: 400 22px/1.1 var(--serif);
}

.identity p {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--muted);
  font: 9px/1.4 var(--mono);
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.connection {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  color: var(--muted);
  font: 10px/1.4 var(--mono);
  text-transform: uppercase;
  white-space: nowrap;
}

.connection__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.connection[data-connection='ready'] { color: var(--green); }
.connection[data-connection='ready'] .connection__dot { background: var(--green); }
.connection[data-connection='busy'] { color: var(--amber); }
.connection[data-connection='busy'] .connection__dot { background: var(--amber); }
.connection[data-connection='offline'] { color: var(--red); }
.connection[data-connection='offline'] .connection__dot { background: var(--red); }

.workspace {
  display: grid;
  width: min(100%, 1320px);
  min-height: calc(100vh - 121px);
  grid-template-columns: minmax(330px, 0.43fr) minmax(480px, 0.78fr);
  margin: 0 auto;
  padding: 0 clamp(18px, 3vw, 42px);
}

.composer,
.output {
  min-width: 0;
  padding-block: clamp(30px, 5vw, 66px);
}

.composer {
  padding-right: clamp(26px, 4vw, 56px);
  border-right: 1px solid var(--rule);
}

.output { padding-left: clamp(26px, 4vw, 56px); }

.section-heading { margin-bottom: 28px; }

.section-heading--output {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font: 9px/1.5 var(--mono);
  text-transform: uppercase;
}

.section-heading h2 {
  margin: 0;
  font: 400 46px/1.08 var(--serif);
}

.section-copy {
  max-width: 390px;
  margin: 13px 0 0;
  color: var(--muted);
  font: 18px/1.45 var(--serif);
}

.api-label {
  overflow: hidden;
  max-width: 190px;
  color: var(--muted);
  font: 9px/1.5 var(--mono);
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.field { margin-bottom: 22px; }

.field > label,
.field__label-row label {
  color: var(--muted);
  font: 10px/1.5 var(--mono);
  text-transform: uppercase;
}

.field__label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.character-count {
  color: var(--muted);
  font: 9px/1.5 var(--mono);
}

textarea,
input[type='number'] {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--surface);
}

textarea {
  display: block;
  min-height: 210px;
  padding: 15px 16px;
  resize: vertical;
  font-size: 15px;
  line-height: 1.65;
}

textarea::placeholder { color: #928a80; }

textarea:focus,
input[type='number']:focus {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.seed-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 8px;
}

input[type='number'] {
  min-width: 0;
  height: 44px;
  padding: 9px 12px;
  border-right: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.icon-command,
.button {
  min-height: 42px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--surface);
  cursor: pointer;
}

.icon-command {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 11px;
}

.icon-command span:first-child { color: var(--accent); font-size: 17px; }

.icon-command:hover,
.button--quiet:hover { border-color: var(--accent); color: var(--accent); }

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  min-width: 96px;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 15px;
  font-size: 12px;
  text-decoration: none;
}

.button--primary {
  min-width: 176px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper);
}

.button--primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button--small {
  min-width: 0;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 10px;
  white-space: nowrap;
}

.button:disabled,
.icon-command:disabled,
textarea:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.privacy-note {
  display: flex;
  gap: 9px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.privacy-note span { color: var(--green); }

.service-notice {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 21px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--blue);
  background: var(--surface);
}

.service-notice[data-tone='error'] { border-left-color: var(--red); }
.service-notice[data-tone='busy'] { border-left-color: var(--amber); }
.service-notice[data-tone='success'] { border-left-color: var(--green); }

.service-notice strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.service-notice p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.run-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-block: 1px solid var(--rule);
}

.run-facts div { padding: 11px 12px; }
.run-facts div + div { border-left: 1px solid var(--rule); }

.run-facts dt {
  color: var(--muted);
  font: 9px/1.4 var(--mono);
  text-transform: uppercase;
}

.run-facts dd {
  margin: 4px 0 0;
  overflow: hidden;
  font: 12px/1.4 var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  position: relative;
  height: 3px;
  overflow: hidden;
  background: var(--paper-deep);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width 220ms ease;
}

.progress-track[data-indeterminate='true'] span {
  width: 35%;
  animation: progress-sweep 1.4s ease-in-out infinite;
}

@keyframes progress-sweep {
  from { transform: translateX(-110%); }
  to { transform: translateX(300%); }
}

.result-stage {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 260px;
  margin-top: 22px;
  overflow: hidden;
  place-items: center;
  border: 1px solid #2e3237;
  background: var(--night);
  color: #f4f1e9;
}

.result-placeholder {
  display: grid;
  max-width: 340px;
  place-items: center;
  padding: 28px;
  text-align: center;
}

.placeholder-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid #6f7478;
  color: #d7d2c9;
  font: 600 12px/1 var(--mono);
}

.result-placeholder p {
  margin: 17px 0 5px;
  font: 400 22px/1.2 var(--serif);
}

.result-placeholder > span:last-child {
  color: #9da2a6;
  font-size: 11px;
  line-height: 1.5;
}

.result-stage video {
  display: block;
  width: 100%;
  height: 100%;
  background: #08090a;
  object-fit: contain;
}

.result-footer {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--rule);
}

.result-footer p {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-footer {
  display: flex;
  min-height: 49px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px clamp(18px, 3vw, 42px);
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font: 9px/1.5 var(--mono);
  text-transform: uppercase;
}

@media (max-width: 880px) {
  .workspace {
    display: block;
    min-height: 0;
  }

  .composer {
    padding-right: 0;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .output { padding-left: 0; }
  .section-copy { max-width: 520px; }
}

@media (max-width: 600px) {
  .app-header__inner { min-height: 64px; gap: 10px; }
  .back-link { width: 28px; overflow: hidden; font-size: 0; white-space: nowrap; }
  .back-link span { font-size: 18px; }
  .header-rule { display: none; }
  .model-mark { width: 34px; height: 34px; }
  .identity h1 { font-size: 19px; }
  .identity p { display: none; }
  .connection { padding: 5px 8px; font-size: 0; }
  .connection__dot { width: 8px; height: 8px; }
  .workspace { padding-inline: 18px; }
  .composer, .output { padding-block: 34px; }
  .section-heading { margin-bottom: 23px; }
  .section-heading h2 { font-size: 34px; }
  .section-heading--output { align-items: start; }
  .api-label { max-width: 105px; margin-top: 5px; }
  textarea { min-height: 180px; }
  .service-notice { align-items: start; flex-direction: column; }
  .run-facts div { padding-inline: 8px; }
  .result-stage { min-height: 190px; }
  .form-actions .button--primary { min-width: 0; flex: 1; }
  .result-footer { align-items: start; flex-direction: column; padding: 12px 0; }
  .result-footer p { max-width: 100%; white-space: normal; }
}

@media (max-width: 390px) {
  .seed-control { grid-template-columns: 1fr 46px; }
  .icon-command { justify-content: center; padding-inline: 8px; }
  .icon-command span:last-child { display: none; }
  .run-facts dd { font-size: 10px; }
  .app-footer { display: block; }
  .app-footer span { display: block; }
  .app-footer span + span { margin-top: 4px; }
}

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

  .progress-track[data-indeterminate='true'] span {
    width: 65%;
    animation: none;
  }
}
