:root {
  --bg: #FFFFFF;
  --surface: #FAFAF8;
  --surface-alt: #F3F3EF;
  --text: #14171F;
  --text-dim: #6B7178;
  --accent: #2F5EFF;
  --accent-soft: #EEF2FF;
  --accent-line: #C7D4FF;
  --line: #E7E7E1;
  --ok: #1F9D65;
  --ok-soft: #E9F7EF;
  --err: #D64545;
  --err-soft: #FCEBEB;
  --display: 'Space Grotesk', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --body: 'Inter', -apple-system, sans-serif;
  --shadow: 0 1px 2px rgba(20, 23, 31, 0.04), 0 8px 24px -12px rgba(20, 23, 31, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 32px 24px 100px; }
.hidden { display: none !important; }

.top { display: flex; justify-content: space-between; align-items: center; padding-bottom: 48px; }
.brand-mark { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 30px; height: 30px; flex-shrink: 0; }
.logo { font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.tag { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }

.panel { margin-bottom: 28px; }

.intake h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(30px, 4.6vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  max-width: 15ch;
}
.lede { margin-top: 16px; color: var(--text-dim); font-size: 16.5px; max-width: 48ch; }

form { margin-top: 36px; }
label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); font-weight: 600; margin-bottom: 10px; }
textarea {
  width: 100%; min-height: 112px; resize: vertical;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-family: var(--body); font-size: 15px; padding: 15px 17px;
  outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea::placeholder { color: #A6ABB3; }

.track-toggle { display: flex; gap: 8px; margin-top: 8px; margin-bottom: 30px; }
.track-btn {
  font-family: var(--mono); font-size: 13px; padding: 11px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text-dim); cursor: pointer; transition: all 0.15s ease;
}
.track-btn:hover { border-color: var(--accent-line); }
.track-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.license-btn {
  font-family: var(--body); font-size: 13px; padding: 11px 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text-dim); cursor: pointer; transition: all 0.15s ease;
}
.license-btn:hover { border-color: var(--accent-line); }
.license-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.submit-btn {
  font-family: var(--body); font-weight: 600; font-size: 15px;
  background: var(--text); color: #fff; border: none; border-radius: 9px;
  padding: 15px 28px; cursor: pointer; transition: opacity 0.15s ease, transform 0.1s ease;
}
.submit-btn:hover { opacity: 0.86; }
.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.mission {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 26px 28px; box-shadow: var(--shadow);
}
.mission-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; gap: 14px; }
.mission-title { font-family: var(--display); font-size: 16px; font-weight: 600; margin-bottom: 4px; max-width: 46ch; }
.mission-id-label { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
#mission-id { color: var(--accent); font-weight: 600; }
.mission-status {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-dim); background: #fff;
}
.mission-status.complete { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.mission-status.error { color: var(--err); border-color: var(--err); background: var(--err-soft); }

.stage-list { list-style: none; }
.stage-item {
  display: flex; gap: 14px; align-items: flex-start; padding: 15px 0;
  border-bottom: 1px solid var(--line); opacity: 0.4; transition: opacity 0.2s ease;
}
.stage-item:last-child { border-bottom: none; }
.stage-item.active, .stage-item.done { opacity: 1; }

.dot {
  width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0;
  background: #D5D5CE; transition: background 0.2s ease;
}
.stage-item.active .dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.stage-item.done .dot { background: var(--ok); }
.stage-item.error .dot { background: var(--err); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.stage-name { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); font-weight: 500; }
.stage-label { font-size: 14.5px; margin-top: 3px; color: var(--text); }

.error-banner {
  margin-top: 18px; background: var(--err-soft); border: 1px solid var(--err);
  border-radius: 8px; padding: 14px 16px; font-family: var(--mono); font-size: 13px;
  color: #8A2A2A; white-space: pre-wrap; word-break: break-word;
}

.result {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; box-shadow: var(--shadow);
}
.result-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 22px; }
.result-header h2 { font-family: var(--display); font-size: 21px; font-weight: 600; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { font-family: var(--body); font-weight: 600; font-size: 13.5px; padding: 11px 18px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block; transition: all 0.15s ease; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--accent-line); }

#preview { width: 100%; height: 500px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

.paid-status { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.unlock-row { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.unlock-row input {
  flex: 1; min-width: 140px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 14px; outline: none;
}
.unlock-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

@media (max-width: 600px) {
  .result-header { flex-direction: column; align-items: flex-start; }
  .top { flex-direction: column; align-items: flex-start; gap: 10px; }
}
