:root {
  --bg: #0a0d12;
  --bg-soft: #10151d;
  --card: #111823;
  --card-hi: #16202d;
  --line: #212c3a;
  --line-soft: #1a2431;
  --text: #e8eef6;
  --dim: #8b9bb0;
  --dimmer: #62708a;
  --accent: #7ee787;
  --accent-soft: rgba(126, 231, 135, .12);
  --warm: #ffd479;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0 auto;
  max-width: 1180px;
  padding: 0 18px calc(48px + env(safe-area-inset-bottom));
  background:
    radial-gradient(900px 420px at 15% -8%, rgba(126,231,135,.07), transparent 70%),
    radial-gradient(700px 380px at 92% 0%, rgba(88,166,255,.06), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 0 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.logo {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(160deg, #1d2a38, #131b25);
  border: 1px solid var(--line);
  color: var(--accent);
  flex: none;
}

.brand-text { display: flex; flex-direction: column; gap: 1px; }

h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.2px;
}

.sub { font-size: 12.5px; color: var(--dim); }

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
}
.live i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(126,231,135,.15);
}

/* ---------- hero ---------- */

.hero { padding: 6px 0 4px; }

.lede {
  margin: 0 0 18px;
  max-width: 720px;
  color: #b9c6d6;
  font-size: 14.5px;
  line-height: 1.62;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.stat {
  flex: 1 1 150px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
}
.stat b {
  display: block;
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.3px;
}
.stat span { font-size: 11.5px; color: var(--dimmer); }

/* ---------- controls ---------- */

.controls {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 0 12px;
  margin-bottom: 2px;
  background: linear-gradient(var(--bg) 78%, rgba(10,13,18,0));
  backdrop-filter: blur(6px);
}

.search-row { position: relative; }

#q {
  width: 100%;
  padding: 13px 44px 13px 15px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .15s, background .15s;
}
#q::placeholder { color: var(--dimmer); }
#q:focus { border-color: #35506a; background: var(--card-hi); }

