:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { width: 100%; height: 100%; position: relative; }
.screen {
  width: 100%; height: 100%; position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column;
}
.screen.hidden { display: none; }
.focusable {
  transition: all 0.15s ease; border: 2px solid transparent;
  cursor: pointer; outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}
.hidden { display: none !important; }

/* ---------- Layout shell ---------- */
.hdr {
  flex: 0 0 auto;
  padding: 14px 22px 12px;
  background: var(--bg-primary);
  border-bottom: 1px solid #20202c;
}
.back {
  font-size: 13px; color: var(--accent);
  letter-spacing: 0.5px; margin-bottom: 3px; font-weight: 600;
}
.hdr-title {
  font-size: 23px; font-weight: 700; letter-spacing: -0.3px;
  line-height: 1.15;
}
.hdr-sub {
  font-size: 13px; color: var(--text-secondary); margin-top: 3px;
}
.content {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 16px 18px 22px;
}
.hint {
  flex: 0 0 auto;
  height: 34px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-muted);
  background: var(--bg-primary); border-top: 1px solid #20202c;
  letter-spacing: 0.3px;
}
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background: #2c2c3c; border-radius: 3px; }
.content::-webkit-scrollbar-track { background: transparent; }

/* ---------- Section labels ---------- */
.seclabel {
  font-size: 12px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text-muted);
  margin: 6px 4px 10px;
}
.seclabel + .seclabel,
.card + .seclabel { margin-top: 18px; }

/* ---------- Cards ---------- */
.card {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 72px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 12px 16px 12px 22px;
  margin-bottom: 10px;
}
.card::before {
  content: ''; position: absolute; left: 7px; top: 12px; bottom: 12px;
  width: 5px; border-radius: 3px;
  background: var(--cat, var(--accent));
}
.card-main { flex: 1 1 auto; min-width: 0; }
.card-name {
  font-size: 17px; font-weight: 650; line-height: 1.25;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.card-desc {
  font-size: 13px; color: var(--text-secondary); margin-top: 3px;
  line-height: 1.3;
}
.count {
  flex: 0 0 auto;
  min-width: 34px; height: 34px; padding: 0 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-tertiary); color: var(--text-secondary);
  border-radius: 17px; font-size: 15px; font-weight: 700;
}
.chev { flex: 0 0 auto; font-size: 24px; color: var(--text-muted); padding-right: 4px; }
.flag { color: var(--accent-secondary); font-size: 14px; }
.foot-note {
  text-align: center; color: var(--text-muted); font-size: 12px;
  margin: 14px 0 4px; letter-spacing: 0.4px;
}

.eqcard { min-height: 78px; }
.eqcard .card-name { font-size: 16px; }

/* ---------- Formula rendering ---------- */
.eq {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 0 7px; line-height: 1.5;
}
.eq.small { font-size: 16px; color: var(--text-secondary); margin-top: 6px; }
.eq.small .sp { color: #d8d8e4; }
.eq.big {
  font-size: 29px; justify-content: center; gap: 0 9px;
  color: var(--text-primary); font-weight: 600;
}
.eq .sp sub { font-size: 0.66em; vertical-align: -0.25em; }
.eq .sp sup { font-size: 0.66em; vertical-align: 0.45em; }
.eq .arrow { color: var(--accent); font-weight: 700; padding: 0 2px; }
.eq .plus { color: var(--text-muted); }
.eq.big .plus { color: var(--text-secondary); }
.gen { color: var(--text-secondary); font-weight: 500; }
.gen .sp { font-style: normal; }

.cat-blurb {
  position: relative;
  background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 14px 16px 14px 22px; margin-bottom: 16px;
}
.cat-blurb::before {
  content: ''; position: absolute; left: 7px; top: 12px; bottom: 12px;
  width: 5px; border-radius: 3px; background: var(--cat, var(--accent));
}
.cat-blurb .gen { font-size: 17px; }
.gen-def { font-size: 13px; color: var(--text-secondary); margin-top: 7px; line-height: 1.4; }

/* ---------- Detail screen ---------- */
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cat, var(--accent));
  border: 1px solid var(--cat, var(--accent));
  border-radius: 20px; padding: 4px 12px; margin-bottom: 12px;
}
.eqname { font-size: 22px; font-weight: 700; line-height: 1.2; margin-bottom: 14px; }
.formula-card {
  background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 24px 16px 16px; margin-bottom: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.balanced {
  font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  color: var(--accent-secondary);
}
.desc {
  font-size: 15px; line-height: 1.45; color: var(--text-primary);
  margin-bottom: 14px;
}
.fact {
  position: relative;
  background: var(--bg-tertiary); border-radius: var(--radius-md);
  padding: 13px 16px 13px 18px; margin-bottom: 18px;
  font-size: 14px; line-height: 1.45; color: var(--text-secondary);
  border-left: 4px solid var(--accent);
}
.fact-k {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--accent); margin-bottom: 5px;
}
.btnrow { display: flex; gap: 12px; margin-bottom: 14px; }
.btn {
  flex: 1 1 0; min-height: 56px;
  background: var(--bg-tertiary); color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 16px; font-weight: 650;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.pos { text-align: center; font-size: 12px; color: var(--text-muted); letter-spacing: 0.4px; }

/* ---------- Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 40px 24px 24px; gap: 10px;
}
.empty-star { font-size: 56px; color: var(--text-muted); line-height: 1; }
.empty-t { font-size: 19px; font-weight: 700; }
.empty-s { font-size: 14px; color: var(--text-secondary); line-height: 1.5; max-width: 380px; }
.empty .btn { flex: 0 0 auto; min-width: 220px; margin-top: 12px; padding: 0 24px; }
