:root {
  --ink: #0e1218;
  --muted: #627083;
  --line: #e6e8ec;
  --paper: #f7f8fa;
  --card: #ffffff;
  --blue: #2e5cff;
  --blue-soft: #eaf0ff;
  --green: #0f9f6e;
  --red: #e11d48;
  --amber: #b45309;
  --shadow: 0 16px 40px rgba(20, 32, 51, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

.nav {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  width: min(1080px, calc(100% - 32px));
  height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  height: 32px;
  width: auto;
  display: block;
}

.nav-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.credit {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.credit:hover { color: var(--blue); }

button, input { font: inherit; }

.app {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.hero { margin-bottom: 18px; }

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.lede, .note, .muted { color: var(--muted); }

.lede { margin: 0; max-width: 640px; line-height: 1.5; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.search input {
  flex: 1;
  border: 0;
  outline: 0;
  padding: 12px 12px;
  background: transparent;
  color: var(--ink);
}

.search button, .candidate button, .ghost {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--blue);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.search button:disabled { opacity: 0.6; cursor: wait; }

.ghost {
  background: transparent;
  color: var(--blue);
}

.notice, .error, .panel {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.notice, .error { padding: 14px 16px; line-height: 1.45; }
.error { border-color: #fecdd3; background: #fff5f6; color: #9f1239; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  margin-top: 16px;
}

.score-card, .panel { padding: 20px; }
.score-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.ring {
  width: 168px;
  height: 168px;
  margin: 8px auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--blue) calc(var(--p) * 1%), #e8edf5 0);
}

.ring span {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: white;
  display: grid;
  place-items: center;
  font-size: 42px;
  font-weight: 750;
  letter-spacing: -0.05em;
}

.band { text-align: center; font-size: 18px; font-weight: 750; margin: 0; }
.center { text-align: center; }

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

.identity img, .fallback {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--blue-soft);
}

.fallback {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--blue);
}

.identity h2 { margin: 0 0 4px; font-size: 22px; }
.identity p { margin: 0; }

.wallet {
  margin-top: 12px;
  font-family: Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.stat {
  padding: 12px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.stat b { display: block; margin-top: 4px; font-size: 18px; }
.up { color: var(--green); }
.down { color: var(--red); }

.tier {
  margin-top: 16px;
}

.bar, .meter {
  height: 8px;
  border-radius: 99px;
  background: #e8edf5;
  overflow: hidden;
}

.bar > span, .meter > span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.rows { display: grid; gap: 12px; margin-top: 8px; }
.row-top, .split {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.flags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.flag {
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff7ed;
  color: var(--amber);
  font-size: 13px;
}

.cats { display: flex; flex-wrap: wrap; gap: 8px; }
.cat {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--blue-soft);
  color: var(--ink);
  font-size: 13px;
}

svg.chart { width: 100%; height: 120px; display: block; }
.chart path { fill: none; stroke: var(--blue); stroke-width: 2.4; }
.chart .area { fill: rgba(22, 82, 240, 0.12); stroke: none; }

.candidates { display: grid; gap: 8px; margin-top: 8px; }
.candidate {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.fine {
  margin-top: 18px;
  font-size: 13px;
  line-height: 1.5;
}

.alloc { margin-top: 16px; }
.alloc h2 { margin: 0 0 6px; font-size: 22px; }
.alloc-head, .presets, .alloc-figures, .controls {
  display: flex;
  gap: 12px;
}
.alloc-head { justify-content: space-between; align-items: start; }
.presets { flex-wrap: wrap; }
.preset {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 650;
  cursor: pointer;
}
.preset:hover { border-color: var(--blue); color: var(--blue); }
.alloc-figures { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 16px; }
.alloc-context { margin: 12px 0 0; }
.controls { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 16px; }
.control {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
}
.control span { font-size: 13px; font-weight: 650; }
.control small { color: var(--muted); }
.control input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}

@media (max-width: 800px) {
  .brand-logo { height: 26px; }
  .nav-meta { gap: 8px; }
  .credit { font-size: 13px; }
  .layout, .stats, .alloc-figures, .controls, .alloc-head { grid-template-columns: 1fr; display: grid; }
  .search { flex-direction: column; }
}
