:root {
  --bg: #0f1117; --panel: #171a23; --panel2: #1f2330; --line: rgba(255,255,255,0.08);
  --text: #e8eaf2; --muted: #8f96ad; --accent: #7c9cff; --good: #3ddc84; --near: #ffcc4d; --bad: #ff5c7a;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; }
button, input, select { font: inherit; color: inherit; }
h2 { margin: 0 0 6px; font-size: 24px; }
h3 { margin: 0 0 10px; font-size: 16px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
[hidden] { display: none !important; }

/* header */
.top { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-size: 18px; cursor: pointer; white-space: nowrap; }
.brand-accent { color: var(--good); }
nav { display: flex; gap: 4px; flex: 1; }
.navbtn { background: transparent; border: 0; padding: 8px 14px; border-radius: 8px; color: var(--muted); cursor: pointer; }
.navbtn:hover { background: var(--panel2); color: var(--text); }
.navbtn.active { background: var(--panel2); color: var(--text); font-weight: 600; }
.micbox { display: flex; align-items: center; gap: 10px; }
.meter { position: relative; width: 120px; height: 10px; background: #0a0c12; border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, #3ddc84 0 60%, #ffcc4d 60% 85%, #ff5c7a 85%); background-size: 120px 100%; transition: width .05s linear; }
.meter-gate { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff; opacity: .7; }

/* buttons */
.btn { background: var(--panel2); border: 1px solid var(--line); padding: 9px 16px; border-radius: 10px; cursor: pointer; transition: transform .05s, background .15s; min-height: 38px; touch-action: manipulation; }
.btn:hover { background: #262b3a; }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.big { padding: 14px 28px; font-size: 18px; font-weight: 700; }
.btn.primary { background: var(--accent); color: #0b0e1a; border-color: transparent; }
.btn.primary:hover { background: #93adff; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(255,92,122,.5); color: var(--bad); }
.btn.stop { background: var(--bad); color: #fff; border-color: transparent; }
.btn.on { border-color: var(--good); color: var(--good); }

main { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; }
.view { display: none; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* home */
.hero { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; padding: 20px 24px; border-radius: 16px; margin-bottom: 18px;
  background: linear-gradient(135deg, #1b2140, #171a23 60%); border: 1px solid var(--line); }
.hero h1 { margin: 0 0 4px; font-size: 26px; }
.hero .stat { display: flex; gap: 18px; color: var(--muted); }
.hero .stat b { color: var(--text); }
.hero .spacer { flex: 1; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--muted); }
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); color: #0b0e1a; border-color: transparent; font-weight: 600; }
.chip.goal { border-color: rgba(255,204,77,.4); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.wide { margin-bottom: 14px; }
.excard { cursor: pointer; transition: transform .08s, border-color .15s; display: flex; flex-direction: column; gap: 6px; }
.excard:hover { transform: translateY(-2px); border-color: rgba(124,156,255,.5); }
.excard .top-row { display: flex; align-items: center; gap: 8px; }
.excard .icon { font-size: 20px; }
.excard .name { font-weight: 600; flex: 1; }
.excard .best { font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--panel2); }
.excard .desc { color: var(--muted); font-size: 13px; flex: 1; }
.excard .foot { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.lvl { letter-spacing: 2px; color: var(--accent); }
.tag { padding: 1px 7px; border-radius: 6px; background: rgba(255,204,77,.15); color: var(--near); }
.tag.power { background: rgba(124,156,255,.15); color: var(--accent); }
.cathead { grid-column: 1 / -1; margin: 10px 0 -4px; display: flex; align-items: baseline; gap: 10px; }
.cathead h3 { margin: 0; }
.cathead span { color: var(--muted); font-size: 13px; }

/* programs */
.progcard { cursor: pointer; }
.progcard:hover { border-color: rgba(124,156,255,.5); }
.progcard .icon { font-size: 28px; }
.progcard .name { font-weight: 700; font-size: 17px; margin: 6px 0 4px; }
.progcard .meta { color: var(--muted); font-size: 13px; }

/* exercise */
.ex-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.ex-title { flex: 1; }
.ex-prog { display: flex; gap: 4px; align-items: center; color: var(--muted); font-size: 13px; }
.ex-prog .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); }
.ex-prog .dot.done { background: var(--good); border-color: transparent; }
.ex-prog .dot.cur { background: var(--accent); border-color: transparent; }
.ex-desc { color: var(--text); margin-bottom: 6px; }
.tipbox { margin-bottom: 12px; color: var(--muted); }
.tipbox summary { cursor: pointer; }
.tipbox p { margin: 6px 0 0 18px; color: var(--text); }
.controls { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.ctl label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.ctl input[type=range] { width: 160px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 7px 12px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--accent); color: #0b0e1a; font-weight: 600; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { background: transparent; border: 0; padding: 6px 12px; cursor: pointer; font-size: 16px; }
.stepper span { min-width: 34px; text-align: center; }
select { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input[type=number] { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100px; }
.startrow { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.status { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; padding: 8px 4px; font-size: 14px; color: var(--muted); position: relative; }
.status b { color: var(--text); font-size: 15px; }
.status-seg { font-weight: 700; color: var(--text); font-size: 16px; min-width: 130px; }
.status-seg.sing { color: var(--accent); }
.status-seg.listen { color: var(--muted); }
.status .live b { color: var(--good); font-size: 18px; }
.progressbar { flex-basis: 100%; height: 4px; background: var(--panel2); border-radius: 2px; overflow: hidden; }
.progressbar div { height: 100%; width: 0; background: var(--accent); }
.roll-wrap { position: relative; height: 46vh; min-height: 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.roll-wrap canvas { width: 100%; height: 100%; display: block; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; font-size: 56px; font-weight: 800; opacity: 0; text-shadow: 0 4px 24px rgba(0,0,0,.6); }
.overlay.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { opacity: 1; transform: scale(.8); } 60% { opacity: .9; transform: scale(1.05); } 100% { opacity: 0; transform: scale(1.1); } }
.tuner { display: grid; grid-template-columns: 140px 1fr 160px; align-items: center; gap: 16px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 10px; }
.tuner-note { font-size: 42px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.tuner-bar { position: relative; height: 26px; background: var(--panel2); border-radius: 13px; }
.tuner-zone { position: absolute; left: 37.5%; right: 37.5%; top: 0; bottom: 0; background: rgba(61,220,132,.18); border-radius: 13px; }
.tuner-needle { position: absolute; top: -4px; width: 4px; height: 34px; left: 50%; margin-left: -2px; background: #fff; border-radius: 2px; transition: left .06s linear, background .1s; }
.tuner-bar span { position: absolute; top: 30px; font-size: 11px; color: var(--muted); }
.tuner-bar .tl { left: 0; } .tuner-bar .tc { left: 50%; transform: translateX(-50%); } .tuner-bar .tr { right: 0; }
.tuner-info { display: flex; flex-direction: column; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.tuner-info span:first-child { font-size: 22px; color: var(--text); font-weight: 700; }
.toolpanel { margin-top: 10px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.toolpanel .bignum { font-size: 48px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 120px; }
.toolpanel .holdbar { width: 200px; height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.toolpanel .holdbar div { height: 100%; background: var(--good); width: 0; }
.toolpanel .phase { font-weight: 700; font-size: 18px; }

/* progress */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .v { font-size: 28px; font-weight: 800; }
.tile .l { color: var(--muted); font-size: 13px; }
.chart { width: 100%; height: 220px; display: block; }
.rangebar { width: 100%; height: 110px; display: block; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } .tuner { grid-template-columns: 1fr; } }
.bar-row { display: grid; grid-template-columns: 170px 1fr 44px; align-items: center; gap: 10px; margin: 6px 0; font-size: 14px; }
.bar-row .bar { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; }
.bar-row .bar div { height: 100%; }
.recent { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 14px; font-size: 14px; }
.recent .d { color: var(--muted); }
.goals { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
@media (max-width: 900px) { .goals { grid-template-columns: 1fr; } }
.goal h4 { margin: 0 0 6px; }
.goal ul { list-style: none; padding: 0; margin: 0; }
.goal li { padding: 4px 0; color: var(--muted); }
.goal li.done { color: var(--good); }

/* settings */
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; }
.field input[type=range] { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; }
.row select { flex: 1; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px 28px; max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; animation: fade .2s ease; }
.modal h2 { margin-bottom: 2px; }
.score-big { display: flex; align-items: center; gap: 22px; margin: 14px 0; }
.score-big .pct { font-size: 64px; font-weight: 900; line-height: 1; }
.score-big .stars { font-size: 34px; letter-spacing: 4px; }
.score-big .sub { color: var(--muted); }
.kpis { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; color: var(--muted); font-size: 14px; }
.kpis b { color: var(--text); }
.notes { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.note-chip { padding: 4px 8px; border-radius: 8px; font-size: 13px; font-variant-numeric: tabular-nums; color: #0b0e1a; font-weight: 600; }
.tips { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.tip { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--panel2); border-radius: 10px; }
.tip .i { font-size: 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.onb-step { margin: 14px 0; padding: 14px; background: var(--panel2); border-radius: 12px; }
.onb-step h4 { margin: 0 0 6px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #2a2f40; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90vw; }

/* --- mobile --- */
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  nav { order: 3; flex-basis: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  .navbtn { padding: 8px 10px; white-space: nowrap; font-size: 14px; }
  .brand { font-size: 16px; }
  .micbox { margin-left: auto; gap: 6px; }
  .meter { width: 64px; }
  main { padding: 12px 10px 40px; }
  h2 { font-size: 20px; }
  .hero { padding: 14px; gap: 12px; }
  .hero h1 { font-size: 20px; }
  .hero .stat { flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
  .hero .btn.big { width: 100%; }
  .grid { grid-template-columns: 1fr; }
  .controls { gap: 10px 14px; padding: 10px; }
  .ctl input[type=range] { width: 120px; }
  .startrow { flex-wrap: wrap; gap: 8px; }
  .status { gap: 8px 14px; font-size: 13px; }
  .status-seg { min-width: 100px; font-size: 15px; }
  .roll-wrap { height: 42vh; min-height: 240px; }
  .overlay { font-size: 36px; }
  .tuner { grid-template-columns: 1fr; gap: 10px; padding: 10px 12px; }
  .tuner-note { font-size: 32px; }
  .tuner-info { flex-direction: row; gap: 12px; text-align: left; align-items: baseline; }
  .toolpanel { gap: 12px; }
  .toolpanel .bignum { font-size: 36px; min-width: 90px; }
  .ex-head { flex-wrap: wrap; gap: 8px; }
  .ex-prog { flex-basis: 100%; }
  .modal { padding: 16px; max-height: 92vh; }
  .score-big { gap: 14px; }
  .score-big .pct { font-size: 48px; }
  .kpis { gap: 10px 14px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .bar-row { grid-template-columns: 120px 1fr 40px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .roll-wrap { height: 60vh; min-height: 200px; }
}
.install-banner { position: fixed; left: 12px; right: 12px; bottom: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; z-index: 25; }
.install-banner span { flex: 1; font-size: 14px; }
.foot { max-width: 1240px; margin: 0 auto; padding: 8px 20px 24px; color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--text); }
.page { max-width: 720px; }
.page h3 { margin-top: 22px; }
.page p, .page li { line-height: 1.55; }
.page ul { margin: 0 0 8px; padding-left: 20px; }
.page a { color: var(--accent); }
