:root {
  --bg: #0d1117;
  --surface: #161b24;
  --surface2: #1c2330;
  --surface3: #222b3a;
  --border: #2a3244;
  --border-soft: #1e2838;
  --accent: #3ecf8e;
  --accent-dim: rgba(62,207,142,0.12);
  --accent-glow: rgba(62,207,142,0.2);
  --blue: #58a6ff;
  --blue-dim: rgba(88,166,255,0.12);
  --orange: #f0883e;
  --orange-dim: rgba(240,136,62,0.12);
  --text: #e6edf3;
  --text-soft: #8b949e;
  --text-muted: #484f58;
  --red: #ff7b72;
  --gold: #e3b341;
  --silver: #8b949e;
  --bronze: #b87333;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  top: -200px; left: 50%;
  transform: translateX(-50%);
  width: 800px; height: 500px;
  background: radial-gradient(ellipse at center, rgba(62,207,142,0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 56px 24px 100px;
}

.header { margin-bottom: 48px; animation: fadeDown 0.5s ease; }

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.header-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
  background: var(--accent-dim);
  padding: 5px 12px;
  border-radius: 20px;
}

.header-eyebrow .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.35; }
}

.header h1 {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 10px;
}

.header h1 em { font-style: normal; color: var(--accent); }

.header p {
  color: var(--text-soft);
  font-size: 0.95rem;
  font-weight: 300;
  max-width: 620px;
  line-height: 1.75;
}

.scoring-toggle { margin-bottom: 32px; animation: fadeDown 0.5s ease 0.1s both; }

.scoring-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  color: var(--text-soft);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.scoring-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.scoring-btn .chevron { width: 14px; height: 14px; stroke: currentColor; transition: transform 0.25s; margin-left: 2px; }
.scoring-btn.open .chevron { transform: rotate(180deg); }
.scoring-btn .info-icon { width: 15px; height: 15px; stroke: currentColor; }

.scoring-panel {
  display: none;
  margin-top: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.scoring-panel.open { display: block; }

.scoring-formula {
  font-family: 'DM Mono', monospace;
  font-size: 0.95rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 20px;
  line-height: 2.2;
}

.sc-eq { color: var(--text-soft); font-size: 0.78rem; letter-spacing: 0.04em; display: block; margin-bottom: 2px; }
.sc-pr { color: var(--blue); font-weight: 600; }
.sc-q  { color: var(--orange); font-weight: 600; }
.sc-var{ color: var(--accent); }

.scoring-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) { .scoring-legend { grid-template-columns: 1fr; } }

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

.legend-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
}

.ic-blue   { background: var(--blue-dim);   color: var(--blue); }
.ic-orange { background: var(--orange-dim); color: var(--orange); }
.ic-green  { background: var(--accent-dim); color: var(--accent); }
.ic-grey   { background: var(--surface3);   color: var(--text-muted); }

.legend-text strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.legend-text span { font-size: 12px; color: var(--text-soft); line-height: 1.5; }
.mono { font-family: 'DM Mono', monospace; font-size: 11px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
  animation: fadeUp 0.4s ease both;
}

.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.18s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.04em;
}

.card-body { padding: 16px 24px 24px; }

.presets-heading {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.presets-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-soft);
  font-family: 'DM Sans', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  transform: translateY(-1px);
}

.preset-btn:active { transform: translateY(0); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 580px) { .two-col { grid-template-columns: 1fr; } }

.input-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.input-label .lbl { font-size: 13px; font-weight: 600; color: var(--text); }
.input-label .hint { font-size: 11px; color: var(--text-muted); font-family: 'DM Mono', monospace; background: var(--surface3); padding: 2px 8px; border-radius: 4px; }

textarea, input[type="number"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12.5px;
  line-height: 1.7;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}

textarea:focus, input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea { min-height: 145px; }

.input-help {
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 2px;
}

.run-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.k-group { flex-shrink: 0; }

.k-group input {
  width: 110px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 12px;
  resize: none;
}

.run-btn {
  flex: 1;
  min-width: 200px;
  padding: 14px 24px;
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.run-btn:hover {
  background: #4de89e;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(62,207,142,0.3);
}

.run-btn:active { transform: translateY(0); box-shadow: none; }
.run-btn svg { width: 15px; height: 15px; }

.shortcut-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  text-align: right;
}

.shortcut-hint kbd {
  font-family: 'DM Mono', monospace;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
}

.error-box {
  display: none;
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(255,123,114,0.08);
  border: 1px solid rgba(255,123,114,0.25);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 13px;
  align-items: center;
  gap: 8px;
}

.error-box.show { display: flex; }

#results { display: none; animation: fadeUp 0.45s ease; }

.results-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.results-top {
  padding: 22px 26px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.results-title { font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; }
.results-title span { color: var(--accent); }

.result-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 11px;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-soft);
  border: 1px solid var(--border);
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface2); }

th {
  padding: 11px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

th.r { text-align: right; }

td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
  vertical-align: middle;
}

td.r { text-align: right; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
}

.r1 { background: rgba(227,179,65,0.15); color: var(--gold); }
.r2 { background: rgba(139,148,158,0.15); color: var(--silver); }
.r3 { background: rgba(184,115,51,0.15); color: var(--bronze); }
.rn { background: var(--surface3); color: var(--text-muted); }

.url-cell {
  font-family: 'DM Mono', monospace;
  font-size: 12.5px;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.q-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: 'DM Mono', monospace;
}

.q-pill::before { content:''; width:5px; height:5px; border-radius:50%; background:currentColor; }
.q-high { background: var(--accent-dim); color: var(--accent); }
.q-low  { background: var(--orange-dim); color: var(--orange); }

.pr-val { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--text-soft); }
.final-val { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 700; color: var(--accent); }

.bars-section { padding: 22px 26px 28px; border-top: 1px solid var(--border-soft); }
.bars-title { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 18px; }

.bar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 13px; }
.bar-row:last-child { margin-bottom: 0; }

.bar-url {
  font-family: 'DM Mono', monospace;
  font-size: 11.5px;
  color: var(--text-soft);
  width: 155px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track { flex: 1; height: 7px; background: var(--surface3); border-radius: 4px; overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--blue), var(--accent));
  width: 0%;
  transition: width 0.7s cubic-bezier(.22,.68,0,1.1);
}

.bar-score {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  width: 44px;
  text-align: right;
  flex-shrink: 0;
}