/* Vocal Mirror — app shell styles. Dark, calm, big type. Variables named like js/viz/theme.js
   (--vm-<kebab-key>) so the canvas renderers pick up the same colours. */
:root {
  color-scheme: dark;
  --vm-bg: #0e1116;
  --vm-panel: #151a22;
  --vm-panel-raised: #1c2330;
  --vm-grid: #232c3a;
  --vm-grid-strong: #34415a;
  --vm-text: #e6ecf5;
  --vm-text-dim: #98a4b8;
  --vm-accent: #4fd1c5;
  --vm-good: #48bb78;
  --vm-warn: #ecc94b;
  --vm-bad: #f56565;
  --vm-info: #63b3ed;
  --vm-pitch: #4fd1c5;
  --vm-target: #a0aec0;
  --vm-font: 13px system-ui, "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  --vm-font-small: 11px system-ui, "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  --vm-font-big: 600 20px system-ui, "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  --ink-on-accent: #07201d;
  --radius: 16px;
  --radius-sm: 10px;
  --gap: 16px;
  --header-h: 56px;
  --nav-h: 0px;
  --maxw: 1240px;
  --focus: 0 0 0 3px rgba(79, 209, 197, .55);
  --sans: system-ui, "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Hiragino Sans", "Yu Gothic UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--vm-bg); color: var(--vm-text); font: 16px/1.55 var(--sans);
  min-height: 100vh; padding-bottom: var(--nav-h); overflow-x: hidden;
  word-break: keep-all; overflow-wrap: break-word;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.25; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
a { color: var(--vm-accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.skip-link { position: absolute; left: -999px; top: 6px; background: var(--vm-accent); color: var(--ink-on-accent); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
[hidden] { display: none !important; }
.muted { color: var(--vm-text-dim); }
.small { font-size: 14px; }
.ico { display: inline-flex; vertical-align: middle; }

/* ---------------------------------------------------------------- header */
.app-header {
  position: sticky; top: 0; z-index: 20; height: var(--header-h); display: flex; align-items: center; gap: 12px;
  padding: 0 max(16px, env(safe-area-inset-left)); background: rgba(14, 17, 22, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--vm-grid);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--vm-text); text-decoration: none; font-weight: 800; font-size: 17px; }
.brand-mark { display: inline-flex; }
.spacer { flex: 1; }
.nav { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.nav-item { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; color: var(--vm-text-dim); text-decoration: none; font-weight: 600; font-size: 15px; }
.nav-item:hover { color: var(--vm-text); background: var(--vm-panel); }
.nav-item.on { color: var(--vm-text); background: var(--vm-panel-raised); }
.langs { display: flex; gap: 2px; background: var(--vm-panel); border-radius: 999px; padding: 3px; }
.lang { border: 0; background: none; color: var(--vm-text-dim); padding: 5px 10px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; }
.lang.on { background: var(--vm-panel-raised); color: var(--vm-text); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; color: var(--vm-text-dim); }
.icon-btn:hover, .icon-btn.on { color: var(--vm-text); background: var(--vm-panel); }

/* ---------------------------------------------------------------- generic */
main#app { outline: none; }
.screen { max-width: var(--maxw); margin: 0 auto; padding: 20px 16px 40px; }
.screen.center { text-align: center; padding-top: 80px; display: grid; gap: 14px; justify-items: center; }
.hero { max-width: 640px; margin: 0 auto; text-align: center; display: grid; gap: 18px; justify-items: center; padding-top: 4vh; }
.lead { font-size: 18px; color: #c6d0de; max-width: 34em; }
.fine { font-size: 14px; color: var(--vm-text-dim); max-width: 34em; }
.tip { display: flex; gap: 10px; align-items: flex-start; text-align: left; color: var(--vm-text-dim); font-size: 14px; background: var(--vm-panel); border-radius: var(--radius-sm); padding: 10px 14px; max-width: 34em; }
.tip .ico { color: var(--vm-accent); flex: none; margin-top: 2px; }
.links { font-size: 14px; color: var(--vm-text-dim); }
.links a, .link { color: var(--vm-text-dim); }
.row-center { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; text-decoration: none;
  min-height: 46px; padding: 10px 22px; border-radius: 999px; font-weight: 700; font-size: 16px; transition: transform .08s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn-primary { background: var(--vm-accent); color: var(--ink-on-accent); }
.btn-primary:hover:not([disabled]) { background: #6fe0d5; }
.btn-secondary { background: var(--vm-panel-raised); color: var(--vm-text); border: 1px solid var(--vm-grid-strong); }
.btn-secondary:hover { background: #243044; }
.btn-ghost { background: transparent; color: var(--vm-text-dim); }
.btn-ghost:hover { color: var(--vm-text); background: var(--vm-panel); }
.btn-danger { background: #c53030; color: #fff; }
.btn-big { min-height: 60px; padding: 14px 38px; font-size: 20px; }
.btn-small { min-height: 36px; padding: 6px 14px; font-size: 14px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--vm-panel-raised); color: var(--vm-text-dim); white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.badge.conf-high { color: var(--vm-good); }
.badge.conf-medium { color: var(--vm-warn); }
.badge.conf-low { color: var(--vm-text-dim); }
.badge.reg-chest { color: #f6ad55; } .badge.reg-mix { color: #b794f4; } .badge.reg-falsetto { color: #63b3ed; }

.callout { text-align: left; background: var(--vm-panel); border: 1px solid var(--vm-grid-strong); border-radius: var(--radius-sm); padding: 12px 16px; max-width: 34em; width: 100%; display: grid; gap: 6px; }
.callout.warn { border-color: #7a6a20; background: #1f1b0e; }
.callout ul { padding-left: 18px; display: grid; gap: 4px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--vm-grid-strong); background: var(--vm-panel-raised); color: var(--vm-text); border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600; }
.chip:hover, .chip.on { border-color: var(--vm-accent); color: var(--vm-accent); }
.chip.on { background: rgba(79, 209, 197, .12); }

/* welcome */
.hero-orb { filter: drop-shadow(0 8px 30px rgba(217, 118, 122, .25)); }
.steps { list-style: none; padding: 0; display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; color: var(--vm-text-dim); font-size: 14px; }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps b { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--vm-panel-raised); color: var(--vm-accent); align-items: center; justify-content: center; font-size: 13px; }

/* microphone */
.mic-box { display: grid; gap: 18px; justify-items: center; }
.mic-ico { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; background: var(--vm-panel-raised); color: var(--vm-accent); }
.mic-ico.warn { color: var(--vm-warn); }
.mic-ico.ok { color: var(--vm-good); }
.mic-ico.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(79, 209, 197, .45); } 50% { box-shadow: 0 0 0 18px rgba(79, 209, 197, 0); } }
.help-list { text-align: left; max-width: 34em; padding-left: 20px; display: grid; gap: 8px; color: #c6d0de; }

/* setup */
.setup-step { display: grid; gap: 14px; justify-items: center; width: 100%; }
.dots { display: flex; gap: 10px; justify-content: center; }
.dots .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--vm-grid-strong); display: inline-block; }
.dots .dot.done { background: var(--vm-accent); opacity: .55; }
.dots .dot.now { background: var(--vm-accent); opacity: 1; box-shadow: 0 0 0 4px rgba(79, 209, 197, .25); }
.dots-host { display: grid; gap: 8px; justify-items: center; }
.step-names { display: flex; gap: 16px; font-size: 13px; color: var(--vm-text-dim); flex-wrap: wrap; justify-content: center; }
.step-names .on { color: var(--vm-text); font-weight: 700; }
.level-ring { position: relative; display: grid; place-items: center; }
.level-ring .trk { stroke: var(--vm-grid-strong); }
.level-ring .val { stroke: var(--vm-text-dim); transition: stroke-dashoffset .08s linear, stroke .2s; }
.level-ring.heard .val { stroke: var(--vm-accent); }
.level-inner { position: absolute; inset: 0; display: grid; place-items: center; }
.prompt { max-width: 18em; }
.status { min-height: 1.6em; color: var(--vm-accent); font-weight: 700; }
.retry { background: #1f1b0e; border: 1px solid #7a6a20; color: #f6e7a8; border-radius: var(--radius-sm); padding: 10px 16px; font-weight: 600; max-width: 30em; }
.note-line { font-size: 20px; font-weight: 700; min-height: 1.6em; }
.setup-summary { display: grid; gap: 16px; justify-items: center; width: 100%; }
.facts { display: grid; gap: 10px; width: 100%; max-width: 30em; background: var(--vm-panel); border-radius: var(--radius); padding: 16px 20px; text-align: left; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.facts dt { color: var(--vm-text-dim); }
.facts dd { font-weight: 700; font-size: 18px; text-align: right; }
.facts small { color: var(--vm-text-dim); font-weight: 500; font-size: 13px; }

/* meters (own DOM, i18n labels) */
.meter { background: var(--vm-panel-raised); border-radius: var(--radius-sm); padding: 10px 14px 12px; --conf: .35; }
.m-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.m-title { font-weight: 700; font-size: 14px; }
.m-lowconf { font-size: 11px; color: var(--vm-text-dim); border: 1px dashed var(--vm-text-dim); border-radius: 999px; padding: 0 7px; }
.m-status { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--vm-text-dim); }
.m-body { display: grid; grid-template-columns: minmax(40px, max-content) 1fr minmax(40px, max-content); gap: 10px; align-items: center; }
.m-end { font-size: 12.5px; color: var(--vm-text-dim); white-space: nowrap; }
.m-end.lo { text-align: right; }
.m-track { position: relative; height: 12px; border-radius: 6px; background: var(--vm-grid); }
.m-zone { position: absolute; top: -3px; bottom: -3px; border-radius: 8px; background: rgba(72, 187, 120, .16); box-shadow: inset 0 0 0 1px rgba(72, 187, 120, .45); }
.m-mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: rgba(230, 236, 245, .25); }
.m-needle { position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; background: var(--vm-accent); border: 3px solid #f4f7fb; box-shadow: 0 0 0 3px rgba(0, 0, 0, .3), 0 0 14px rgba(79, 209, 197, .55); opacity: var(--conf); transition: background .25s; }
.meter[data-level=idle] .m-needle { opacity: .3; box-shadow: 0 0 0 3px rgba(0, 0, 0, .3); background: var(--vm-text-dim); }
.meter[data-level=good] .m-needle { background: var(--vm-good); box-shadow: 0 0 0 3px rgba(0, 0, 0, .3), 0 0 14px rgba(72, 187, 120, .6); }
.meter[data-level=off][data-practice] .m-needle { background: var(--vm-warn); box-shadow: 0 0 0 3px rgba(0, 0, 0, .3), 0 0 14px rgba(236, 201, 75, .5); }
.m-hint { margin-top: 8px; font-size: 12px; color: var(--vm-text-dim); }
.meter-big { padding: 22px 24px 26px; border-radius: var(--radius); }
.meter-big .m-title { font-size: 20px; }
.meter-big .m-end { font-size: 15px; }
.meter-big .m-track { height: 22px; border-radius: 11px; }
.meter-big .m-zone { top: -6px; bottom: -6px; border-radius: 14px; background: rgba(72, 187, 120, .2); box-shadow: inset 0 0 0 2px rgba(72, 187, 120, .6); }
.meter-big .m-needle { width: 34px; height: 34px; margin: -17px 0 0 -17px; border-width: 4px; }
.meter-big .m-hint { font-size: 14px; }

/* panels */
.panel { background: var(--vm-panel); border: 1px solid var(--vm-grid); border-radius: var(--radius); padding: 12px; min-width: 0; position: relative; }
.panel > header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 2px 4px 10px; }
.panel > header h2 { font-size: 17px; }
.panel > header small { color: var(--vm-text-dim); font-size: 13px; }
.panel > header .badge { margin-left: auto; }
.panel canvas { display: block; width: 100%; border-radius: 12px; }
.panel-error canvas { display: none; }
.panel-error::after { content: attr(data-fallback); display: block; padding: 30px 12px; text-align: center; color: var(--vm-text-dim); }

/* toasts, dialogs, overlay */
#toasts { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; }
.toast { background: #2a3548; border: 1px solid var(--vm-grid-strong); padding: 10px 18px; border-radius: 999px; font-weight: 600; box-shadow: 0 6px 24px rgba(0, 0, 0, .4); transition: opacity .3s; }
.toast.out { opacity: 0; }
dialog.dlg { background: var(--vm-panel-raised); color: var(--vm-text); border: 1px solid var(--vm-grid-strong); border-radius: var(--radius); padding: 22px; max-width: min(92vw, 420px); }
dialog.dlg::backdrop { background: rgba(0, 0, 0, .6); }
.tap-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(8, 10, 14, .88); color: var(--vm-text); border: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* mobile: bottom navigation */
@media (max-width: 720px) {
  :root { --nav-h: 64px; --header-h: 52px; }
  .app-header { backdrop-filter: none; background: var(--vm-bg); }
  body[data-chrome=full] { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 30; justify-content: space-around; gap: 0; background: rgba(14, 17, 22, .97); border-top: 1px solid var(--vm-grid); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .nav-item { flex-direction: column; gap: 2px; padding: 4px 10px; font-size: 12px; border-radius: 12px; min-width: 64px; }
  .brand-name { display: none; }
  .lang { padding: 5px 8px; font-size: 12px; }
  .btn-big { padding: 14px 28px; font-size: 18px; }
  .screen { padding: 14px 12px 32px; }
}
