:root {
  color-scheme: dark;
  --bg: #07100e;
  --panel: rgba(13, 25, 22, 0.86);
  --panel-strong: #101e1a;
  --line: rgba(177, 214, 199, 0.14);
  --text: #edf7f2;
  --muted: #94aaa1;
  --green: #60f2ad;
  --green-strong: #19d982;
  --green-soft: rgba(73, 240, 165, 0.12);
  --amber: #f5bb66;
  --red: #ff7c76;
  --red-soft: rgba(255, 98, 98, 0.1);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 50% -20%, #153f33 0%, transparent 43%),
    var(--bg);
  background-size: 42px 42px, 42px 42px, auto, auto;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
  pointer-events: none;
}

.ambient-one { top: 15%; left: -14rem; background: var(--green); }
.ambient-two { right: -16rem; bottom: 4%; background: #378bc6; }

.shell {
  position: relative;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 64px 0 52px;
}

.hero { margin-bottom: 30px; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  color: var(--green);
  font: 600 0.72rem/1 var(--mono);
  letter-spacing: 0.18em;
}

.pulse {
  width: 8px;
  height: 8px;
  border: 2px solid var(--green);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(96, 242, 173, 0.08);
}

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

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 5.3rem);
  font-weight: 660;
  line-height: 0.96;
  letter-spacing: -0.065em;
}

h1 span { color: var(--green); font-weight: 350; }

.lede {
  max-width: 720px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.privacy-chip {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border: 1px solid rgba(96, 242, 173, 0.25);
  border-radius: 999px;
  color: var(--green);
  background: rgba(96, 242, 173, 0.06);
  font-size: 0.8rem;
  font-weight: 650;
}

.privacy-chip svg, .notice svg { width: 18px; fill: currentColor; }

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(17, 31, 27, 0.94), rgba(9, 18, 16, 0.94));
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.18);
}

.config-panel, .input-panel { margin-bottom: 16px; padding: 22px; }

.section-heading,
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading > div:first-child { display: flex; align-items: center; gap: 12px; }

.step {
  color: var(--green);
  font: 600 0.72rem/1 var(--mono);
  letter-spacing: 0.08em;
}

h2 { margin: 0; font-size: 1rem; font-weight: 650; letter-spacing: 0.01em; }
h2 strong { margin-left: 7px; color: var(--green); font-family: var(--mono); }

.endpoint {
  color: #6f8d81;
  font: 0.72rem/1 var(--mono);
}

.config-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
}

.field { display: grid; gap: 8px; }
.field > span { color: var(--muted); font-size: 0.78rem; }

input[type="text"], select {
  width: 100%;
  height: 45px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: rgba(4, 10, 8, 0.65);
}

input[type="text"] { padding: 0 14px; font-family: var(--mono); font-size: 0.84rem; }
select { padding: 0 12px; cursor: pointer; }

input[type="text"]:focus, select:focus, textarea:focus {
  border-color: rgba(96, 242, 173, 0.5);
  box-shadow: 0 0 0 3px rgba(96, 242, 173, 0.08);
}

.remember-row {
  grid-column: 1 / -1;
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
}

.remember-row input { accent-color: var(--green-strong); }

.parse-status { display: flex; gap: 14px; color: var(--muted); font: 0.72rem/1 var(--mono); }
.parse-status span:first-child { color: var(--green); }

.token-area, .result-area {
  display: block;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: #cde0d8;
  background: rgba(3, 9, 7, 0.72);
  font: 0.78rem/1.75 var(--mono);
  scrollbar-color: #315146 transparent;
}

.token-area { min-height: 220px; padding: 15px; }
.result-area { min-height: 174px; padding: 13px; }
.token-area::placeholder, .result-area::placeholder { color: #486057; }

.input-foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 0.75rem;
}

code { color: var(--green); font-family: var(--mono); }

.text-button {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: none;
  cursor: pointer;
}
.text-button:hover { color: var(--red); }

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 22px 0;
}

