:root {
  --ink: #201d1d;
  --ink-deep: #0f0000;
  --charcoal: #302c2c;
  --mute: #646262;
  --ash: #9a9898;
  --canvas: #fdfcfc;
  --surface-soft: #f8f7f7;
  --surface-dark: #201d1d;
  --surface-dark-elevated: #302c2c;
  --warning: #ff9f0a;
  --danger: #ff3b30;
  --success: #30d158;
  --bg: var(--surface-dark);
  --fg: var(--canvas);
  --fg-soft: var(--ash);
  --panel: var(--surface-dark);
  --panel-soft: var(--surface-dark-elevated);
  --input-bg: var(--surface-dark-elevated);
  --hairline: rgba(253, 252, 252, 0.18);
  --hairline-strong: var(--ash);
  --button-bg: var(--canvas);
  --button-fg: var(--ink);
  --motion-fast: 160ms;
  --motion-mid: 360ms;
  --motion-slow: 760ms;
}

:root[data-theme="light"] {
  --bg: var(--canvas);
  --fg: var(--ink);
  --fg-soft: var(--mute);
  --panel: var(--canvas);
  --panel-soft: var(--surface-soft);
  --input-bg: var(--surface-soft);
  --hairline: rgba(15, 0, 0, 0.12);
  --hairline-strong: var(--mute);
  --button-bg: var(--ink);
  --button-fg: var(--canvas);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: "Berkeley Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 16px;
  line-height: 1.5;
  transition: background-color var(--motion-mid) ease, color var(--motion-mid) ease;
}

button,
input {
  font: inherit;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 64px;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  filter: blur(6px);
}

.reveal.is-visible {
  animation: reveal-up var(--motion-slow) cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: var(--reveal-delay, 0ms);
}

.reveal-terminal.is-visible .ascii-title {
  animation: terminal-type var(--motion-slow) steps(5, end) both;
  animation-delay: calc(var(--reveal-delay, 0ms) + 180ms);
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  margin: 0;
  font-weight: 700;
  line-height: 1;
}

.nav-meta,
.prompt-row,
.button-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-terminal {
  position: relative;
  overflow: hidden;
  margin-top: 32px;
  padding: 64px 32px;
  background: var(--ink);
  color: var(--canvas);
}

.hero-terminal::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(253, 252, 252, 0.12), transparent);
  transform: translateX(-120%);
}

.hero-terminal.is-visible::after {
  animation: scan-line 1100ms ease 420ms both;
}

.ascii-title {
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--canvas);
}

.prompt-row {
  flex-wrap: wrap;
  margin-top: 32px;
  padding: 8px 12px;
  border-radius: 4px;
  background: var(--charcoal);
  color: var(--canvas);
  transition: transform var(--motion-fast) ease;
}

.prompt-row:hover {
  transform: translateY(-2px);
}

#hero-project {
  color: var(--ash);
  overflow-wrap: anywhere;
}

.section-block {
  margin-top: 96px;
  border-top: 1px solid var(--hairline);
  padding-top: 16px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-head span,
.lead-list span {
  color: var(--fg-soft);
}

h1,
h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
}

.lead-list {
  margin-top: 16px;
  border-top: 1px solid var(--hairline);
}

.lead-list p {
  display: flex;
  gap: 12px;
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--fg-soft);
}

.app-grid {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.control-block,
.output-block {
  margin-top: 96px;
}

.field {
  margin-top: 16px;
}

.field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  outline: none;
  background: var(--input-bg);
  color: var(--fg);
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease, transform var(--motion-fast) ease;
}

input:focus {
  border-color: var(--fg);
  background: var(--panel);
  transform: translateY(-1px);
}

input::placeholder {
  color: var(--fg-soft);
}

.inline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  align-items: end;
}

.helper-text,
.selection-summary {
  margin: 4px 0 0;
  color: var(--fg-soft);
  font-size: 14px;
  line-height: 2;
}

.upload-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}

.dropzone {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 142px;
  padding: 16px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: var(--panel-soft);
  cursor: pointer;
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease, transform var(--motion-fast) ease;
}

.dropzone:hover,
.dropzone.active {
  transform: translateY(-2px);
  border-color: var(--fg);
}

