:root {
  --bg: #fbfbfd;
  --card: #ffffff;
  --ink: #1d1d1f;
  --mute: #6e6e73;
  --line: #e5e5ea;
  --soft: #f2f2f5;
  --red: #d52b1e;
  --kept: #30a46c;
  --partly: #f5a524;
  --broken: #e5484d;
  --notyet: #8e8e93;
  --cantverify: #5b5bd6;
  --shadow: 0 2px 14px rgba(0, 0, 0, .06);
}
:root[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --ink: #f5f5f7;
  --mute: #98989d;
  --line: #2c2c2e;
  --soft: #2c2c2e;
  --shadow: 0 2px 14px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: 52px; padding: 0 40px;
  display: flex; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.logo { font-weight: 600; }
.links a { margin: 0 14px; color: var(--mute); text-decoration: none; transition: color .2s; }
.links a:hover, .links a.on { color: var(--ink); }
.links a.on { font-weight: 600; }
.theme-btn { background: none; border: 0; cursor: pointer; color: var(--ink); padding: 6px; }
.theme-btn svg { width: 18px; height: 18px; display: block; }

/* ---------- Shared pieces ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 0 40px 80px; }
.hero { text-align: center; padding: 56px 0 28px; }
.hero h1 { font-size: 56px; letter-spacing: -1.6px; margin: 0; line-height: 1.05; }
.hero p { color: var(--mute); font-size: 21px; margin: 10px 0 24px; }
.controls { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }

.seg { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0; background: none; color: var(--ink); font: inherit; font-size: 14px;
  padding: 7px 20px; border-radius: 999px; cursor: pointer; transition: background .2s, box-shadow .2s;
}
.seg button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.15); font-weight: 600; }

select.pill {
  appearance: none; font: inherit; font-size: 14px; color: var(--ink);
  padding: 8px 34px 8px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--card)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236e6e73'/%3E%3C/svg%3E") no-repeat right 14px center;
  cursor: pointer;
}

.card { background: var(--card); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 18px; }
h2 { font-size: 22px; letter-spacing: -.4px; margin: 0 0 16px; }
.mute { color: var(--mute); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

.status-banner {
  text-align: center; font-size: 14px; color: var(--mute); margin: 0 0 22px;
}
.status-banner b { color: var(--ink); }

/* ---------- Dashboard: overview ---------- */
.overview { grid-template-columns: 340px 1fr; }
.ring-card { align-self: start; position: sticky; top: 72px; min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-card svg { width: 240px; height: 240px; }
.ring-card circle.seg-arc { transition: stroke-dasharray .9s cubic-bezier(.2,.8,.2,1), stroke-dashoffset .9s cubic-bezier(.2,.8,.2,1), opacity .2s; cursor: pointer; }
.ring-card .big { font-size: 8px; font-weight: 700; fill: var(--ink); }
.ring-card .small { font-size: 2.6px; fill: var(--mute); }

.stats { grid-template-columns: repeat(5, minmax(0, 1fr)); align-content: start; }
.stat { cursor: pointer; transition: transform .2s, box-shadow .2s, opacity .2s; border: 2px solid transparent; }
.stat:hover { transform: translateY(-2px); }
.stat.on { border-color: var(--ink); }
.stats.filtering .stat:not(.on) { opacity: .45; }
.stat .n { font-size: 44px; font-weight: 700; letter-spacing: -1px; }
.stat .l { color: var(--mute); font-size: 14px; }

.cats { grid-column: 1 / -1; }
.cat-row {
  display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px;
}
.cat-row:last-child { border-bottom: 0; }
.cat-row .count { text-align: right; color: var(--mute); font-size: 13px; }
.bar { height: 10px; border-radius: 5px; background: var(--soft); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; transition: width .8s cubic-bezier(.2,.8,.2,1); }

/* ---------- Dashboard: quality (opposition) ---------- */
.meters { grid-template-columns: repeat(3, 1fr); }
.meter .n { font-size: 44px; font-weight: 700; letter-spacing: -1px; }
.meter .track { height: 8px; background: var(--soft); border-radius: 4px; margin-top: 12px; overflow: hidden; }
.meter .track i { display: block; height: 100%; background: var(--red); border-radius: 4px; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.stars { font-size: 26px; letter-spacing: 2px; color: var(--partly); }

/* ---------- Dashboard: progress (2025) ---------- */
.progress-list .p-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.progress-list .p-row:last-child { border-bottom: 0; }
.tag { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--red); font-weight: 700; }
.stages { display: flex; align-items: center; }
.stages i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--red); background: var(--card); }
.stages i.f { background: var(--red); }
.stages b { width: 26px; height: 2px; background: var(--line); }
.stages b.f { background: var(--red); }
.stage-label { font-size: 12px; color: var(--mute); width: 90px; text-align: right; margin-left: 12px; }

