/* =========================================================================
   cubetimer — styles
   Everything visual is driven by the custom properties below. The settings
   drawer writes to them at runtime (see js/settings.js), so to add a new
   adjustable property: add a variable here + one SCHEMA entry.
   ========================================================================= */

:root {
  /* colours */
  --bg: #0f1115;
  --bg-2: #1a1d29;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #8a91a0;
  --accent: #7c8cff;
  --accent-text: #0f1115;
  --ready: #3ddc97;
  --holding: #ff5d6c;
  --inspect: #ffb547;
  --timer-color: #e7e9ee;
  --danger: #ff5d6c;
  --cube-U: #ffffff; --cube-F: #22c55e; --cube-R: #ef4444;
  --cube-D: #facc15; --cube-L: #fb923c; --cube-B: #3b82f6;
  /* alg diagrams: yellow top, green front (derived from the cube colours) */
  --alg-U: var(--cube-D); --alg-D: var(--cube-U); --alg-F: var(--cube-F);
  --alg-B: var(--cube-B); --alg-R: var(--cube-L); --alg-L: var(--cube-R);
  --alg-mask: color-mix(in srgb, var(--muted) 30%, var(--surface-2));
  --learn-w: min(1040px, 64vw);

  /* type */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-timer: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-scramble: var(--font-timer);
  --timer-size: 9rem;
  --timer-weight: 500;
  --timer-tracking: -0.02em;
  --timer-glow: 0px;
  --scramble-size: 1.35rem;
  --ui-scale: 1;

  /* shape */
  --radius: 14px;
  --border-w: 1px;
  --shadow: 0.35;
  --panel-opacity: 1;
  --glass: 0px;
  --density: 1;
  --space: calc(1rem * var(--density));

  /* layout */
  --sidebar-w: 300px;
  --max-w: 1800px;
  --timer-offset: 0vh;
  --preview-w: 220px;
  --bottom-h: 190px;

  /* background */
  --bg-angle: 160deg;
  --bg-blur: 0px;
  --bg-dim: 0.4;
  --bg-layer: var(--bg);

  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark light;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(16px * var(--ui-scale)); -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
kbd {
  font-family: var(--font-timer); font-size: .8em; padding: .1em .45em;
  border: var(--border-w) solid var(--border); border-bottom-width: calc(var(--border-w) + 1px);
  border-radius: 6px; background: var(--surface-2);
}

/* ---------- background layer ---------- */
#bg {
  position: fixed; inset: 0; z-index: -1;
  background: var(--bg-layer);
  filter: blur(var(--bg-blur));
  transform: scale(1.06);
}
body[data-bg="image"] #bg::after {
  content: ""; position: absolute; inset: 0; background: var(--bg); opacity: var(--bg-dim);
}

/* ---------- panels ---------- */
.panel {
  background: color-mix(in srgb, var(--surface) calc(var(--panel-opacity) * 100%), transparent);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(0 0 0 / calc(var(--shadow) * .3)), 0 12px 32px -12px rgb(0 0 0 / calc(var(--shadow) * .6));
  backdrop-filter: blur(var(--glass));
  -webkit-backdrop-filter: blur(var(--glass));
  padding: calc(var(--space) * .9);
  min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: calc(var(--space) * .6); }
.panel h2 { margin: 0; font-size: .78rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------- buttons & inputs ---------- */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 2.25rem; height: 2.25rem; flex: none;
  border-radius: calc(var(--radius) * .7);
  border: var(--border-w) solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.95); }
.icon-btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.icon-btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 1.1rem; height: 1.1rem; }

.btn {
  padding: .55rem .9rem; border-radius: calc(var(--radius) * .7);
  border: var(--border-w) solid var(--border); background: var(--surface-2);
  font-size: .875rem; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }

select, input[type="text"], input[type="search"], input[type="email"], input[type="password"], input:not([type]), textarea {
  background: var(--surface-2);
  border: var(--border-w) solid var(--border);
  border-radius: calc(var(--radius) * .6);
  padding: .45rem .65rem;
  min-width: 0;
}
textarea { width: 100%; resize: vertical; font-family: var(--font-timer); font-size: .85rem; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select-wrap select { font-weight: 500; }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: calc(var(--radius) * .7); background: var(--surface-2); }
.seg button { border: 0; background: transparent; padding: .35rem .75rem; border-radius: calc(var(--radius) * .5); font-size: .8rem; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .15); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--space);
  padding: calc(var(--space) * .75) calc(var(--space) * 1.25);
  width: 100%; max-width: var(--max-w); margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.logo {
  width: 1.4rem; height: 1.4rem; border-radius: 6px;
  background:
    linear-gradient(var(--bg), var(--bg)) 33.3% 0 / 1.5px 100% no-repeat,
    linear-gradient(var(--bg), var(--bg)) 66.6% 0 / 1.5px 100% no-repeat,
    linear-gradient(var(--bg), var(--bg)) 0 33.3% / 100% 1.5px no-repeat,
    linear-gradient(var(--bg), var(--bg)) 0 66.6% / 100% 1.5px no-repeat,
    var(--accent);
}
.selectors { display: flex; gap: .5rem; align-items: center; flex: 1; justify-content: center; min-width: 0; }
.selectors select { max-width: 13rem; }
.top-actions { display: flex; gap: .4rem; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  display: grid; min-width: 12rem; padding: 6px;
  background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius);
  box-shadow: 0 16px 40px -8px rgb(0 0 0 / .4);
}
.menu-pop button { text-align: left; border: 0; background: none; padding: .55rem .7rem; border-radius: calc(var(--radius) * .5); font-size: .875rem; }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop .danger { color: var(--danger); }

/* ---------- main layout ---------- */
.app {
  flex: 1; min-height: 0;
  width: 100%; max-width: var(--max-w); margin: 0 auto;
  display: grid; gap: var(--space);
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "side main";
  padding: 0 calc(var(--space) * 1.25) calc(var(--space) * 1.25);
}
body[data-sidebar="right"] .app { grid-template-columns: minmax(0, 1fr) var(--sidebar-w); grid-template-areas: "main side"; }
/* interface detail levels: 0 zen · 1 minimal · 2 focused · 3 standard · 4 everything */
body[data-detail="0"] .app, body[data-detail="1"] .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
body[data-detail="0"] .side, body[data-detail="1"] .side { display: none; }
body[data-detail="0"] .sub-stats, body[data-detail="0"] .last-actions, body[data-detail="0"] .splits:empty { display: none !important; }
body[data-detail="0"] .bottom, body[data-detail="1"] .bottom, body[data-detail="2"] .bottom { display: none; }
body[data-detail="0"] .hint, body[data-detail="1"] .hint, body[data-detail="2"] .hint { display: none; }
body[data-detail="0"] .input-bar, body[data-detail="1"] .input-bar, body[data-detail="2"] .input-bar, body[data-detail="3"] .input-bar { display: none; }
body[data-detail="0"] .scramble-tag { display: none; }

.side { grid-area: side; display: flex; flex-direction: column; gap: var(--space); min-height: 0; }
@media (min-width: 901px) { body { height: 100dvh; } }
.main { grid-area: main; display: flex; flex-direction: column; gap: var(--space); min-height: 0; min-width: 0; }

/* ---------- scramble ---------- */
.scramble-bar { display: flex; align-items: center; gap: .5rem; padding: calc(var(--space) * .6) calc(var(--space) * .7); }
.scramble-wrap { flex: 1; min-width: 0; text-align: center; }
body[data-align="left"] .scramble-wrap { text-align: left; }
.scramble-text {
  font-family: var(--font-scramble); font-size: var(--scramble-size); line-height: 1.5;
  word-spacing: .15em; white-space: pre-line; overflow-wrap: anywhere;
  max-height: 11.5em; overflow-y: auto;
}
.scramble-text.loading { color: var(--muted); }
.scramble-tag { margin-top: .15rem; min-height: 1em; }
.scramble-actions { display: flex; gap: 2px; }

/* ---------- timer ---------- */
.timer-zone {
  flex: 1; min-height: 14rem;
  display: grid; place-items: center;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.timer-stack { display: flex; flex-direction: column; align-items: center; gap: calc(var(--space) * .6); transform: translateY(var(--timer-offset)); }
.time {
  font-family: var(--font-timer);
  font-size: min(var(--timer-size), 19vw);
  font-weight: var(--timer-weight);
  letter-spacing: var(--timer-tracking);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--timer-color);
  text-shadow: 0 0 var(--timer-glow) currentColor;
  transition: color calc(.12s * var(--anim-mul, 1)), transform calc(.25s * var(--anim-mul, 1)) var(--ease);
}
body[data-state="holding"] .time { color: var(--holding); }
body[data-state="ready"] .time { color: var(--ready); transform: scale(1.02); }
body[data-state="inspecting"] .time,
body[data-state="inspect-armed"] .time { color: var(--inspect); }
.time.pb { animation: pb calc(1.2s * var(--anim-mul, 1)) var(--ease); }
@keyframes pb { 0% { transform: scale(1); } 30% { transform: scale(1.06); color: var(--accent); } 100% { transform: scale(1); } }