.icon-btn {
  position: absolute;
  top: 50%; right: 8px;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 0;
  background: #1b2634;
  color: var(--dim);
  font-size: 13px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); }

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 1px 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chips.sorts { padding-top: 8px; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #131a24;
  color: #aebbcb;
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: all .14s;
}
.chip:hover { border-color: #33475e; color: var(--text); }
.chip.on {
  background: var(--accent-soft);
  border-color: rgba(126,231,135,.45);
  color: var(--accent);
}
.chip .n {
  font-size: 11px;
  opacity: .65;
  font-variant-numeric: tabular-nums;
}
.chips.sorts .chip { background: transparent; border-color: transparent; color: var(--dim); padding: 6px 9px; }
.chips.sorts .chip:hover { color: var(--text); }
.chips.sorts .chip.on { background: #17202c; border-color: var(--line); color: var(--text); }

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 12px;
  margin-top: 6px;
}

.card {
  display: flex;
  gap: 12px;
  min-width: 0;
  padding: 15px;
  border-radius: var(--radius);
  background: linear-gradient(170deg, #121a25, #0f151e);
  border: 1px solid var(--line-soft);
  cursor: pointer;
  transition: transform .12s, border-color .15s, background .15s;
}
.card:hover {
  transform: translateY(-1px);
  border-color: #2b3f55;
  background: linear-gradient(170deg, #15202d, #111823);
}
.card:active { transform: scale(.995); }

.mark {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 650;
  color: #0a0d12;
  background: linear-gradient(150deg, #9ff0a6, #6fd879);
}

.card-body { min-width: 0; flex: 1; }

.card-title {
  margin: 0 0 3px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-line {
  margin: 0 0 10px;
  font-size: 12.8px;
  line-height: 1.5;
  color: #93a3b8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 39px;
}

.nums {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.grow {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.grow small { display: block; font-size: 10.5px; font-weight: 400; color: var(--dimmer); }
.grow.flat { color: var(--dimmer); font-weight: 500; }

.total {
  font-size: 12.5px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.spark {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
  margin-bottom: 1px;
}
.spark i {
  display: block;
  width: 4px;
  border-radius: 1px;
  background: #3b5570;
  min-height: 3px;
}
.spark i.hi { background: var(--accent); }

.meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--dimmer);
  overflow: hidden;
}

.badge {
  flex: none;
  padding: 2px 7px;
  border-radius: 6px;
  background: #1a2432;
  border: 1px solid #24344a;
  color: #93a8bf;
  font-size: 11px;
}
.who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- states ---------- */

.status {
  margin: 26px 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: #131a24;
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 13.5px;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 56px 16px;
  color: var(--dim);
  text-align: center;
}
.empty b { color: var(--text); font-size: 15px; }

.foot {
  margin-top: 38px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.6;
  color: var(--dimmer);
  max-width: 720px;
}
.foot p { margin: 0 0 8px; }
.foot .dim { opacity: .75; }

/* ---------- sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(4, 7, 11, .66);
  backdrop-filter: blur(3px);
  animation: fade .15s ease-out;
}

.sheet-box {
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  background: #0f1520;
  border: 1px solid var(--line);
  border-bottom: 0;
  animation: rise .2s ease-out;
  padding-bottom: env(safe-area-inset-bottom);
}

@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(22px); opacity: .6 } }

.sheet-inner { padding: 18px 18px 24px; }

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}
.sheet-head h2 {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -.3px;
}
.kicker {
  font-size: 11.5px;
  color: var(--dimmer);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.close {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #16202c;
  color: var(--dim);
  font-size: 14px;
  cursor: pointer;
}
.close:hover { color: var(--text); }

.one-liner {
  margin: 0 0 16px;
  color: #a9b8ca;
  font-size: 14px;
  line-height: 1.55;
}

.summary { margin: 0 0 14px; font-size: 14px; line-height: 1.65; color: #cfdae7; }

.sheet h3 {
  margin: 20px 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--dimmer);
}

.why { margin: 0; padding-left: 18px; color: #c3d0de; font-size: 13.6px; line-height: 1.6; }
.why li { margin-bottom: 5px; }

.install {
  padding: 10px 12px;
  border-radius: 10px;
  background: #0b1017;
  border: 1px solid var(--line-soft);
  font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #a8e6b0;
  white-space: pre-wrap;
  word-break: break-word;
}

.risk {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 196, 92, .07);
  border: 1px solid rgba(255, 196, 92, .28);
  color: #f0cf98;
  font-size: 13px;
  line-height: 1.55;
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.fact {
  padding: 10px 11px;
  border-radius: 11px;
  background: #121a25;
  border: 1px solid var(--line-soft);
}
.fact b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.fact span { font-size: 10.5px; color: var(--dimmer); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 3px 8px;
  border-radius: 6px;
  background: #16202c;
  border: 1px solid var(--line-soft);
  color: #8fa4bb;
  font-size: 11.5px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 22px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 16px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #16202c;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #08210c; }
.btn:hover { filter: brightness(1.08); }

.note {
  margin: 16px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--dimmer);
}

.cta {
  margin: 4px 0 0;
  padding: 11px 13px;
  border-radius: 11px;
  background: #121a25;
  border: 1px dashed #2a3a4d;
  color: #93a3b8;
  font-size: 12.5px;
  line-height: 1.55;
}

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  body { padding: 0 13px calc(40px + env(safe-area-inset-bottom)); }
  .top { padding: 16px 0 6px; }
  h1 { font-size: 17.5px; }
  .brand .sub { display: none; }
  .live-label { display: none; }
  .live { font-size: 11px; }
  .lede { font-size: 13.5px; }
  .stats { gap: 7px; }
  .stat { flex: 1 1 96px; padding: 10px 11px; }
  .stat b { font-size: 17px; }
  .stat span { font-size: 10px; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .card { padding: 13px; }
  .card-line { min-height: 0; -webkit-line-clamp: 2; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .sheet-box { max-height: 94vh; border-radius: 18px 18px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