/* ---------- Placeholder pages ---------- */
.soon { text-align: center; padding: 120px 0; }
.soon h1 { font-size: 44px; letter-spacing: -1.2px; margin: 0 0 10px; }

.sample-note {
  width: fit-content; margin: 0 auto 32px; text-align: center;
  background: var(--card); color: var(--mute); font-size: 12px;
  padding: 6px 14px; border-radius: 999px; box-shadow: var(--shadow);
}

/* Fade-in for page changes */
.fade { animation: fade .45s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Phone widths ---------- */
@media (max-width: 860px) {
  .topbar { padding: 0 16px; height: auto; flex-wrap: wrap; }
  .logo, .theme-btn { height: 48px; display: flex; align-items: center; }
  .links { order: 3; width: 100%; overflow-x: auto; white-space: nowrap; padding-bottom: 10px; }
  .links a:first-child { margin-left: 0; }
  main { padding: 0 16px 80px; }
  .hero h1 { font-size: 38px; }
  .hero p { font-size: 17px; }
  .overview { grid-template-columns: 1fr; }
  .ring-card { position: static; min-height: 0; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meters { grid-template-columns: 1fr; }
  .cat-row { grid-template-columns: 90px 1fr 30px; }
}

/* ---------- Shared additions ---------- */
.nav-tools { display: flex; gap: 2px; }
.icon-btn { background: none; border: 0; font-size: 18px; color: var(--mute); cursor: pointer; padding: 4px 8px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 60; transition: opacity .4s; max-width: calc(100% - 32px); text-align: center; }
.toast.out { opacity: 0; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; color: #fff; white-space: nowrap; display: inline-block; }
.big-badge { font-size: 15px; padding: 7px 16px; }
.stage-badge { background: #0a84ff; }
.quality-badge { background: var(--soft); color: var(--ink); }
.empty { text-align: center; padding: 48px; color: var(--mute); }
.btn { display: inline-block; border: 0; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; padding: 10px 20px;
  border-radius: 999px; background: var(--ink); color: var(--bg); transition: opacity .2s, transform .1s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.danger { color: var(--broken); }
.btn.small { padding: 7px 14px; font-size: 13px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--red); cursor: pointer; text-decoration: underline; }
.small-text { font-size: 13px; line-height: 1.5; }
.stat.static { cursor: default; }
.stat.static:hover { transform: none; }
button.p-row, button.mini, button.row { width: 100%; text-align: left; background: none; border: 0; font: inherit; color: inherit; cursor: pointer; }
.mini-list { margin-top: 16px; display: grid; gap: 6px; }
.mini { display: flex !important; flex-direction: column; gap: 6px; padding: 10px 12px !important; border-radius: 12px; background: var(--soft) !important; font-size: 14px; margin-bottom: 6px; }
.mini .tag { display: block; }
.mini-score .badge { font-size: 11px; }
.page-title { font-size: 40px; letter-spacing: -1.2px; margin: 40px 0 18px; }
.hero.compact { padding: 44px 0 24px; }
.hero.compact h1 { font-size: 46px; }
.section-h { margin: 34px 0 14px; }
code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--mute); margin: 24px 0 10px; }
a { color: var(--red); }

/* ---------- Explore ---------- */
.search, textarea, .modal input:not([type=checkbox]), .modal select:not(.pill) {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.search:focus, textarea:focus, .modal input:focus { border-color: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 15%, transparent); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.count-line { font-size: 13px; margin: 6px 0 12px; }
.list { padding: 4px 22px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line) !important; font-size: 15px; transition: background .15s; }
.row:last-child { border-bottom: 0 !important; }
.row:hover { background: var(--soft); margin: 0 -22px; padding: 14px 22px; }

/* ---------- Side panel ---------- */
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%); background: var(--card); z-index: 30;
  box-shadow: -10px 0 40px rgba(0,0,0,.18); padding: 28px; overflow-y: auto; transform: translateX(105%); transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.shade { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 29; opacity: 0; pointer-events: none; transition: opacity .3s; }
.panel-open .panel { transform: none; }
.panel-open .shade { opacity: 1; pointer-events: auto; }
.panel-top { display: flex; justify-content: space-between; align-items: center; }
.panel-title { font-size: 28px; letter-spacing: -.6px; margin: 8px 0 6px; line-height: 1.15; }
.detail { font-size: 15px; line-height: 1.5; }
.status-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 16px 0 4px; }
.pill.conf { font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.conf-high { color: var(--kept); } .conf-medium { color: var(--partly); } .conf-low { color: var(--broken); }
.timeline { list-style: none; padding: 0 0 0 16px; margin: 0; border-left: 2px solid var(--line); font-size: 14px; }
.timeline li { display: flex; gap: 12px; padding: 5px 0; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.timeline b { min-width: 64px; }
.reasoning { font-size: 15px; line-height: 1.55; }
.q-bars > div { display: grid; grid-template-columns: 100px 1fr 30px; align-items: center; gap: 10px; font-size: 14px; padding: 4px 0; }
.q-bars .track { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.q-bars .track i { display: block; height: 100%; background: var(--red); }
.sources { padding-left: 0; list-style: none; font-size: 13px; line-height: 1.8; margin: 8px 0; word-break: break-word; }
.panel-actions { display: flex; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.draft-note { background: color-mix(in srgb, var(--partly) 18%, transparent); padding: 10px 14px; border-radius: 12px; font-size: 13px; margin-top: 12px; }

/* ---------- Compare ---------- */
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 720px; }
td, th { padding: 14px 10px; border-bottom: 1px solid var(--line); text-align: left; }
tr:last-child td { border-bottom: 0; }
th { color: var(--mute); font-weight: 500; font-size: 13px; }
.cell-bar { width: 70px; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; display: inline-block; margin-right: 8px; vertical-align: middle; }
.cell-bar i { display: block; height: 100%; background: var(--red); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.stars.small { font-size: 15px; letter-spacing: 1px; }
.top { font-size: 11px; font-weight: 700; color: var(--kept); }
.balance { display: flex; gap: 16px; align-items: center; margin-top: 18px; }
.balance-icon { font-size: 28px; }
.side-by-side { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.col { padding: 16px; }
.col-head { font-weight: 600; margin-bottom: 12px; }

/* ---------- Ask ---------- */
.ask { max-width: 780px; margin: 0 auto; }
textarea { resize: vertical; min-height: 110px; }
.ask-actions { margin: 14px 0 24px; display: flex; gap: 8px; }
.answer-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.related { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; }

/* ---------- About ---------- */
.about .grid.three { grid-template-columns: repeat(3, 1fr); }
.about .grid.two { grid-template-columns: repeat(2, 1fr); margin-top: 18px; }
.about p { line-height: 1.55; }
.about-block { margin-top: 18px; }
.emoji { font-size: 30px; margin-bottom: 8px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.steps { line-height: 1.8; padding-left: 20px; margin: 0; }
.credit { text-align: center; font-size: 13px; margin-top: 40px; line-height: 1.6; }

/* ---------- Modals ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px; overflow-y: auto; animation: fade .25s ease both; }
.modal { width: min(560px, 100%); }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.modal label { display: block; font-size: 14px; margin: 12px 0; }
.modal label input { margin-top: 6px; }
.modal label.check { display: flex; gap: 8px; align-items: center; }
.modal-actions { display: flex; gap: 8px; align-items: center; margin: 14px 0; flex-wrap: wrap; }
.review-list { display: grid; gap: 10px; margin: 14px 0; max-height: 55vh; overflow-y: auto; }
.review-item { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.review-item.off { opacity: .45; }
.rv-fields { flex: 1; display: grid; gap: 6px; }
.rv-fields input { padding: 8px 12px !important; font-size: 15px !important; }
.rv-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rv-meta select { width: auto !important; padding: 6px 10px !important; font-size: 13px !important; }
.share-canvas { width: 100%; max-width: 360px; display: block; margin: 16px auto; border-radius: 16px; box-shadow: var(--shadow); }

@media (max-width: 860px) {
  .about .grid.three, .about .grid.two, .scale { grid-template-columns: 1fr; }
  .side-by-side { grid-template-columns: 1fr; }
  .page-title, .hero.compact h1 { font-size: 34px; }
  .panel { padding: 22px 16px; }
}