.penalty-tag { min-height: 1.2rem; font-weight: 600; color: var(--danger); font-size: .9rem; letter-spacing: .04em; }
.sub-stats { display: flex; gap: calc(var(--space) * 1.5); font-family: var(--font-timer); font-variant-numeric: tabular-nums; color: var(--muted); font-size: 1.05rem; }
.sub-stats b { color: var(--text); font-weight: 500; margin-left: .35em; }
.hint { color: var(--muted); font-size: .85rem; min-height: 1.3em; }

.last-actions { display: flex; gap: 4px; }
.last-actions button {
  border: var(--border-w) solid var(--border); background: var(--surface); border-radius: calc(var(--radius) * .6);
  padding: .3rem .7rem; font-size: .8rem; font-weight: 600; color: var(--muted);
  display: inline-grid; place-items: center;
}
.last-actions button:hover { color: var(--text); border-color: var(--accent); }
.last-actions button.on { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.last-actions svg { width: .95rem; height: .95rem; }

.typing input {
  font-family: var(--font-timer); font-size: 2rem; text-align: center; width: min(26rem, 80vw);
  padding: .6rem 1rem; border-radius: var(--radius);
}

/* focus mode: hide all chrome while solving / inspecting */
.chrome { transition: opacity calc(.2s * var(--anim-mul, 1)) var(--ease); }
body[data-state="running"] .chrome,
body[data-state="inspecting"] .chrome,
body[data-state="holding"].was-inspecting .chrome,
body[data-state="ready"].was-inspecting .chrome { opacity: var(--focus-fade, 0); pointer-events: none; }
body[data-state="running"] { cursor: none; }

/* ---------- bottom panels ---------- */
.bottom { display: grid; grid-template-columns: var(--preview-w) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: var(--space); height: var(--bottom-h); flex: none; }
.preview-panel { display: flex; padding: calc(var(--space) * .7); min-height: 0; }
.preview { flex: 1; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem; text-align: center; }
.preview svg { width: 100%; height: 100%; display: block; }
.graph-panel { display: flex; flex-direction: column; }
.graph-panel .panel-head { margin-bottom: .3rem; }
.graph-wrap { flex: 1; position: relative; min-height: 0; }
#graph { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

body[data-show-stats="off"] .stats-panel,
body[data-show-times="off"] .times-panel,
body[data-show-sub-stats="off"] .sub-stats,
body[data-show-preview="off"] .preview-panel,
body[data-show-graph="off"] .graph-panel,
body[data-show-hint="off"] .hint { display: none; }
body[data-show-preview="off"] .bottom { grid-template-columns: 1fr; }
body[data-show-graph="off"] .bottom { grid-template-columns: var(--preview-w); justify-content: center; }
body[data-show-preview="off"][data-show-graph="off"] .bottom { display: none; }

/* ---------- stats ---------- */
.stats-grid { display: grid; grid-template-columns: auto 1fr 1fr; gap: 2px 0; font-variant-numeric: tabular-nums; }
.stats-grid > * { padding: .32rem .45rem; border-radius: calc(var(--radius) * .45); }
.stats-grid .h { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; text-align: right; }
.stats-grid .k { color: var(--muted); font-size: .85rem; }
.stats-grid .v { text-align: right; font-family: var(--font-timer); font-size: .92rem; }
.stats-grid button.v { border: 0; background: none; }
.stats-grid button.v:hover { background: var(--surface-2); }
.stats-grid .best { color: var(--accent); }
.stats-foot { display: flex; justify-content: space-between; margin-top: .6rem; padding: .5rem .45rem 0; border-top: var(--border-w) solid var(--border); font-size: .8rem; color: var(--muted); }
.stats-foot b { color: var(--text); font-family: var(--font-timer); font-weight: 500; }

/* ---------- times list ---------- */
.times-panel { flex: 1; min-height: 12rem; display: flex; flex-direction: column; }
.times-head, .time-row { display: grid; grid-template-columns: 2.6rem 1fr 1fr 1fr; gap: .25rem; align-items: center; }
.times-head { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 .5rem .35rem; text-align: right; }
.times-head span:first-child { text-align: left; }
.times { overflow-y: auto; flex: 1; min-height: 0; margin: 0 calc(var(--space) * -.4); padding: 0 calc(var(--space) * .4); scrollbar-width: thin; }
.time-row {
  width: 100%; border: 0; background: none; text-align: right;
  padding: .38rem .5rem; border-radius: calc(var(--radius) * .5);
  font-family: var(--font-timer); font-size: .88rem; font-variant-numeric: tabular-nums;
}
.time-row:hover { background: var(--surface-2); }
.time-row .n { text-align: left; color: var(--muted); font-size: .75rem; }
.time-row .a { color: var(--muted); }
.time-row .dnf { color: var(--danger); }
.time-row.is-best .t { color: var(--accent); font-weight: 600; }
.times .more { width: 100%; margin-top: .4rem; }
.empty { color: var(--muted); font-size: .85rem; text-align: center; padding: 1.5rem .5rem; }

/* ---------- drawer ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(420px, 100vw);
  background: var(--surface); border-left: var(--border-w) solid var(--border);
  box-shadow: -24px 0 60px -20px rgb(0 0 0 / .5);
  display: flex; flex-direction: column;
  transform: translateX(105%); transition: transform calc(.3s * var(--anim-mul, 1)) var(--ease);
}
.drawer.open { transform: none; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 49; background: rgb(0 0 0 / .35); opacity: 0; pointer-events: none; transition: opacity .3s; }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .5rem 1.25rem; }
.drawer-head h2 { margin: 0; font-size: 1.1rem; }
.drawer-tabs { margin: 0 1.25rem .5rem; display: flex; }
.drawer-tabs button { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 0 1.25rem 2rem; }
.drawer fieldset { border: 0; margin: 0; padding: 1rem 0 .25rem; border-bottom: var(--border-w) solid var(--border); }
.drawer fieldset:last-child { border-bottom: 0; }
.drawer legend { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0; margin-bottom: .4rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .45rem 0; font-size: .9rem; }
.row.col { flex-direction: column; align-items: stretch; gap: .4rem; }
.row.col > label { display: flex; justify-content: space-between; }
.row output { font-family: var(--font-timer); font-size: .8rem; color: var(--muted); }
.row select { max-width: 55%; }
.color-field { display: inline-flex; align-items: center; gap: .4rem; }
.color-field .hex { width: 5.6rem; font-family: var(--font-timer); font-size: .8rem; padding: .3rem .45rem; }
input[type="color"] { width: 2rem; height: 2rem; padding: 0; border: var(--border-w) solid var(--border); border-radius: 50%; background: none; cursor: pointer; overflow: hidden; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 50%; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 50%; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
.switch {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 2.4rem; height: 1.4rem; border-radius: 1rem; position: relative; cursor: pointer;
  background: var(--surface-2); border: var(--border-w) solid var(--border); transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.4rem - 6px); height: calc(1.4rem - 6px);
  border-radius: 50%; background: var(--muted); transition: transform .2s var(--ease), background .2s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(1rem); background: var(--accent-text); }

.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; padding: .25rem 0 .5rem; }
.preset {
  display: grid; gap: .4rem; padding: .5rem; border-radius: calc(var(--radius) * .7);
  border: var(--border-w) solid var(--border); background: var(--surface-2); font-size: .78rem; text-align: left;
}
.preset.on, .preset:hover { border-color: var(--accent); }
.preset .swatch { display: flex; height: 2.2rem; border-radius: 6px; overflow: hidden; background: var(--p-bg); padding: 5px; gap: 4px; align-items: flex-end; }
.preset .swatch i { flex: 1; border-radius: 3px; height: 100%; background: var(--p-surface); }
.preset .swatch i:nth-child(2) { background: var(--p-accent); height: 60%; }
.preset .swatch i:nth-child(3) { background: var(--p-text); height: 35%; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; padding: .5rem 0; }
.danger-zone { margin-top: .5rem; }

/* ---------- modal ---------- */
dialog {
  border: var(--border-w) solid var(--border); border-radius: calc(var(--radius) * 1.2);
  background: var(--surface); color: var(--text);
  padding: 0; width: min(560px, calc(100vw - 2rem)); max-height: min(85dvh, 760px);
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / .6);
}
dialog::backdrop { background: rgb(0 0 0 / .45); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-inner { padding: 1.3rem 1.4rem; display: grid; gap: 1rem; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-time { font-family: var(--font-timer); font-size: 2.8rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.modal-scramble { font-family: var(--font-scramble); font-size: .95rem; background: var(--surface-2); padding: .8rem; border-radius: calc(var(--radius) * .7); white-space: pre-line; overflow-wrap: anywhere; }
.modal-preview svg { width: 100%; max-width: 280px; display: block; margin: 0 auto; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; font-size: .88rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.stat-list { font-family: var(--font-timer); font-size: .9rem; background: var(--surface-2); padding: .8rem; border-radius: calc(var(--radius) * .7); max-height: 45vh; overflow: auto; white-space: pre-wrap; margin: 0; }
.shortcut-list { display: grid; grid-template-columns: auto 1fr; gap: .55rem 1.2rem; font-size: .9rem; align-items: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 60;
  transform: translate(-50%, 150%); opacity: 0;
  background: var(--text); color: var(--bg);
  padding: .6rem 1rem; border-radius: 999px; font-size: .88rem; font-weight: 500;
  transition: transform .3s var(--ease), opacity .3s;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.pb { background: var(--accent); color: var(--accent-text); }

/* ---------- motion off ---------- */
body[data-anim="off"] *, body[data-anim="off"] *::before, body[data-anim="off"] *::after { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ---------- sidebar tabs ---------- */
.side-tabs { display: flex; flex: none; }
.side-tabs button { flex: 1; }
.side-pane { display: flex; flex-direction: column; gap: var(--space); flex: 1; min-height: 0; }
.side-pane[hidden] { display: none !important; }
.learn-pane { overflow-y: auto; padding: calc(var(--space) * .9); scrollbar-width: thin; }
body[data-side-tab="learn"][data-learn-wide="on"] .app { grid-template-columns: var(--learn-w) minmax(0, 1fr); }
body[data-side-tab="learn"][data-learn-wide="on"][data-sidebar="right"] .app { grid-template-columns: minmax(0, 1fr) var(--learn-w); }
body[data-force-side="on"] .side { display: flex !important; }
body[data-force-side="on"] .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) !important; grid-template-areas: "side main" !important; }
body[data-force-side="on"][data-learn-wide="on"] .app { grid-template-columns: var(--learn-w) minmax(0, 1fr) !important; }

/* ---------- learn ---------- */
.learn { font-size: .9rem; }
.learn-top { display: grid; gap: .5rem; position: sticky; top: calc(var(--space) * -.9); z-index: 2; padding: .2rem 0 .6rem; margin-top: -.2rem;
  background: color-mix(in srgb, var(--surface) calc(var(--panel-opacity) * 100%), transparent); }
.learn-tools { display: flex; gap: .4rem; }
.learn-search { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  border: var(--border-w) solid var(--border); background: var(--surface-2); color: var(--muted);
  padding: .28rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 500;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chips.methods .chip { font-size: .82rem; padding: .35rem .8rem; }
.method-title { margin: .6rem 0 .2rem; font-size: 1.15rem; letter-spacing: -.01em; }
.method-blurb { color: var(--muted); margin: 0 0 .5rem; }
.step { border-top: var(--border-w) solid var(--border); padding: .9rem 0 .4rem; }
.step h4 { margin: 0 0 .35rem; font-size: .95rem; }
.step p { margin: 0 0 .6rem; line-height: 1.55; }
.step code, .case-alg, .alg-row code { font-family: var(--font-scramble); }
.inline-algs { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.inline-alg {
  display: grid; grid-template-columns: 64px 1fr; gap: .6rem; align-items: center; text-align: left;
  padding: .5rem; border-radius: calc(var(--radius) * .7); border: var(--border-w) solid var(--border); background: var(--surface-2);
}
.inline-alg:hover { border-color: var(--accent); }
.inline-alg b { display: block; font-size: .82rem; margin-bottom: .15rem; }
.inline-alg code { font-size: .82rem; }
.set-head { display: flex; justify-content: space-between; margin: .2rem 0 .4rem; }
.set-block .chips { margin-bottom: .6rem; }
.case-grid { display: grid; gap: .45rem; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.case-card {
  display: grid; gap: .25rem; padding: .5rem .45rem .55rem; text-align: center;
  border: var(--border-w) solid var(--border); background: var(--surface-2); border-radius: calc(var(--radius) * .7);
  position: relative; transition: border-color .15s, transform .1s;
}
.case-card:hover { border-color: var(--accent); }
.case-card:active { transform: scale(.98); }
.case-card.learning::after, .case-card.learned::after { content: ""; position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--inspect); }
.case-card.learned::after { background: var(--ready); }
.case-img { display: block; width: 100%; aspect-ratio: 1; }
.case-card .case-img { width: 74%; margin: 0 auto; }
.case-img svg, .case-big svg { width: 100%; height: 100%; display: block; }
.case-name { font-size: .74rem; font-weight: 600; }
.case-alg { font-size: .68rem; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.case-big { width: min(220px, 60vw); margin: 0 auto; }
.alg-list { display: grid; gap: .35rem; }
.alg-row { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border-radius: calc(var(--radius) * .6); background: var(--surface-2); border: var(--border-w) solid transparent; }
.alg-row.on { border-color: var(--accent); }
.alg-row code { flex: 1; font-size: .95rem; overflow-wrap: anywhere; }
.alg-pick { border: 0; background: none; color: var(--accent); font-size: 1.05rem; padding: 0 .2rem; }
.status-seg { justify-self: center; }
.player-box:empty { display: none; }
.player-box { display: grid; place-items: center; }
.player-box twisty-player { width: min(320px, 70vw); height: 280px; }
.credits { margin-top: 1.2rem; }
.credits a { color: inherit; }

/* ---------- input switcher & devices ---------- */
.input-bar { position: absolute; top: calc(var(--space) * .6); left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: .35rem; max-width: 100%; z-index: 1; }
.input-bar .seg { overflow-x: auto; max-width: calc(100vw - 2rem); scrollbar-width: none; }
.input-bar .seg button { white-space: nowrap; }
body[data-show-input-bar="off"] .input-bar { display: none; }
.device-status { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); min-height: 1.2em; flex-wrap: wrap; justify-content: center; }
.device-status:empty { display: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--holding); flex: none; }
.dot.ok { background: var(--ready); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ready) 25%, transparent); }
.link { border: 0; background: none; color: var(--accent); padding: 0; font-size: inherit; font-weight: 600; }
.link:hover { text-decoration: underline; }
.tok.done { opacity: .3; }
.tok.cur { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: .25em; }
.tok.fix { color: var(--danger); font-weight: 700; white-space: nowrap; }
.brand-grid { display: grid; gap: .5rem; }
.brand-opt { text-align: left; display: grid; gap: .2rem; padding: .8rem 1rem; border-radius: var(--radius); border: var(--border-w) solid var(--border); background: var(--surface-2); }
.brand-opt:hover { border-color: var(--accent); }
.brand-opt span { color: var(--muted); font-size: .82rem; }

/* ---------- profiles ---------- */
.profile-wrap select { max-width: 11rem; }
.menu-pop hr { border: 0; border-top: var(--border-w) solid var(--border); margin: 4px 0; }
.table-wrap { overflow-x: auto; }
table.cmp { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
table.cmp th { text-align: right; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: .4rem; }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; }
table.cmp td { text-align: right; padding: .55rem .4rem; border-top: var(--border-w) solid var(--border); font-family: var(--font-timer); vertical-align: top; }
table.cmp td:first-child { font-family: var(--font-ui); }
table.cmp tr.current td:first-child b { color: var(--accent); }
.pdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .45rem; }
.row-actions { white-space: nowrap; }
.row-actions > * { vertical-align: middle; }
.icon-btn.sm { width: 1.8rem; height: 1.8rem; }
.icon-btn.sm svg { width: .95rem; height: .95rem; }
.btn.sm { padding: .3rem .6rem; font-size: .78rem; }
.times-head-right { display: flex; align-items: center; gap: .3rem; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .app, body[data-sidebar="right"] .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "main" "side";
  }
  .app { grid-template-rows: auto; flex: 1 0 auto; min-height: auto; }
  .bottom { grid-template-rows: auto; }
  .scramble-text { font-size: min(var(--scramble-size), 1.05rem); word-spacing: .05em; }
  .scramble-bar { padding: .5rem .35rem; gap: .15rem; }
  .scramble-actions { flex-direction: column; }
  .scramble-actions [data-action="scramble-edit"] { display: none; }
  .timer-zone { min-height: 52dvh; }
  .times-panel { max-height: 60dvh; }
  .bottom { grid-template-columns: minmax(0, 1fr); height: auto; }
  .preview-panel { height: 170px; }
  .graph-panel { height: var(--bottom-h); }
  .brand span:last-child { display: none; }
  .topbar { gap: .5rem; padding-inline: .75rem; }
  .app { padding-inline: .75rem; }
  .selectors { justify-content: flex-start; }
  .select-wrap { flex: 1 1 0; min-width: 0; }
  .selectors select { max-width: none; width: 100%; }
  .top-actions [data-action="shortcuts"], .top-actions [data-action="fullscreen"], .top-actions [data-action="open-learn"] { display: none; }
  .profile-wrap { display: none; }
  .timer-zone { padding-top: 4.5rem; }
  body[data-side-tab="learn"][data-learn-wide="on"] .app { grid-template-columns: minmax(0, 1fr); }
  .learn-pane { max-height: none; overflow: visible; }
  .learn-top { position: static; }
}
.hint-touch { display: none; }
@media (hover: none) {
  .hint-kb { display: none; }
  .hint-touch { display: inline; }
}

/* ---------- v3: stepped sliders & settings ---------- */
.stepped .ticks { display: flex; justify-content: space-between; gap: .2rem; margin-top: -.15rem; }
.stepped .ticks span { font-size: .68rem; color: var(--muted); cursor: pointer; text-align: center; flex: 1; line-height: 1.2; padding-top: .15rem; }
.stepped .ticks span:first-child { text-align: left; }
.stepped .ticks span:last-child { text-align: right; }
.stepped .ticks span.on { color: var(--accent); font-weight: 600; }
.stepped input[type="range"] { background: transparent; }
.hint-text { font-size: .74rem; color: var(--muted); line-height: 1.4; }
input[type="range"].hue-track { appearance: none; -webkit-appearance: none; height: 8px; border-radius: 999px; margin: .45rem 0;
  background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
input[type="range"].hue-track::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
input[type="range"].hue-track::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--surface); }
details.fs { border-bottom: var(--border-w) solid var(--border); padding: .7rem 0; }
details.fs summary { cursor: pointer; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); list-style: none; display: flex; justify-content: space-between; }
details.fs summary::after { content: "+"; font-size: 1rem; line-height: 1; }
details.fs[open] summary::after { content: "–"; }
details.fs summary::-webkit-details-marker { display: none; }
.about p { font-size: .85rem; line-height: 1.5; margin: .3rem 0 .6rem; }

