:root {
  --bg: #0b1120;
  --bg-soft: #111a2e;
  --panel: #131d33;
  --panel-soft: #182440;
  --border: rgba(148, 163, 184, 0.16);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(1200px 600px at 15% -10%, rgba(56, 189, 248, 0.14), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(129, 140, 248, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 5vw, 56px);
  border-bottom: 1px solid var(--border);
  background: rgba(11, 17, 32, 0.72);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.55);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: var(--accent-soft);
  color: #bae6fd;
  white-space: nowrap;
}

.ghost-link {
  font-size: 13px;
  color: var(--muted);
}

.ghost-link:hover {
  color: var(--text);
}

main {
  width: min(980px, 100% - 32px);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) 0 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero h1 {
  font-size: clamp(28px, 4.4vw, 42px);
  line-height: 1.2;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  max-width: 62ch;
  color: var(--muted);
}

.hero em {
  color: var(--accent);
  font-style: normal;
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 26px);
  box-shadow: 0 20px 50px -35px rgba(2, 6, 23, 0.95);
}

.inputs {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.55);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus {
  border-color: rgba(56, 189, 248, 0.65);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.swap {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.swap:hover {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.5);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

button {
  font-family: var(--font);
}

.primary {
  padding: 12px 22px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #04121f;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.primary:active:not(:disabled) {
  transform: translateY(1px);
}

.primary:disabled {
  opacity: 0.65;
  cursor: progress;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.examples button {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.examples button:hover {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.5);
}

.muted {
  color: var(--muted);
}

.status {
  margin: 16px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #bae6fd;
  font-size: 14px;
}

.status[data-tone="error"] {
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
}

.is-busy .status {
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.verdict {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 650;
  font-size: 14px;
}

.verdict--good {
  background: rgba(52, 211, 153, 0.14);
  color: var(--good);
}

.verdict--warn {
  background: rgba(251, 191, 36, 0.14);
  color: var(--warn);
}

.verdict--bad {
  background: rgba(248, 113, 113, 0.14);
  color: var(--bad);
}

.confidence {
  font-size: 13px;
  color: var(--muted);
}

.scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.score {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
}

.score-value {
  font-size: clamp(38px, 6vw, 52px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--accent);
}

.score-value small {
  font-size: 0.4em;
  margin-left: 2px;
  color: var(--muted);
}

.score-label {
  font-weight: 600;
}

.score-hint {
  font-size: 12px;
  color: var(--muted);
}

.pairs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.pair {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.35);
}

.pair h3 {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.pair-title {
  margin: 0 0 4px;
  font-weight: 600;
}

.pair p {
  margin: 0;
  font-size: 13px;
}

.segments h3,
.chart h3 {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 0 10px;
}

.segments ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.segments li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.4);
  border: 1px solid var(--border);
  font-size: 14px;
}

.tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.tag--cut {
  background: rgba(248, 113, 113, 0.16);
  color: var(--bad);
}

.tag--add {
  background: rgba(52, 211, 153, 0.16);
  color: var(--good);
}

.chart canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.45);
}

.fineprint {
  font-size: 12px;
  margin: 14px 0 0;
}

.how h2 {
  font-size: 18px;
  margin: 0 0 10px;
}

.how ol {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.how code {
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5f5;
}

.how p {
  margin: 12px 0 0;
  font-size: 13px;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 20px clamp(16px, 5vw, 56px) 32px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 640px) {
  .inputs {
    grid-template-columns: 1fr;
  }

  .swap {
    justify-self: center;
    transform: rotate(90deg);
  }

  .footer {
    flex-direction: column;
  }
}
