:root {
  color-scheme: dark;
  --bg: #101112;
  --panel: #181a1d;
  --panel-2: #202329;
  --line: #333840;
  --text: #f4f1ea;
  --muted: #aaa59b;
  --accent: #ff4d6d;
  --accent-2: #ffd166;
  --ok: #40d98f;
  --shadow: 0 24px 80px rgb(0 0 0 / 36%);
  font-family: Avenir Next, Futura, Helvetica Neue, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% 8%, rgb(255 77 109 / 18%), transparent 28rem),
    radial-gradient(circle at 82% 20%, rgb(255 209 102 / 12%), transparent 22rem),
    linear-gradient(135deg, #121314 0%, #0b0c0d 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 max(42px, env(safe-area-inset-bottom));
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 68px);
  line-height: 0.95;
}

.lede {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(24 26 29 / 78%);
  box-shadow: var(--shadow);
}

.status-card small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 0 6px rgb(64 217 143 / 14%);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(24 26 29 / 86%);
  box-shadow: var(--shadow);
}

.intake-panel,
.result-panel {
  padding: 18px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 22px;
  border: 1px dashed #626873;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgb(255 77 109 / 13%), transparent),
    var(--panel-2);
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, transform 160ms ease;
}

.drop-zone:hover {
  border-color: var(--accent-2);
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 32px;
  line-height: 1;
}

.drop-zone small {
  margin-top: 8px;
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.mobile-run-button {
  display: none;
  width: 100%;
  margin-top: 12px;
}

.controls label,
.manual-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111315;
  color: var(--text);
  padding: 0 12px;
}

input[type='range'] {
  padding: 0;
  accent-color: var(--accent);
}

.preview-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a0b0c;
  min-height: 460px;
}

#previewCanvas {
  display: block;
  width: 100%;
  height: auto;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #6f7480;
  font-size: 22px;
  font-weight: 800;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

#bestCode {
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: clamp(34px, 6vw, 54px);
  line-height: 1;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.confidence-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--muted);
}

meter {
  width: 100%;
  height: 12px;
}

.mock-submit {
  width: 100%;
  margin: 14px 0 18px;
  background: linear-gradient(90deg, var(--accent), #ff8a4c);
}

.status-line {
  min-height: 20px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.section-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

#candidateList {
  display: grid;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}

#candidateList li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111315;
  font-family: Menlo, Monaco, Consolas, monospace;
}

@media (max-width: 860px) {
  .hero,
  .workspace,
  .controls {
    grid-template-columns: 1fr;
  }

  .hero {
    display: grid;
  }

  .preview-wrap {
    min-height: 260px;
  }
}

@media (max-width: 520px) {
  body {
    background:
      radial-gradient(circle at 8% 0%, rgb(255 77 109 / 18%), transparent 18rem),
      linear-gradient(180deg, #151618 0%, #08090a 100%);
  }

  .app-shell {
    width: min(100vw - 20px, 430px);
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .hero {
    gap: 12px;
    margin-bottom: 12px;
  }

  .eyebrow {
    margin-bottom: 5px;
    font-size: 10px;
  }

  h1 {
    font-size: 30px;
    line-height: 1.05;
  }

  .lede {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.55;
  }

  .status-card {
    min-width: 0;
    padding: 10px 12px;
    box-shadow: none;
  }

  .workspace {
    gap: 12px;
  }

  .intake-panel,
  .result-panel {
    padding: 12px;
  }

  .drop-zone {
    min-height: 124px;
    padding: 18px 14px;
  }

  .upload-icon {
    width: 44px;
    height: 44px;
    font-size: 34px;
  }

  .mobile-run-button {
    display: block;
  }

  .controls {
    gap: 10px;
    margin: 12px 0;
  }

  select,
  input,
  button {
    min-height: 48px;
    font-size: 16px;
  }

  .preview-wrap {
    min-height: 0;
    max-height: 48vh;
    overflow: auto;
  }

  .result-header {
    display: grid;
    gap: 12px;
    padding-bottom: 14px;
  }

  .result-header button {
    display: none;
  }

  #bestCode {
    font-size: 42px;
    overflow-wrap: anywhere;
  }

  .confidence-row {
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin: 14px 0;
  }

  .confidence-row span {
    display: none;
  }

  .mock-submit {
    min-height: 52px;
    margin: 12px 0 14px;
  }

  #candidateList li {
    display: grid;
    gap: 4px;
    padding: 12px;
    font-size: 15px;
  }

}
