/* 3D Workout. Colours are tokens on :root; light and dark follow the system unless Settings forces one. */
:root {
  --bg: #10141c; --panel: #171c27; --panel2: #1e2432; --text: #e8ecf5; --muted: #8f99ae; --line: #2b3347;
  --accent: #ff8a65; --accent-ink: #1d0d06; --accent2: #7a9cff; --good: #4cc38a; --bad: #ef6b6b; --shadow: 0 1px 2px rgba(0,0,0,.35);
  --stage-a: #202a40; --stage-b: #0f131b;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] { --bg: #f1f3f8; --panel: #ffffff; --panel2: #e8ecf4; --text: #161b27; --muted: #5a647a; --line: #d3d9e6; --accent: #e8552b; --accent-ink: #ffffff; --accent2: #3c63d6; --good: #1c8a58; --bad: #c2392b; --shadow: 0 1px 2px rgba(20,30,50,.12); --stage-a: #ffffff; --stage-b: #dfe5f1; color-scheme: light; }
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] { --bg: #f1f3f8; --panel: #ffffff; --panel2: #e8ecf4; --text: #161b27; --muted: #5a647a; --line: #d3d9e6; --accent: #e8552b; --accent-ink: #ffffff; --accent2: #3c63d6; --good: #1c8a58; --bad: #c2392b; --shadow: 0 1px 2px rgba(20,30,50,.12); --stage-a: #ffffff; --stage-b: #dfe5f1; color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.w3-boot { padding: 2rem; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.w3-wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px 40px; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
.w3-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 12px 0 10px; padding-top: max(12px, env(safe-area-inset-top)); }
.w3-brand { font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; }
.w3-brand small { font-weight: 600; color: var(--muted); font-size: .75rem; margin-left: .4rem; padding: .1em .5em; border: 1px solid var(--line); border-radius: 999px; }
.w3-tag { color: var(--muted); font-size: .85rem; }
.w3-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(min(330px, 100%), .7fr); gap: 18px; align-items: start; }
.w3-stagecol { position: sticky; top: 12px; min-width: 0; }

/* ---- stage ---- */
.w3-stage { position: relative; height: clamp(360px, calc(100vh - 220px), 720px); border-radius: 16px; overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(120% 90% at 50% 38%, var(--stage-a), var(--stage-b)); box-shadow: var(--shadow); }
.w3-stage canvas { position: absolute; left: 0; top: 0; display: block; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; outline-offset: -3px; }
.w3-stage.holding canvas { cursor: grabbing; }
.w3-stage.holding { border-color: var(--accent2); }
.w3-hud { position: absolute; left: 12px; right: 12px; top: 10px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; pointer-events: none; }
.w3-hud .name { font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; text-shadow: 0 1px 8px var(--stage-b); }
.w3-hud .sub { color: var(--muted); font-size: .8rem; }
.w3-hud .count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; background: color-mix(in srgb, var(--panel) 80%, transparent); border: 1px solid var(--line); border-radius: 10px; padding: .25em .6em; font-size: .9rem; }
.w3-hud .count small { display: block; color: var(--muted); font-weight: 500; font-size: .72rem; }
.w3-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; color: var(--muted); font-size: .78rem; pointer-events: none; transition: opacity .6s; padding: 0 12px; }
.w3-hint.gone { opacity: 0; }
.w3-overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--stage-b) 55%, transparent); text-align: center; }
.w3-overlay .box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px; max-width: 360px; box-shadow: var(--shadow); }
.w3-overlay h2 { margin: 0 0 4px; font-size: 1.1rem; }
.w3-overlay .big { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.w3-overlay p { margin: 4px 0 12px; color: var(--muted); }
.w3-overlay.rest { place-items: end center; background: linear-gradient(transparent 40%, color-mix(in srgb, var(--stage-b) 75%, transparent)); pointer-events: none; }
.w3-overlay.rest .box { pointer-events: auto; padding: 8px 16px 10px; margin-bottom: 14px; }
.w3-overlay.rest .big { font-size: 2rem; }

/* ---- toolbar ---- */
.w3-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.w3-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: .45em .8em; font-weight: 600; font-size: .88rem; min-height: 40px; display: inline-flex; align-items: center; gap: .4em; }
.w3-btn:hover { background: var(--panel2); }
.w3-btn[aria-pressed="true"] { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 18%, var(--panel)); }
.w3-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.w3-btn.primary:hover { filter: brightness(1.08); }
.w3-btn.icon { padding: .45em; min-width: 40px; justify-content: center; }
.w3-btn.danger { color: var(--bad); }
.w3-btn:disabled { opacity: .45; cursor: not-allowed; }
.w3-btn svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.w3-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.w3-seg button { border: 0; background: transparent; padding: .45em .7em; font-weight: 600; font-size: .85rem; min-height: 38px; }
.w3-seg button + button { border-left: 1px solid var(--line); }
.w3-seg button:hover { background: var(--panel2); }
.w3-select { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: .4em .6em; min-height: 40px; font-weight: 600; font-size: .88rem; }
.w3-spacer { flex: 1; }