/* ---------- splits & virtual cube ---------- */
.splits { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; font-family: var(--font-timer); font-variant-numeric: tabular-nums; font-size: .95rem; min-height: 0; }
.splits:empty { display: none; }
.splits span { padding: .2rem .55rem; border-radius: 999px; background: var(--surface-2); border: var(--border-w) solid var(--border); }
.splits i { font-style: normal; color: var(--muted); font-size: .72em; margin-right: .35em; }
.splits.big { justify-content: flex-start; }
.vcube { width: min(230px, 40vw); aspect-ratio: 7 / 8; margin-bottom: .4rem; }
.vcube svg { width: 100%; height: 100%; display: block; }
.shortcut-list.keys { grid-template-columns: auto 1fr auto 1fr; }

/* ---------- tools ---------- */
.tool-body { margin-top: .8rem; display: grid; gap: .7rem; }
.solver-out { display: grid; gap: .35rem; }
.solve-row { display: grid; grid-template-columns: 12px 4.2rem 3.2rem 1fr auto; gap: .5rem; align-items: center; padding: .5rem .6rem; border-radius: calc(var(--radius) * .6); background: var(--surface-2); border: var(--border-w) solid transparent; }
.solve-row.best { border-color: var(--accent); }
.solve-row code { font-family: var(--font-scramble); font-size: .85rem; overflow-wrap: anywhere; }
.solve-len { font-family: var(--font-timer); color: var(--muted); font-size: .8rem; }
.solve-row.best .solve-len { color: var(--accent); font-weight: 700; }
.swatch-dot { width: 12px; height: 12px; border-radius: 3px; box-shadow: 0 0 0 1px var(--border); }
.solve-name { font-size: .82rem; font-weight: 600; }
.memo { display: grid; gap: .4rem; }
.memo-row { display: grid; grid-template-columns: 4.5rem 1fr auto; gap: .6rem; align-items: center; padding: .55rem .7rem; border-radius: calc(var(--radius) * .6); background: var(--surface-2); }
.memo-row code { font-family: var(--font-timer); font-size: 1.05rem; letter-spacing: .06em; }
.memo-k { color: var(--muted); font-size: .8rem; }
.warn { color: var(--inspect); }
.metro { display: grid; gap: .6rem; justify-items: stretch; }
.metro-bpm { text-align: center; }
.metro-bpm b { font-family: var(--font-timer); font-size: 3rem; font-weight: 500; display: block; line-height: 1; }
.metro-dots { display: flex; gap: .5rem; justify-content: center; }
.metro-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-2); border: var(--border-w) solid var(--border); transition: background .05s; }
.metro-dots i.on { background: var(--accent); border-color: var(--accent); }
.metro-dots i:first-child.on { background: var(--inspect); border-color: var(--inspect); }
.batch-list { margin: 0; padding-left: 1.6rem; display: grid; gap: .35rem; font-size: .82rem; }
.batch-list code { font-family: var(--font-scramble); white-space: pre-line; }
table.cmp tr.total td { border-top-width: calc(var(--border-w) * 2); }
.ms-body { max-height: 60vh; overflow: auto; }
.type-wrap select { max-width: 10rem; }
@media (max-width: 900px) { .type-wrap { display: none; } }