.progress-wrap { display: flex; flex: 1; align-items: center; gap: 13px; }
.progress-track { flex: 1; max-width: 340px; height: 5px; overflow: hidden; border-radius: 999px; background: #1a2b25; }
.progress-bar { width: 0%; height: 100%; border-radius: inherit; background: var(--green); box-shadow: 0 0 14px rgba(96, 242, 173, 0.55); transition: width 180ms ease; }
#progressText { min-width: 92px; color: var(--muted); font: 0.72rem/1 var(--mono); }
.main-actions, .result-actions { display: flex; gap: 9px; }

.button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #15241f;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 650;
  transition: transform 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); border-color: rgba(96, 242, 173, 0.42); }
.button:disabled { opacity: 0.35; cursor: not-allowed; }
.button.primary { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 21px; border-color: transparent; color: #04110c; background: var(--green); }
.button.primary svg { width: 17px; fill: currentColor; }
.button.secondary { min-height: 48px; background: transparent; }
.button.compact { min-height: 35px; padding: 0 11px; font-size: 0.72rem; }
.button.danger { border-color: rgba(255, 124, 118, 0.25); color: #ffaaa5; background: var(--red-soft); }

.results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.result-panel { min-width: 0; padding: 20px; }
.result-kicker { display: block; margin-bottom: 6px; font: 600 0.66rem/1 var(--mono); letter-spacing: 0.12em; }
.result-kicker.success { color: var(--green); }
.result-kicker.failure { color: var(--red); }
.result-panel > p { margin: 10px 0 0; color: var(--muted); font-size: 0.72rem; }
.success-panel { border-top-color: rgba(96, 242, 173, 0.35); }
.failure-panel { border-top-color: rgba(255, 124, 118, 0.3); }

details { margin-top: 10px; color: var(--muted); font-size: 0.72rem; }
summary { width: fit-content; cursor: pointer; }
#failureReasons { max-height: 150px; margin: 10px 0 0; padding-left: 28px; overflow: auto; line-height: 1.55; }
#failureReasons li { padding-left: 4px; overflow-wrap: anywhere; }

.notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 18px;
  padding: 15px 17px;
  border: 1px solid rgba(245, 187, 102, 0.16);
  border-radius: 12px;
  color: #bea77f;
  background: rgba(245, 187, 102, 0.045);
}
.notice svg { flex: 0 0 auto; color: var(--amber); }
.notice p { margin: 0; font-size: 0.77rem; line-height: 1.55; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 5;
  padding: 12px 16px;
  border: 1px solid rgba(96, 242, 173, 0.3);
  border-radius: 10px;
  color: var(--green);
  background: #10221b;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 0.8rem;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255, 124, 118, 0.35); color: #ffaaa5; background: #2a1716; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 780px) {
  .shell { width: min(100% - 24px, 1180px); padding-top: 38px; }
  .hero-row { align-items: flex-start; }
  .privacy-chip { margin-top: 4px; }
  .config-grid, .results-grid { grid-template-columns: 1fr; }
  .action-bar { align-items: stretch; flex-direction: column; }
  .progress-track { max-width: none; }
  .main-actions { justify-content: flex-end; }
}

@media (max-width: 540px) {
  .config-panel, .input-panel, .result-panel { padding: 16px; border-radius: 14px; }
  .hero-row { display: block; }
  .privacy-chip { width: fit-content; margin-top: 18px; }
  .section-heading { align-items: flex-start; }
  .endpoint { display: none; }
  .parse-status { flex-direction: column; gap: 7px; text-align: right; }
  .input-foot { align-items: flex-start; flex-direction: column; }
  .main-actions, .result-actions { width: 100%; }
  .main-actions .button, .result-actions .button { flex: 1; padding-inline: 9px; }
  .result-head { align-items: flex-start; flex-direction: column; }
  .result-actions { order: 2; }
}

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