.dropzone input {
  display: none;
}

.dropzone span:first-of-type {
  font-weight: 700;
}

.dropzone span:last-of-type {
  color: var(--fg-soft);
  overflow-wrap: anywhere;
}

.selection-summary {
  min-height: 32px;
  margin-top: 8px;
}

.checkbox-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-top: 24px;
  color: var(--fg-soft);
}

.checkbox-row input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--button-bg);
}

.primary-button,
.secondary-button,
.text-button,
.result-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--hairline-strong);
  border-radius: 4px;
  padding: 4px 20px;
  background: transparent;
  color: var(--fg);
  font-weight: 500;
  line-height: 2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease, color var(--motion-fast) ease,
    transform var(--motion-fast) ease;
}

.primary-button {
  width: 100%;
  margin-top: 24px;
  border-color: var(--button-bg);
  background: var(--button-bg);
  color: var(--button-fg);
}

.primary-button:hover,
.secondary-button:hover,
.text-button:hover,
.result-links a:hover {
  transform: translateY(-1px);
}

.primary-button:active {
  background: var(--ink-deep);
  color: var(--canvas);
  transform: translateY(1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  border-color: var(--hairline);
  background: var(--panel-soft);
  color: var(--ash);
  cursor: not-allowed;
}

.secondary-button:hover,
.text-button:hover {
  border-color: var(--fg);
  background: var(--panel-soft);
  color: var(--fg);
}

.state-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.state-row strong {
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  border-radius: 4px;
  padding: 2px 8px;
  background: var(--panel-soft);
  color: var(--fg);
  font-size: 14px;
  line-height: 2;
  transition: transform var(--motion-fast) ease;
}

.badge:hover {
  transform: translateY(-1px);
}

.status-success {
  color: var(--success);
}

.status-warning {
  color: var(--warning);
}

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

.progress-shell {
  margin-top: 24px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  color: var(--fg-soft);
}

.progress-track {
  position: relative;
  height: 40px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: var(--panel-soft);
  overflow: hidden;
}

#bar {
  width: 0%;
  height: 100%;
  background: var(--button-bg);
  transition: width 320ms cubic-bezier(0.16, 1, 0.3, 1), background-color var(--motion-mid) ease;
}

.progress-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(253, 252, 252, 0.2), transparent);
  transform: translateX(-120%);
  animation: progress-sheen 1600ms ease-in-out infinite;
}

.result-links {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.result-links a {
  justify-content: flex-start;
  color: var(--success);
}

.terminal-log {
  margin-top: 32px;
}

.terminal-label {
  margin-bottom: 8px;
  color: var(--fg-soft);
}

#logs {
  min-height: 420px;
  max-height: 58vh;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: var(--panel-soft);
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
}

.footer-section {
  display: flex;
  gap: 12px;
  margin-top: 96px;
  padding: 32px 0;
  border-top: 1px solid var(--hairline);
  color: var(--fg-soft);
  font-size: 14px;
  line-height: 2;
}

.footer-section p {
  margin: 0;
}

.footer-section a {
  color: var(--fg);
  text-decoration: underline;
  transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease;
}

.footer-section a:hover {
  background: var(--fg);
  color: var(--bg);
}

@media (max-width: 940px) {
  .app-grid,
  .inline-row {
    grid-template-columns: 1fr;
  }

  .section-block,
  .control-block,
  .output-block,
  .footer-section {
    margin-top: 64px;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 24px, 1120px);
  }

  .topnav,
  .nav-meta,
  .upload-split {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .hero-terminal {
    padding: 48px 16px;
  }

  .ascii-title {
    font-size: 14px;
  }

  .state-row {
    grid-template-columns: 1fr;
  }

  #logs {
    min-height: 320px;
  }
}

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(18px);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes terminal-type {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes scan-line {
  from {
    transform: translateX(-120%);
  }
  to {
    transform: translateX(120%);
  }
}

@keyframes progress-sheen {
  0% {
    transform: translateX(-120%);
  }
  45%,
  100% {
    transform: translateX(120%);
  }
}

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

  .reveal {
    opacity: 1;
    transform: none;
    filter: none;
  }
}