.stepped .ticks.dense span { flex: 1; height: 10px; position: relative; }
.stepped .ticks.dense span::before { content: ""; position: absolute; left: 50%; top: 2px; width: 4px; height: 4px; border-radius: 50%; background: var(--border); transform: translateX(-50%); }
.stepped .ticks.dense span:first-child::before { left: 2px; transform: none; }
.stepped .ticks.dense span:last-child::before { left: auto; right: 2px; transform: none; }
.stepped .ticks.dense span.on::before { background: var(--accent); }
.drawer-body { overflow-x: hidden; }
.row.col > label output { white-space: nowrap; }
.link.small { font-size: .78rem; }
body[data-input-mode="virtual"] .timer-zone { padding-top: 5.2rem; }
body[data-input-mode="virtual"] .time { font-size: min(calc(var(--timer-size) * .7), 15vw); }

/* ---------- v5: accounts ---------- */
.account-btn { position: relative; overflow: visible; }
.account-btn img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; position: absolute; inset: 0; }
.account-btn.signed-in img + svg { display: none; }
.acct-dot { position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%; background: transparent; border: 2px solid var(--bg); display: none; }
.account-btn.signed-in .acct-dot { display: block; background: var(--muted); }
.account-btn[data-sync="synced"] .acct-dot { background: var(--ready); }
.account-btn[data-sync="syncing"] .acct-dot { background: var(--inspect); animation: pulse calc(1s * var(--anim-mul, 1)) infinite alternate; }
.account-btn[data-sync="error"] .acct-dot { background: var(--danger); }
.account-btn[data-sync="offline"] .acct-dot { background: var(--muted); }
@keyframes pulse { to { opacity: .35; } }
.auth-btn { width: 100%; padding: .7rem 1rem; font-size: .95rem; }
.auth-btn.busy, .btn.busy { opacity: .6; pointer-events: none; }
.or { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .75rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: var(--border-w) solid var(--border); }
.auth-seg { justify-self: start; }
.auth-form { display: grid; gap: .55rem; }
.auth-form input { width: 100%; padding: .65rem .8rem; font-size: 1rem; }
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.auth-row .btn { padding: .65rem; }
.auth-msg { display: none; font-size: .85rem; padding: .55rem .7rem; border-radius: calc(var(--radius) * .6); background: color-mix(in srgb, var(--ready) 14%, transparent); }
.auth-msg.show { display: block; }
.auth-msg.err { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.acct-card { display: flex; align-items: center; gap: .8rem; padding: .7rem; border-radius: var(--radius); background: var(--surface-2); }
.acct-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; }
.acct-avatar.letter { display: grid; place-items: center; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 1.2rem; }
.sync-line { display: flex; align-items: center; gap: .5rem; font-size: .88rem; }
.dot.busy { background: var(--inspect); }
.dot.err { background: var(--danger); }
.about a, dialog a { color: var(--accent); }
