@font-face { font-family: 'Inter'; src: url(../assets/fonts/Inter.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Poppins'; src: url(../assets/fonts/Poppins-Medium.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Poppins'; src: url(../assets/fonts/Poppins-SemiBold.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Poppins'; src: url(../assets/fonts/Poppins-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }
:root {
  --orange: #F28C28;
  --orange-hover: #E07B18;
  --orange-soft: #FDEEDD;
  --on-orange: #20252B;
  --teal: #527C82;
  --teal-soft: #E4EDEE;
  --bg: #F5F3EF;
  --surface: #FFFFFF;
  --surface-2: #FAF9F7;
  --border: #E5E7EB;
  --text: #20252B;
  --text-muted: #5E656D;
  --text-faint: #9AA0A6;
  --success: #3E9B6A;
  --danger: #D64545;
  --trained: #D93F3F;
  --skin: #ECEAE6;
  --muscle: #CBCFD4;
  --muscle-line: #F5F3EF;
  --fig: #A7ADB4;
  --eq: #D3D7DC;
  --font-head: 'Poppins', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(32, 37, 43, 0.06);
  --shadow-lg: 0 16px 48px rgba(32, 37, 43, 0.14);
  --focus: 0 0 0 3px rgba(242, 140, 40, 0.35);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 160ms;
  --mo-body: #A9B2BC;
  --mo-far: #CDD3D9;
  --mo-hair: #7A8490;
  --mo-iron: #2B3138;
  --mo-metal: #8E98A3;
  --mo-frame: #D5DAE0;
  --mo-frame-d: #B4BCC5;
  --mo-pad: #527C82;
  --mo-hl: #F28C28;
  --mo-hl-far: #F7BE86;
  --mo-floor: rgba(32, 37, 43, 0.035);
  --top: 68px;
  --gap: 24px;
}

:root[data-theme="dark"] {
  --orange-hover: #F59D47;
  --orange-soft: rgba(242, 140, 40, 0.14);
  --teal: #6A979D;
  --teal-soft: rgba(106, 151, 157, 0.16);
  --bg: #16191D;
  --surface: #20252B;
  --surface-2: #2A3038;
  --border: #343B44;
  --text: #F5F3EF;
  --text-muted: #A3AAB1;
  --text-faint: #6F767E;
  --trained: #E24B4B;
  --skin: #2A3038;
  --muscle: #46505B;
  --muscle-line: #20252B;
  --fig: #6E7782;
  --eq: #3F4751;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --mo-body: #8B95A0;
  --mo-far: #59626D;
  --mo-hair: #66707B;
  --mo-iron: #0F1216;
  --mo-metal: #9AA3AD;
  --mo-frame: #3A424C;
  --mo-frame-d: #4C5560;
  --mo-pad: #5F8E94;
  --mo-hl: #F28C28;
  --mo-hl-far: #9A6331;
  --mo-floor: rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
h1, h2, h3 { font-family: var(--font-head); margin: 0; font-weight: 600; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; }
svg { display: block; }
button:focus-visible { outline: none; box-shadow: var(--focus); }

#boot {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 400ms var(--ease), visibility 400ms;
}
#boot.done { opacity: 0; visibility: hidden; }
.boot-in { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.boot-in > img { width: 88px; height: 88px; }
.boot-name { font-family: var(--font-head); font-size: 28px; font-weight: 600; }
.boot-nova { display: flex; align-items: center; gap: 8px; color: var(--text-faint); font-size: 13px; margin-top: 24px; }
.boot-nova img { width: 20px; height: 20px; }

.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

.top {
  flex: none; position: relative; z-index: 20;
  height: var(--top); padding: 0 32px;
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; gap: 24px;
  border-bottom: 1px solid var(--border);
}
.brand, .drawer-brand { display: flex; align-items: center; gap: 12px; font-family: var(--font-head); font-size: 20px; font-weight: 600; white-space: nowrap; }
.brand img, .drawer-brand img { width: 36px; height: 36px; }
.drawer-brand { display: none; }
.tabs { margin-left: auto; display: flex; gap: 6px; }
.tabs button {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--text-muted); cursor: pointer;
  font-weight: 500; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tabs button svg, .icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button:hover { background: var(--surface); color: var(--text); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tabs button.active svg { stroke: var(--orange); }
.icon-btn { flex: none; width: 40px; height: 40px; border: 0; border-radius: var(--r-sm); background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text); transition: background var(--dur) var(--ease); }
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; }
.scrim { display: none; }

main {
  flex: 1; min-height: 0; width: 100%; max-width: 1480px; margin: 0 auto;
  padding: var(--gap) 32px; padding-bottom: max(var(--gap), env(safe-area-inset-bottom));
  display: flex;
}
.view { display: none; flex: 1; min-width: 0; min-height: 0; }
.view.active { display: flex; flex-direction: column; animation: rise 260ms var(--ease); }
.view.scroll { overflow-y: auto; margin: calc(var(--gap) * -1) -32px; padding: var(--gap) 32px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: var(--gap); }

.map { position: relative; min-height: 0; display: flex; flex-direction: column; padding: 20px 28px 24px; }
.map-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; min-height: 40px; }
.legend { display: flex; gap: 20px; color: var(--text-muted); font-size: 14px; flex-wrap: wrap; }
.legend > span { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ready { background: var(--muscle); }
.dot.recovering { background: var(--trained); }

.figures { flex: 1; min-height: 0; margin-top: 12px; overflow: hidden; position: relative; touch-action: none; border-radius: var(--r-md); }
.zoom { width: 100%; height: 100%; display: flex; justify-content: center; align-items: flex-start; gap: var(--fgap, 48px); transform-origin: 0 0; }
.zoom.anim { transition: transform 240ms var(--ease); }
.map.zoomed .figures { cursor: grab; }
.map.zoomed .figures:active { cursor: grabbing; }
.zoom-ctl { position: absolute; right: 16px; top: 72px; z-index: 2; display: flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.zoom-ctl button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.zoom-ctl button:hover { background: var(--surface-2); color: var(--text); }
.zoom-ctl svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map:not(.zoomed) .zoom-ctl button[data-z="out"], .map:not(.zoomed) .zoom-ctl button[data-z="fit"] { opacity: 0.4; pointer-events: none; }
.grab { display: none; }
.fig { margin: 0; min-height: 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.fig-svg { flex: none; position: relative; width: 120px; height: 300px; }
.fig-svg svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.fig figcaption { flex: none; color: var(--text-faint); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.map:not(.single) .side-toggle { display: none; }
.map.single .fig figcaption { display: none; }
.map.single .figures[data-side="front"] .fig[data-view="back"],
.map.single .figures[data-side="back"] .fig[data-view="front"] { display: none; }

.skin { fill: var(--skin); }
.muscle {
  fill: var(--muscle); stroke: var(--muscle-line); stroke-width: 3;
  cursor: pointer; outline: none;
  transition: fill 300ms var(--ease), opacity var(--dur) var(--ease);
}
.muscle.hover { opacity: 0.78; }
.muscle.sel { stroke: var(--orange); stroke-width: 16; paint-order: stroke; }
.muscle.sel.trained { stroke: var(--text); }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 4px; gap: 4px; }
.seg button {
  border: 0; background: transparent; padding: 7px 16px; border-radius: 10px;
  color: var(--text-muted); cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.panel {
  min-height: 0; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

.empty { text-align: center; padding: 8px 4px 0; }
.empty img { width: 56px; height: 56px; }
.empty h2 { font-size: 21px; margin-top: 16px; }
.empty p { color: var(--text-muted); margin: 6px 0 0; }
.label { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); font-family: var(--font-body); }
.rec-title { margin: 32px 0 10px; }
.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer;
  transition: border-color var(--dur) var(--ease);
}
.rec:hover { border-color: var(--trained); }
.rec .dot { background: var(--trained); }
.rec .rn { font-weight: 500; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rec .rt { color: var(--text-muted); font-size: 14px; white-space: nowrap; }
.rec-none { color: var(--text-faint); font-size: 14px; margin: 0; }

.d-head { flex: none; display: flex; align-items: flex-start; gap: 12px; }
.d-head > div { flex: 1; min-width: 0; }
.d-name { font-size: 26px; line-height: 1.2; margin-top: 2px; }
.d-latin { font-style: italic; color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.d-close { margin: -6px -8px 0 0; }
.d-about { flex: none; margin: 14px 0 0; font-size: 14px; color: var(--text-muted); }

.status { flex: none; margin-top: 16px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; flex-wrap: wrap; }
.status-info { flex: 1 1 auto; }
.chip { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.chip .dot { width: 10px; height: 10px; }
.chip.ready .dot { background: var(--success); }
.chip.recovering .dot { background: var(--trained); }
.status-sub { color: var(--text-muted); font-size: 13px; margin: 2px 0 0 18px; white-space: nowrap; }
.actions { flex: none; display: flex; gap: 8px; margin-left: auto; }
.bar { height: 6px; border-radius: 999px; background: var(--border); margin-top: 12px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--trained); transition: width 400ms var(--ease); }

.btn {
  border: 0; border-radius: var(--r-md); padding: 10px 18px; cursor: pointer;
  font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--orange); color: var(--on-orange); }
.btn.primary:hover { background: var(--orange-hover); }
.btn.ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--text-faint); }
.btn.square { padding: 10px; }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }

.ex-block { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 20px; }
.ex-label { cursor: default; }
.ex-stage { flex: 1; min-height: 150px; max-height: 360px; position: relative; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.ex-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ex-cue { flex: none; color: var(--text-muted); font-size: 14px; margin: 10px 2px 0; min-height: 21px; }
.ex-pick { flex: none; display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.ex-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: var(--r-md); border: 1px solid var(--border);
  background: transparent; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.ex-opt:hover { border-color: var(--text-faint); }
.ex-opt.active { border-color: var(--orange); background: var(--orange-soft); }
.ex-num { flex: none; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.ex-opt.active .ex-num { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }
.ex-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.ex-eq { flex: none; font-size: 12px; font-weight: 600; color: var(--teal); background: var(--teal-soft); padding: 2px 10px; border-radius: 999px; white-space: nowrap; }

.fg { stroke: var(--fig); fill: none; stroke-linecap: round; }
.fgf { fill: var(--fig); }
.tp { fill: var(--fig); stroke: var(--fig); stroke-width: 9; stroke-linejoin: round; }
.far { opacity: 0.45; }
.hl { stroke: var(--orange); fill: none; stroke-linecap: round; }
.hl.tp { fill: var(--orange); stroke: var(--orange); }
.hlf { fill: var(--orange); }
.pp { fill: var(--text); }
.ph { fill: var(--surface-2); }
.eq { fill: var(--eq); }
.eqs { stroke: var(--eq); stroke-linecap: round; fill: none; }
.cb, .bd { stroke: var(--teal); stroke-linecap: round; }
.rope { fill: none; stroke: var(--teal); stroke-width: 1.6; }
.gr { stroke: var(--border); stroke-linecap: round; }

.mo-body { fill: var(--mo-body); stroke: var(--surface-2); stroke-width: 1.1; stroke-linejoin: round; }
.mo-body-f { fill: var(--mo-body); }
.mo-edge { fill: none; stroke: var(--surface-2); stroke-width: 1.1; stroke-linejoin: round; stroke-linecap: round; }
.mo-fold { fill: none; stroke: var(--surface-2); stroke-width: 0.9; stroke-linecap: round; }
.mo-far { fill: var(--mo-far); stroke: var(--surface-2); stroke-width: 1.1; stroke-linejoin: round; }
line.mo-body, line.mo-far { stroke: var(--mo-body); }
line.mo-far { stroke: var(--mo-far); }
.cap { stroke-linecap: round; }
.mo-hair { fill: var(--mo-hair); }
.mo-skin { fill: var(--mo-body); }
.mo-hl { fill: var(--mo-hl); }
.mo-hl.far { fill: var(--mo-hl-far); }
.mo-spine { stroke: var(--surface-2); stroke-linecap: round; opacity: 0.7; }
.mo-iron { fill: var(--mo-iron); }
.mo-round { stroke: var(--mo-iron); stroke-width: 2; stroke-linejoin: round; }
.mo-ring { fill: none; stroke: var(--mo-metal); stroke-width: 1.2; opacity: 0.55; }
.mo-metal { fill: var(--mo-metal); }
.mo-metal-s { stroke: var(--mo-metal); fill: none; stroke-linecap: round; }
.mo-frame { fill: var(--mo-frame); }
.mo-frame-s { stroke: var(--mo-frame); fill: none; stroke-linecap: round; }
.mo-frame-d { fill: var(--mo-frame-d); }
.mo-rod { stroke: var(--mo-frame-d); }
.mo-pad { fill: var(--mo-pad); }
.mo-pad-s { stroke: var(--mo-pad); fill: none; }
.mo-wall { fill: var(--mo-frame); }
.mo-cable { fill: none; stroke: var(--text-muted); stroke-width: 1.3; }
.mo-rope { stroke: var(--mo-pad); fill: none; }
.mo-band { stroke: var(--teal); fill: none; opacity: 0.9; }
.mo-jrope { fill: none; stroke: var(--text-muted); stroke-width: 1.5; stroke-linecap: round; }
.mo-trace { fill: none; stroke: var(--mo-hl); stroke-width: 1.3; stroke-dasharray: 1.5 4; stroke-linecap: round; opacity: 0.6; }
.mo-ground { stroke: var(--border); stroke-width: 2; }
.mo-floor { fill: var(--mo-floor); }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.mm-skin { fill: var(--skin); }
.mm-m { fill: var(--muscle); stroke: var(--muscle-line); stroke-width: 10; stroke-linejoin: round; }
.mm-m.p { fill: var(--orange); }
.mm-m.s { fill: color-mix(in srgb, var(--orange) 36%, var(--muscle)); }

.ex-top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.see-all {
  flex: none; display: inline-flex; align-items: center; gap: 2px; margin: -6px -8px -6px 0; padding: 6px 6px 6px 10px;
  border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.see-all svg { width: 16px; height: 16px; fill: none; stroke: var(--orange); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur) var(--ease); }
.see-all:hover { background: var(--surface-2); color: var(--text); }
.see-all:hover svg { transform: translateX(2px); }

.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 4px; }
.stepper button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.stepper button:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.stepper svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
#restVal { min-width: 64px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.lib { width: 100%; max-width: 1180px; margin: 0 auto; }
.lib-head { position: sticky; top: calc(var(--gap) * -1); z-index: 3; background: var(--bg); padding: 16px 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 10px; }
.lib-filters { display: contents; }
.lib-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.lib-title h1 { font-size: 28px; }
.lib-count { color: var(--text-faint); font-size: 14px; font-weight: 500; }
.search {
  min-width: 0; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 6px 0 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); cursor: text;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.search:focus-within { border-color: var(--orange); box-shadow: var(--focus); }
.search > svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--text-faint); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--text); font: inherit; outline: none; }
.search input::placeholder { color: var(--text-faint); }
.search input::-webkit-search-cancel-button { display: none; }
.search-x { flex: none; width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.search-x:hover { background: var(--surface-2); color: var(--text); }
.search-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.search-x[hidden] { display: none; }
.pick {
  flex: none; max-width: 320px; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 12px 0 14px;
  border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.pick:hover { border-color: var(--text-faint); }
.pick.on { border-color: var(--orange); background: var(--orange-soft); }
.pick svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--text-muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pick.on svg { stroke: var(--orange); }
.pick .pick-chev { width: 16px; height: 16px; stroke-width: 2.2; }
.pick > span:not(.pick-x) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-x { display: none; width: 26px; height: 26px; margin: 0 -6px 0 -2px; border-radius: 8px; align-items: center; justify-content: center; }
.pick-x:hover { background: color-mix(in srgb, var(--orange) 22%, transparent); }
.pick .pick-x svg { width: 16px; height: 16px; stroke: var(--text); stroke-width: 2.2; }
.pick.on .pick-x { display: flex; }
.pick.on .pick-chev { display: none; }
.chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.fchip {
  flex: none; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.fchip:hover { color: var(--text); border-color: var(--text-faint); }
.fchip.on { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }

.lib-sec { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; font-size: 18px; margin: 18px 0 2px; }
.lib-sec:first-child { margin-top: 0; }
.lib-sec span { font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--text-faint); }
.lib-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; padding-bottom: 8px; }
.xc {
  position: relative; display: flex; align-items: center; gap: 16px; min-height: 108px; padding: 12px 16px 12px 12px;
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); cursor: pointer; content-visibility: auto; contain-intrinsic-size: auto 108px;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.xc:hover { border-color: var(--text-faint); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(32, 37, 43, 0.08); }
.xc:focus-visible { outline: none; box-shadow: var(--focus); }
.xc-map { flex: none; width: 76px; height: 84px; display: flex; gap: 3px; justify-content: center; align-items: center; padding: 6px 4px; background: var(--surface-2); border-radius: 12px; }
.xc-map .mm { height: 100%; width: auto; }
.xc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding-right: 22px; }
.xc-name { font-family: var(--font-head); font-weight: 600; font-size: 16px; line-height: 1.3; }
.xc-mus { color: var(--text-muted); font-size: 13px; line-height: 1.4; }
.xc-eq { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.xc-eq i, .tag { font-style: normal; font-size: 12px; font-weight: 600; color: var(--teal); background: var(--teal-soft); padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.xc-anim { position: absolute; top: 12px; right: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--orange-soft); display: flex; align-items: center; justify-content: center; }
.xc-anim svg { width: 11px; height: 11px; fill: var(--orange); margin-left: 1px; }
.lib-empty { grid-column: 1 / -1; text-align: center; padding: 56px 16px; }
.lib-empty img { width: 56px; height: 56px; }
.lib-empty h2 { font-size: 20px; margin-top: 14px; }
.lib-empty p { color: var(--text-muted); margin: 6px 0 20px; }

.xov { position: fixed; inset: 0; z-index: 60; background: rgba(22, 25, 29, 0.45); display: flex; align-items: center; justify-content: center; padding: 24px; opacity: 0; visibility: hidden; transition: opacity 200ms var(--ease), visibility 200ms; }
.xov.on { opacity: 1; visibility: visible; }
.xov-box {
  width: 100%; max-width: 640px; max-height: calc(100dvh - 48px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(0.98); transition: transform 240ms var(--ease);
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.xov.on .xov-box { transform: none; }
.xd-stage { position: relative; height: 290px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.xd-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage-map { height: 100%; display: flex; justify-content: center; gap: 32px; padding: 22px; }
.stage-map .mm { position: static; height: 100%; width: auto; }
.ex-stage.as-map .stage-map { position: absolute; inset: 0; gap: 18px; padding: 14px; }
.xd-body { padding: 22px 26px 26px; }
.xd-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.xd-name { font-size: 24px; line-height: 1.25; }
.xd-head .icon-btn { margin: -4px -10px 0 0; }
.xd-cue { color: var(--text-muted); margin: 6px 0 0; }
.xd-mus { display: flex; gap: 22px; margin-top: 22px; align-items: flex-start; }
.xd-map { flex: none; display: flex; gap: 6px; height: 156px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); }
.xd-map .mm { height: 100%; width: auto; }
.no-anim .xd-map { display: none; }
.xd-groups { flex: 1; min-width: 0; }
.xd-groups .label { margin-bottom: 8px; }
.xd-groups .label:not(:first-child) { margin-top: 18px; }
.mchips, .xd-eq { display: flex; flex-wrap: wrap; gap: 8px; }
.xd-eq .tag { font-size: 13px; padding: 4px 12px; }
.mchip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; font-size: 14px;
  transition: border-color var(--dur) var(--ease);
}
.mchip:hover { border-color: var(--orange); }
.mchip i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.mchip.p i { background: var(--orange); }
.mchip.s i { background: color-mix(in srgb, var(--orange) 36%, var(--muscle)); }

.xov-box.ov-pick { max-width: 580px; padding: 22px 24px 24px; }
.pk-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.pk-head h2 { font-size: 20px; }
.pk-head .icon-btn { margin-right: -8px; }
.pk-all, .pk-m {
  display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.pk-all { width: 100%; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); font-weight: 600; }
.pk-all svg { width: 20px; height: 20px; fill: none; stroke: var(--text-muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pk-all:hover, .pk-m:hover { border-color: var(--text-faint); }
.pk-all.on, .pk-m.on { border-color: var(--orange); background: var(--orange-soft); }
.pk-all .n, .pk-m .n { margin-left: auto; color: var(--text-faint); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.pk-group { margin-top: 18px; }
.pk-group .label { margin-bottom: 8px; }
.pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.pk-m { padding: 10px 12px; border-radius: 12px; background: var(--surface); font-weight: 500; font-size: 14px; }
.pk-m span:first-child { min-width: 0; }

.narrow { width: 100%; max-width: 680px; margin: 0 auto; }
.narrow > h1 { font-size: 28px; margin: 4px 0 20px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; padding: 20px 24px; margin-bottom: 14px; flex-wrap: wrap; }
.setting h3 { font-size: 17px; }
.setting p { margin: 4px 0 0; color: var(--text-muted); font-size: 14px; }
.about { text-align: center; padding: 48px 28px; }
.about > img { width: 96px; height: 96px; }
.about h1 { font-size: 30px; margin-top: 18px; }
.about .ver { color: var(--text-faint); margin: 4px 0 0; font-size: 14px; }
.about-text { max-width: 420px; margin: 20px auto 0; color: var(--text-muted); }
.studio {
  display: flex; align-items: center; gap: 16px; max-width: 400px; margin: 32px auto 0; padding: 16px 18px;
  border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); text-decoration: none; text-align: left;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.studio:hover { border-color: var(--orange); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(242, 140, 40, 0.14); }
.studio:focus-visible { outline: none; box-shadow: var(--focus); }
.studio-icon { flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--orange-soft); display: flex; align-items: center; justify-content: center; }
.studio-icon img { width: 30px; height: 30px; border-radius: 8px; }
.studio-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.studio-name { font-family: var(--font-head); font-weight: 600; font-size: 15px; }
.studio-sub { color: var(--text-muted); font-size: 13px; }
.studio-go { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--orange); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur) var(--ease); }
.studio:hover .studio-go { transform: translate(2px, -2px); }

.tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--text); color: var(--bg); font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: var(--r-sm); white-space: nowrap;
  opacity: 0; transform: translate(-50%, -140%); transition: opacity 120ms var(--ease);
}
.tip.on { opacity: 1; }

.modal { position: fixed; inset: 0; z-index: 60; background: rgba(22, 25, 29, 0.45); display: none; align-items: center; justify-content: center; padding: 24px; }
.modal.on { display: flex; }
.modal-box { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 28px; max-width: 420px; width: 100%; }
.modal-box h3 { font-size: 20px; }
.modal-box p { color: var(--text-muted); margin: 10px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

@media (max-width: 1100px) {
  :root { --gap: 16px; }
  .layout { grid-template-columns: minmax(0, 1fr) 360px; }
  main { padding-left: 20px; padding-right: 20px; }
  .view.scroll { margin: calc(var(--gap) * -1) -20px; padding: var(--gap) 20px; }
  .figures { gap: 28px; }
}

@media (max-width: 900px) {
  :root { --top: 60px; }
  .top { padding: 0 12px; padding-top: env(safe-area-inset-top); gap: 8px; }
  .brand img { width: 32px; height: 32px; }
  .menu-btn { display: flex; position: relative; z-index: 45; }
  .drawer-brand { display: flex; padding: 4px 8px 24px; }
  .tabs {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(280px, 82vw); z-index: 40;
    flex-direction: column; gap: 4px; padding: calc(16px + env(safe-area-inset-top)) 16px 24px;
    background: var(--surface); box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform 240ms var(--ease);
  }
  .tabs.open { transform: none; }
  .tabs button { padding: 14px 16px; }
  .tabs button.active { background: var(--surface-2); box-shadow: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(22, 25, 29, 0.4); opacity: 0; visibility: hidden; transition: opacity 240ms var(--ease), visibility 240ms; }
  .scrim.on { opacity: 1; visibility: visible; }
  .menu-btn.hide { visibility: hidden; }
}

@media (max-width: 720px) {
  :root { --gap: 12px; }
  main { padding-left: 12px; padding-right: 12px; padding-bottom: 0; }
  .view.scroll { margin: calc(var(--gap) * -1) -12px; padding: var(--gap) 12px; padding-bottom: max(var(--gap), env(safe-area-inset-bottom)); }
  .layout { display: block; position: relative; margin: 0 -12px; }
  .map { height: 100%; border-radius: 0; border: 0; box-shadow: none; background: transparent; padding: 4px 16px calc(var(--peek, 150px) + 8px); }
  .map-head { min-height: 40px; }
  .layout.open .legend { display: none; }
  .layout.open .map-head { justify-content: center; }
  .figures { margin-top: 4px; }
  .zoom-ctl { right: 12px; top: 56px; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
    height: 150px; overflow: hidden; padding: 0 18px calc(16px + env(safe-area-inset-bottom));
    border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0;
    box-shadow: 0 -8px 32px rgba(22, 25, 29, 0.12);
    transition: height 280ms var(--ease);
  }
  .panel.full { overflow-y: auto; }
  .panel > * { flex-shrink: 0; }
  .grab { display: flex; justify-content: center; align-items: center; flex: none; width: calc(100% + 36px); margin: 0 -18px 4px; height: 26px; border: 0; background: transparent; cursor: pointer; touch-action: none; position: sticky; top: 0; z-index: 1; background: var(--surface); }
  .grab i { width: 40px; height: 5px; border-radius: 999px; background: var(--border); transition: background var(--dur) var(--ease); }
  .grab:hover i { background: var(--text-faint); }
  .ex-label { cursor: pointer; }
  .ex-opt { padding: 8px 10px; }
  .ex-pick { gap: 6px; margin-top: 10px; }
  .ex-cue { margin-top: 8px; font-size: 13px; }
  .ex-top { margin-bottom: 8px; }
  .empty { display: flex; align-items: center; gap: 14px; text-align: left; padding: 0; }
  .empty img { width: 40px; height: 40px; flex: none; }
  .empty h2 { font-size: 18px; margin: 0; }
  .empty p { font-size: 13px; margin-top: 2px; }
  .rec-title { margin-top: 14px; }
  .rec-list { flex-direction: row; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -18px; padding: 2px 18px 4px; }
  .rec-list::-webkit-scrollbar { display: none; }
  .rec-list { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .panel.full .rec-list { -webkit-mask-image: none; mask-image: none; }
  .panel.full .rec-list { flex-wrap: wrap; overflow: visible; }
  .rec { flex: none; width: auto; padding: 6px 12px; gap: 8px; border-radius: 999px; }
  .rec .dot { width: 8px; height: 8px; }
  .rec .rn { flex: none; font-size: 14px; }
  .rec .rt { font-size: 13px; }
  .rt-pre { display: none; }
  .d-name { font-size: 22px; }
  .status { margin-top: 12px; padding: 12px 14px; }
  .d-about { order: 5; margin-top: 16px; }
  .ex-block { flex: none; margin-top: 16px; }
  .ex-stage { flex: none; height: 210px; min-height: 0; max-height: none; }
  .setting { padding: 18px; }
  .seg button { padding: 7px 12px; }
}

@media (max-height: 560px) and (min-width: 721px) {
  :root { --top: 56px; --gap: 12px; }
  .zoom-ctl { display: none; }
  .map { padding: 12px 18px 14px; }
  .panel { padding: 18px; }
  .layout { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.5fr); }
  .panel.open { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-rows: auto auto 1fr; column-gap: 20px; align-content: start; }
  .panel.open .d-head, .panel.open .d-about, .panel.open .status { grid-column: 1; }
  .panel.open .status { align-self: start; }
  .panel.open .ex-block { grid-column: 2; grid-row: 1 / span 3; margin-top: 0; min-height: 0; }
  .d-name { font-size: 22px; }
  .ex-stage { min-height: 96px; }
  .ex-opt { padding: 6px 10px; }
  .ex-pick { gap: 5px; margin-top: 8px; }
  .ex-cue { margin-top: 6px; font-size: 13px; }
}

@media (max-width: 720px) {
  .lib-title h1 { font-size: 24px; }
  .lib-head { grid-template-columns: minmax(0, 1fr); padding: 12px 0; gap: 10px; }
  .search, .pick { height: 44px; }
  .lib-filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 2px; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .lib-filters::-webkit-scrollbar { display: none; }
  .pick { height: 36px; max-width: none; border-radius: 999px; padding: 0 10px 0 12px; gap: 6px; font-size: 14px; }
  .pick svg { width: 18px; height: 18px; }
  .chips { flex-wrap: nowrap; }
  .lib-list { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .xc { min-height: 96px; gap: 14px; padding: 10px 14px 10px 10px; contain-intrinsic-size: auto 96px; }
  .xc-map { width: 68px; height: 76px; }
  .xc-name { font-size: 15px; }
  .xov { align-items: flex-end; padding: 0; }
  .xov-box { max-width: none; max-height: 92dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; transform: translateY(48px); padding-bottom: env(safe-area-inset-bottom); }
  .xov-box.ov-pick { max-width: none; padding: 18px 18px 24px; }
  .xd-stage { height: 230px; }
  .xd-body { padding: 18px 18px 22px; }
  .xd-name { font-size: 21px; }
  .xd-mus { gap: 16px; margin-top: 18px; }
  .xd-map { height: 124px; padding: 8px; }
  .pk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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

#getapp { position: fixed; inset: 0; z-index: 2000; overflow-y: auto; display: flex; padding: calc(24px + env(safe-area-inset-top)) 22px calc(24px + env(safe-area-inset-bottom)); background: #20252B; color: #F5F3EF; font-family: var(--font-body); }
#getapp .ga-c { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; margin: auto; }
#getapp .ga-logo { width: 88px; height: 88px; border-radius: 20px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35); }
#getapp h1 { margin: 4px 0 0; font-family: var(--font-head); font-weight: 700; font-size: 28px; }
#getapp .ga-d { margin: 0 0 6px; color: #C9CDD2; line-height: 1.5; }
#getapp .ga-btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 50px; border-radius: var(--r-md); font-family: var(--font-head); font-weight: 600; font-size: 16px; text-decoration: none; }
#getapp .ga-dl { background: var(--orange); color: var(--on-orange); }
#getapp .ga-open { border: 1px solid #3A424B; color: #F5F3EF; }
#getapp .ga-steps { margin: 0; padding: 14px 16px 14px 34px; width: 100%; text-align: left; border-radius: var(--r-md); background: #2A3038; line-height: 1.55; font-size: 14px; color: #E2E5E8; }
#getapp .ga-web { background: none; border: 0; color: #9AA0A6; text-decoration: underline; padding: 10px; font: inherit; font-size: 14px; cursor: pointer; }