/* ---- panel ---- */
.w3-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.w3-card h2, .w3-card h3 { margin: 0 0 6px; font-size: 1rem; }
.w3-note { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.w3-info .muscles { color: var(--accent2); font-size: .8rem; font-weight: 600; margin-bottom: 4px; }
.w3-info p { margin: 0 0 6px; }
.w3-info ul { margin: 6px 0 0; padding-left: 1.1em; color: var(--muted); font-size: .88rem; }
.w3-tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.w3-tab { flex: 1; border: 0; background: transparent; padding: .5em .6em; border-radius: 9px; font-weight: 700; font-size: .9rem; color: var(--muted); min-height: 40px; }
.w3-tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.w3-tab .n { margin-left: .35em; font-size: .75rem; opacity: .85; }
.w3-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.w3-chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: .25em .8em; font-size: .82rem; font-weight: 600; color: var(--muted); min-height: 32px; }
.w3-chip[aria-pressed="true"] { color: var(--text); border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 16%, var(--panel)); }

.w3-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.w3-ex { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.w3-ex[data-active="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.w3-ex .main { border: 0; background: transparent; padding: 0; text-align: left; display: block; width: 100%; }
.w3-ex canvas { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; background: radial-gradient(100% 90% at 50% 40%, var(--stage-a), var(--stage-b)); }
.w3-ex .txt { padding: 8px 10px 2px; }
.w3-ex .nm { font-weight: 700; font-size: .92rem; }
.w3-ex .mu { color: var(--muted); font-size: .74rem; }
.w3-ex .add { margin: 6px 10px 10px; justify-content: center; }

.w3-empty { text-align: center; padding: 22px 12px; color: var(--muted); }
.w3-empty .w3-btn { margin: 4px; }
.w3-item { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.w3-item[data-active="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.w3-item[data-done="true"] { opacity: .55; }
.w3-item .head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.w3-item .idx { width: 24px; height: 24px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-size: .75rem; font-weight: 700; flex: none; }
.w3-item .title { border: 0; background: transparent; font-weight: 700; text-align: left; padding: 0; min-width: 0; overflow-wrap: anywhere; }
.w3-item .moves { display: flex; gap: 4px; }
.w3-item .moves .w3-btn { min-height: 34px; min-width: 34px; padding: .2em; }
.w3-steps { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.w3-step { display: flex; align-items: center; gap: 4px; font-size: .78rem; color: var(--muted); }
.w3-step label { margin-right: 2px; }
.w3-step input { width: 3.2em; text-align: center; border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; padding: .3em 0; min-height: 34px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.w3-step input::-webkit-outer-spin-button, .w3-step input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.w3-step button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; width: 34px; height: 34px; font-weight: 700; font-size: 1rem; line-height: 1; }
.w3-total { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.w3-total b { font-variant-numeric: tabular-nums; }
.w3-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.w3-row:last-child { border-bottom: 0; }
.w3-row .lbl { font-weight: 600; }
.w3-row .lbl small { display: block; color: var(--muted); font-weight: 400; }
.w3-msg { min-height: 1.3em; font-size: .85rem; margin-top: 6px; }
.w3-msg.err { color: var(--bad); } .w3-msg.ok { color: var(--good); }
.w3-toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: .55em 1em; border-radius: 10px; font-weight: 600; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; max-width: calc(100vw - 32px); }
.w3-toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 880px) {
  .w3-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .w3-stagecol { top: 0; z-index: 10; background: var(--bg); padding: 0 0 8px; margin: 0 -16px; padding-inline: 16px; }
  .w3-stage { height: clamp(230px, 36vh, 400px); border-radius: 14px; }
  .w3-bar { gap: 6px; margin-top: 8px; }
  .w3-bar .w3-btn { min-height: 38px; padding: .3em .65em; font-size: .82rem; }
  .w3-bar .w3-btn.icon, .w3-bar .w3-btn.label-hide { min-width: 44px; justify-content: center; }
  .w3-bar .w3-select { min-height: 38px; padding: .3em .4em; }
  .w3-seg button { min-height: 36px; padding: .3em .55em; font-size: .8rem; }
  .w3-btn.label-hide span { display: none; }
  .w3-hint { display: none; }
  .w3-hud .name { font-size: 1rem; }
}
@media (max-height: 520px) and (max-width: 880px) { .w3-stagecol { position: static; } .w3-stage { height: 80vh; } }
@media (prefers-reduced-motion: reduce) { .w3-toast, .w3-hint { transition: none; } }
