/* ==========================================================================
   Trainer page
   All colours, sizes and radii come from tokens.css.
   Panels are separated by surface tint; borders are reserved for inputs
   and a single hairline above the footer.
   ========================================================================== */

:root {
    --footer-h: 64px;
    --banner-h: 40px;
}

.mobile-only {
    display: none !important;
}

/* ── Shell & header ────────────────────────────────────────────────────── */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    padding-bottom: var(--footer-h);
}

body:has(#slowModeBanner[style*="flex"]) .app-shell {
    padding-top: var(--banner-h);
}

.app-header {
    flex: none;
    padding: 12px 20px 0;
}

.header-bar,
.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.header-bar {
    justify-content: space-between;
}

.status-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.status-item {
    padding: 4px 10px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: var(--fs-xs);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.status-item:empty {
    display: none;
}

.scramble {
    padding: var(--sp-4) 0 var(--sp-2);
    text-align: center;
}

.scramble .label {
    display: block;
    margin-bottom: 2px;
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 500;
}

#current-scramble {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(18px, 1.7vw, 26px);
    font-weight: 500;
    word-spacing: -0.1em;
    text-wrap: balance;
}

/* ── Three-column layout ───────────────────────────────────────────────── */

.trainer-container {
    flex: 1;
    min-height: 0;
    padding: var(--sp-4) 20px;
}

.trainer-grid {
    display: grid;
    grid-template-columns: minmax(260px, 310px) minmax(0, 1fr) minmax(300px, 370px);
    gap: 20px;
    height: 100%;
}

.side-panel,
.case-sidebar {
    min-height: 0;
    height: 100%;
}

.panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: var(--r-md);
    background: var(--surface);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    flex: none;
    padding: var(--sp-4) var(--sp-4) var(--sp-2);
}

.panel-title {
    font-size: var(--fs-md);
    font-weight: 600;
}

.panel-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--sp-2) var(--sp-4) var(--sp-4);
}

/* ── Settings panel ────────────────────────────────────────────────────── */

.settings-card-body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.section-label {
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.toggle-list {
    display: flex;
    flex-direction: column;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    min-height: 34px;
    cursor: pointer;
}

.toggle-text {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
}

.toggle-badge {
    padding: 1px 6px;
    border-radius: var(--r-pill);
    background: var(--warn-soft);
    color: var(--warn);
    font-size: 11px;
    font-weight: 500;
}

.field-hint {
    margin: 2px 0 var(--sp-1);
    color: var(--text-3);
    font-size: var(--fs-xs);
    line-height: 1.45;
    text-wrap: pretty;
}

.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    min-height: 34px;
}

.field-row label {
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.field-stack {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.field {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.field + .field {
    margin-top: 10px;
}

.field label {
    color: var(--text-2);
    font-size: var(--fs-xs);
}

#maskSettings {
    padding-top: var(--sp-1);
}

.range-row {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr) 40px;
    align-items: center;
    gap: var(--sp-3);
    min-height: 34px;
}

.range-row label {
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.range-row input[type="range"] {
    width: 100%;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.range-row output {
    color: var(--text-3);
    font: 500 var(--fs-xs) var(--font-mono);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.kb-settings-btn {
    margin-top: var(--sp-1);
}

/* ── Centre: cube + timer ──────────────────────────────────────────────── */

.main-training-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    min-height: 0;
    overflow-y: auto;
}

.timer-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* The canvas is sized by virtualCubeEmbed.js to exactly fill this box,
   so --cube-scale (Display > Cube size) is all it takes to resize the cube. */
#virtualCubeContainer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 100%;
    height: calc(min(42vh, 380px) * var(--cube-scale, 1));
    overflow: hidden;
}

#canvas {
    display: block;
}

.timer-display {
    margin: var(--sp-4) 0 var(--sp-2);
    color: var(--timer-idle);
    font-family: var(--font-mono);
    font-size: calc(var(--fs-timer) * var(--timer-scale, 1));
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.04em;
    line-height: 1;
    transition: color 80ms linear;
}

.timer-hint {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

#splitDisplay {
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
}

.split-item {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text-2);
}

.split-item b {
    font-weight: 600;
}

.split-recog b {
    color: var(--accent-text);
}

.split-exec b {
    color: var(--good);
}

.split-item.is-pending {
    opacity: 0.5;
}

.split-divider {
    display: none;
}

#recallBanner {
    align-items: center;
    justify-content: center;
    margin-top: var(--sp-3);
    padding: 4px 12px;
    border-radius: var(--r-pill);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: var(--fs-xs);
    font-weight: 500;
    animation: recallPulse 2.4s ease-in-out infinite;
}

@keyframes recallPulse {
    50% {
        opacity: 0.65;
    }
}

/* ── Case panel ────────────────────────────────────────────────────────── */

#case-text {
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 500;
}

#case-time {
    padding: 2px 8px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    font: 600 var(--fs-sm) var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.case-card-body {
    flex: none;
    padding: var(--sp-2) var(--sp-4) var(--sp-4);
    text-align: center;
}

#case-img {
    display: block;
    width: 116px;
    height: auto;
    margin: 0 auto;
}

#case-img:not([src]),
#case-img[src=""] {
    display: none;
}

/* Case image drawn from the cube state (Display > Case image) */
#case-canvas {
    display: block;
    margin: 0 auto;
}

#case-img[hidden],
#case-canvas[hidden] {
    display: none;
}

#case-name {
    margin-top: var(--sp-2);
    font: 600 var(--fs-md) var(--font-mono);
}

.case-card-footer {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    padding-top: 0;
}

.info-block > label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 600;
}

#case-scram {
    padding: var(--sp-2) 10px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    word-spacing: 0.15em;
}

#case-algs {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
    font-size: var(--fs-sm);
}

.alg-entry {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 6px 8px 10px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
}

.alg-entry.alg-main {
    background: var(--good-soft);
}

.alg-entry-top {
    display: flex;
    align-items: center;
    gap: 2px;
    min-height: 24px;
}

.alg-main-badge {
    color: var(--good);
    font-size: 11px;
    font-weight: 600;
}

.alg-set-main-btn {
    padding: 2px 6px;
    margin-left: -6px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-3);
    font: 500 11px var(--font-sans);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.alg-set-main-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.alg-edit-btn,
.alg-copy-btn,
.alg-note-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.alg-edit-btn {
    margin-left: auto;
}

.alg-edit-btn .icon,
.alg-copy-btn .icon,
.alg-note-btn .icon {
    width: 14px;
    height: 14px;
}

.alg-edit-btn:hover,
.alg-copy-btn:hover,
.alg-note-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.alg-entry:has(.alg-note-input:not([value=""])) .alg-note-btn {
    color: var(--accent-text);
}

.alg-text {
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    line-height: 1.5;
    word-spacing: 0.1em;
    word-break: break-word;
}

.alg-note-row {
    margin-top: 6px;
    padding-right: 4px;
}

.alg-note-input {
    width: 100%;
    height: 28px;
    padding: 0 var(--sp-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font: 400 var(--fs-xs) var(--font-sans);
    outline: none;
}

.alg-note-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.alg-note-input::placeholder {
    color: var(--text-3);
}

#caseStatsSummary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.stat-square {
    display: flex;
    flex-direction: column;
    padding: var(--sp-2) 10px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
}

.stat-label {
    color: var(--text-3);
    font-size: 11px;
}

.stat-value {
    font: 600 var(--fs-md) var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.recog-value,
.tag-recog,
.recog-col {
    color: var(--accent-text);
}

.exec-value,
.tag-exec,
.exec-col {
    color: var(--good);
}

#caseAttemptsList {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: var(--sp-2);
}

#caseAttemptsList:empty {
    display: none;
}

.clickable-tag {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--surface-2);
    font: 500 var(--fs-xs) var(--font-mono);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.clickable-tag:hover {
    background: var(--bad-soft);
    color: var(--bad);
}

.tag-split {
    display: flex;
    gap: 4px;
    font-size: 10px;
}

.stats-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
}

/* ── Footer ────────────────────────────────────────────────────────────── */

.action-footer {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--footer-h);
    padding: 0 20px;
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.footer-controls {
    display: flex;
    gap: var(--sp-2);
}

.footer-controls .btn {
    height: 36px;
    padding: 0 18px;
}

/* ── Sheets: stats + slow cases ────────────────────────────────────────── */

.sheet {
    width: calc(100% - 32px);
    max-width: 860px;
    height: auto;
    margin: var(--sp-5) auto calc(var(--footer-h) + var(--sp-5));
    padding: var(--sp-5);
    overflow: visible;
}

.sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.sheet-header h3 {
    font-size: var(--fs-lg);
    font-weight: 600;
}

.sheet-sub {
    margin-top: 2px;
    color: var(--text-3);
    font-size: var(--fs-sm);
}

#statsContent h4 {
    margin: var(--sp-5) 0 var(--sp-2);
    color: var(--text-2);
    font-size: var(--fs-sm);
    font-weight: 600;
}

#statsContent h4:first-child {
    margin-top: 0;
}

#statsContent table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}

#statsContent th {
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--line-strong);
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 500;
    text-align: left;
}

#statsContent td {
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--line);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

#statsContent tr:last-child td {
    border-bottom: 0;
}

#statsContent tr:hover td {
    background: var(--surface-2);
}

/* Sets to show, and one section per set */
.stats-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--sp-4);
}

.stats-filter-label {
    margin-right: 4px;
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.stats-set-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    font-size: var(--fs-sm);
    cursor: pointer;
}

.stats-set-check input {
    accent-color: var(--accent);
}

.stats-set-n {
    color: var(--text-3);
    font: 500 var(--fs-xs) var(--font-mono);
}

.stats-set + .stats-set {
    margin-top: var(--sp-4);
}

.stats-set summary {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px var(--sp-3);
    padding: 6px 0;
    list-style: none;
    cursor: pointer;
}

.stats-set summary::-webkit-details-marker {
    display: none;
}

.stats-set summary::before {
    content: "›";
    display: inline-block;
    width: 10px;
    color: var(--text-3);
    transition: transform var(--dur) var(--ease);
}

.stats-set[open] summary::before {
    transform: rotate(90deg);
}

.stats-set-name {
    font-weight: 600;
}

.stats-set-sum {
    color: var(--text-3);
    font-size: var(--fs-xs);
}

.stats-table-wrap {
    overflow-x: auto;
}

.stats-case-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent-text);
    font: inherit;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    cursor: pointer;
}

.stats-empty {
    color: var(--text-3);
    font-size: var(--fs-sm);
}

.threshold-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
    padding: 10px var(--sp-3);
    border-radius: var(--r-sm);
    background: var(--surface-2);
}

.threshold-row label {
    color: var(--text-2);
    font-size: var(--fs-sm);
}

#thresholdSlider {
    flex: 1;
    accent-color: var(--accent);
}

#thresholdLabel {
    min-width: 44px;
    font: 600 var(--fs-sm) var(--font-mono);
    text-align: right;
}

#slowCasesList {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 420px;
    margin-bottom: var(--sp-4);
    overflow-y: auto;
}

.slow-bulk-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--sp-2);
}

.slow-bulk-btn {
    height: 28px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font: 500 var(--fs-xs) var(--font-sans);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.slow-bulk-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.slow-selected-count {
    margin-left: auto;
    color: var(--text-3);
    font-size: var(--fs-xs);
}

.slow-case-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 6px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.slow-case-row:hover {
    background: var(--surface-2);
    opacity: 1 !important;
}

.slow-case-row:not(.slow-checked) {
    opacity: 0.5;
}

.slow-case-checkbox {
    display: flex;
    flex: none;
}

.slow-case-checkbox input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.slow-case-img {
    flex: none;
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.slow-case-info {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.slow-case-name {
    overflow: hidden;
    font: 600 var(--fs-sm) var(--font-mono);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Picture and name open the case info window */
.slow-case-open {
    cursor: pointer;
}

button.slow-case-name {
    align-self: flex-start;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    text-align: left;
    text-decoration: underline dotted var(--text-3);
    text-underline-offset: 3px;
}

button.slow-case-name:hover {
    color: var(--accent-text);
}

img.slow-case-open:hover {
    outline: 2px solid var(--accent-soft);
    border-radius: 6px;
}

.slow-case-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    font-size: var(--fs-xs);
}

.slow-avg,
.slow-best {
    font-family: var(--font-mono);
    font-weight: 600;
}

.slow-ok .slow-avg {
    color: var(--text-2);
}

.slow-medium .slow-avg {
    color: var(--warn);
}

.slow-hard .slow-avg {
    color: var(--bad);
}

.slow-best {
    color: var(--good);
}

.slow-count {
    color: var(--text-3);
}

.no-slow-cases {
    padding: var(--sp-5);
    color: var(--text-3);
    font-size: var(--fs-sm);
    text-align: center;
}

#slowModeBanner {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 200;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    height: var(--banner-h);
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--warn) 14%, var(--surface));
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: 500;
}

#slowModeBanner button {
    height: 28px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-2);
    font: 500 var(--fs-sm) var(--font-sans);
    cursor: pointer;
}

#slowModeBanner button:hover {
    background: rgb(0 0 0 / 0.06);
    color: var(--text);
}

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1200px) {
    .mobile-only {
        display: inline-flex !important;
    }

    .app-shell {
        height: auto;
        min-height: 100dvh;
        padding-bottom: calc(var(--footer-h) + var(--sp-4));
    }

    .trainer-grid {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
    }

    .main-training-area {
        padding: var(--sp-3) 0 var(--sp-5);
    }

    .side-panel,
    .case-sidebar,
    .panel {
        height: auto;
    }

    .case-card-footer {
        overflow: visible;
    }

    .left-panel {
        display: none;
    }

    .left-panel.active {
        position: fixed;
        inset: 0;
        z-index: 300;
        display: block;
        padding: var(--sp-4);
        overflow-y: auto;
        background: var(--bg);
    }

    .left-panel.active .panel {
        max-width: 480px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 10px 12px 0;
    }

    .header-bar {
        flex-wrap: wrap;
    }

    .trainer-container {
        padding: var(--sp-3);
    }

    .action-footer {
        padding: 0 var(--sp-3);
    }

    .footer-controls {
        width: 100%;
    }

    .footer-controls .btn {
        flex: 1;
        padding: 0 var(--sp-2);
    }

    .sheet {
        width: calc(100% - 16px);
        padding: var(--sp-4);
    }

    #statsContent {
        overflow-x: auto;
    }

    #statsContent table {
        min-width: 520px;
    }

    #slowModeBanner {
        padding: 0 var(--sp-3);
        font-size: var(--fs-xs);
    }
}

@media (max-width: 520px) {
    .header-right {
        display: contents;
    }

    .header-left {
        flex: 1;
        margin-left: -8px;
    }

    .status-group {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .slow-case-img {
        width: 36px;
        height: 36px;
    }
}

/* ==========================================================================
   Keybind modal
   ========================================================================== */

.kb-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    background: var(--overlay);
    opacity: 0;
    transition: opacity 180ms var(--ease);
}

.kb-overlay.kb-visible {
    opacity: 1;
}

.kb-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow: hidden;
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    transform: translateY(8px) scale(0.98);
    transition: transform 180ms var(--ease);
}

.kb-overlay.kb-visible .kb-card {
    transform: none;
}

.kb-card-wide {
    max-width: 680px !important;
}

.kb-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex: none;
    padding: 18px 20px 12px;
}

.kb-header-label {
    margin: 0 0 2px;
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 500;
}

.kb-header-title {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: 600;
}

.kb-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-3);
    font-size: 15px;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.kb-close:hover {
    background: var(--surface-2);
    color: var(--text);
}

.kb-view-toggle-bar {
    display: flex;
    flex: none;
    gap: 2px;
    margin: 0 20px 12px;
    padding: 3px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    width: fit-content;
}

.kb-view-btn {
    height: 26px;
    padding: 0 12px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-2);
    font: 500 var(--fs-xs) var(--font-sans);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.kb-view-btn:hover {
    color: var(--text);
}

.kb-view-btn-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.kb-layout-bar {
    display: flex;
    flex: none;
    align-items: center;
    gap: 6px;
    padding: 0 20px 12px;
    overflow-x: auto;
    scrollbar-width: none;
}

.kb-layout-bar::-webkit-scrollbar {
    display: none;
}

.kb-layout-pill {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text-2);
    font: 500 var(--fs-xs) var(--font-sans);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.kb-layout-pill:hover {
    background: var(--surface-3);
    color: var(--text);
}

.kb-layout-pill-active,
.kb-layout-pill-active:hover {
    background: var(--accent);
    color: var(--text-on-accent);
}

.kb-layout-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 10px;
    opacity: 0.7;
    cursor: pointer;
}

.kb-layout-del:hover {
    background: rgb(255 255 255 / 0.2);
    opacity: 1;
}

.kb-layout-save-btn {
    flex: none;
    height: 28px;
    padding: 0 10px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--text-2);
    font: 500 var(--fs-xs) var(--font-sans);
    white-space: nowrap;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.kb-layout-save-btn:hover {
    border-color: var(--accent);
    color: var(--accent-text);
}

.kb-hint {
    flex: none;
    margin: 0;
    padding: 10px 20px;
    border-top: 1px solid var(--line);
    color: var(--text-3);
    font-size: var(--fs-xs);
}

.kb-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 0 var(--sp-2);
}

.kb-category-head {
    padding: 14px 20px 4px;
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.kb-row {
    display: grid;
    grid-template-columns: 48px 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 5px 20px;
    transition: background-color var(--dur) var(--ease);
}

.kb-row:hover {
    background: var(--surface-2);
}

.kb-listening {
    background: var(--accent-soft) !important;
}

.kb-move-label {
    font: 600 var(--fs-sm) var(--font-mono);
}

.kb-key-cell {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.kb-badge {
    min-width: 22px;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--surface-2);
    box-shadow: inset 0 -1px 0 var(--line-strong), 0 0 0 1px var(--line);
    font: 500 var(--fs-xs) var(--font-mono);
    text-align: center;
}

.kb-unbound {
    color: var(--text-3);
    font-size: var(--fs-xs);
}

.kb-rebind-btn {
    height: 26px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font: 500 var(--fs-xs) var(--font-sans);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.kb-rebind-btn:hover {
    background: var(--surface-3);
    color: var(--text);
}

.kb-listening-btn {
    background: var(--accent) !important;
    color: var(--text-on-accent) !important;
    animation: kb-blink 1s ease-in-out infinite;
}

@keyframes kb-blink {
    50% {
        opacity: 0.7;
    }
}

.kb-confirm-btn {
    background: var(--warn-soft) !important;
    color: var(--warn) !important;
}

.kb-warn {
    display: none;
    grid-column: 1 / -1;
    padding: 4px 10px;
    border-radius: var(--r-sm);
    background: var(--warn-soft);
    color: var(--warn);
    font-size: var(--fs-xs);
    line-height: 1.4;
}

.kb-warn.kb-warn-visible {
    display: block;
}

.kb-footer {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid var(--line);
}

.kb-reset-btn,
.kb-done-btn {
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--r-sm);
    font: 500 var(--fs-sm) var(--font-sans);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.kb-reset-btn {
    background: transparent;
    color: var(--text-2);
}

.kb-reset-btn:hover {
    background: var(--bad-soft);
    color: var(--bad);
}

.kb-done-btn {
    padding: 0 20px;
    background: var(--accent);
    color: var(--text-on-accent);
}

.kb-done-btn:hover {
    background: var(--accent-hover);
}

/* Keyboard editor */

.kb-editor-body {
    padding: 16px 20px 12px;
    overflow-y: auto;
}

.kb-keyboard-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: var(--sp-3);
    user-select: none;
}

.kb-key-row {
    display: flex;
    gap: 4px;
}

.kb-key-row-extra {
    align-items: center;
    margin-top: 10px;
    padding-left: 0 !important;
}

.kb-extra-label {
    flex: none;
    margin-right: var(--sp-2);
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 500;
}

.kb-key {
    position: relative;
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 46px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    box-shadow: inset 0 -2px 0 var(--line-strong);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease);
}

.kb-key:hover {
    background: var(--surface-3);
}

.kb-key.kb-key-bound {
    background: var(--accent-soft);
}

.kb-key.kb-key-selected {
    background: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-soft) !important;
}

.kb-key-phys {
    position: absolute;
    top: 4px;
    left: 5px;
    color: var(--text-3);
    font: 500 9px var(--font-mono);
    line-height: 1;
}

.kb-key-move {
    margin-top: 8px;
    color: var(--text-3);
    font: 600 var(--fs-xs) var(--font-mono);
    line-height: 1;
}

.kb-key-move.kb-key-move-bound {
    color: var(--accent-text);
}

.kb-key.kb-key-selected .kb-key-phys,
.kb-key.kb-key-selected .kb-key-move {
    color: var(--text-on-accent) !important;
}

.kb-move-picker {
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    animation: kb-picker-in 140ms var(--ease);
}

@keyframes kb-picker-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
}

.kb-picker-title {
    margin-bottom: 10px;
    font-size: var(--fs-sm);
    font-weight: 500;
}

.kb-picker-title code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--surface-3);
    color: var(--accent-text);
    font: 500 var(--fs-xs) var(--font-mono);
}

.kb-picker-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.kb-picker-cat {
    flex-basis: 100%;
    margin-top: var(--sp-2);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
}

.kb-picker-cat:first-child {
    margin-top: 0;
}

.kb-picker-pill,
.kb-picker-clear {
    height: 26px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font: 600 var(--fs-xs) var(--font-mono);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.kb-picker-pill:hover {
    background: var(--surface-3);
}

.kb-picker-pill.kb-picker-pill-active {
    background: var(--accent);
    color: var(--text-on-accent);
}

.kb-picker-clear {
    color: var(--bad);
    font-family: var(--font-sans);
    font-weight: 500;
}

.kb-picker-clear:hover {
    background: var(--bad-soft);
}

.kb-picker-clear.kb-picker-pill-active {
    background: var(--bad);
    color: #fff;
}

/* AUF-adjusted algorithms: pre/post AUF shown as small chips */
.alg-text .auf {
    display: inline-block;
    padding: 0 5px;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
    line-height: 1.5;
}

.alg-text .auf-pre {
    margin-right: 2px;
}

.alg-text .auf-post {
    margin-left: 2px;
}

/* ── Alg player: see styles/player.css ──────────────────────────────────── */

.alg-play-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.alg-play-btn .icon {
    width: 14px;
    height: 14px;
}

.alg-play-btn:hover {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.alg-play-btn + .alg-edit-btn {
    margin-left: 0;
}









































/* ── Detected alg (last solve) ──────────────────────────────────────────── */

.alg-used-badge {
    padding: 0 6px;
    border-radius: var(--r-pill);
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
}

.alg-detect {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border-radius: var(--r-sm);
    background: var(--accent-soft);
}

.alg-detect-title {
    color: var(--accent-text);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.alg-detect-text {
    color: var(--text-2);
    font-size: var(--fs-xs);
    line-height: 1.45;
}

.alg-detect .alg-text {
    padding: 6px 8px;
    border-radius: 4px;
    background: var(--surface);
}

.alg-detect-warn {
    color: var(--warn);
    font-size: var(--fs-xs);
    line-height: 1.45;
}

.alg-detect-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.alg-detect-actions .btn {
    height: 28px;
    padding: 0 10px;
    font-size: var(--fs-xs);
}

/* ── LSLL breakdown (ZBLS step, then ZBLL step) ─────────────────────────── */

.lsll-breakdown {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lsll-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.lsll-step-img {
    flex: none;
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.lsll-step-noimg {
    display: block;
}

.lsll-step-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.lsll-step-label {
    margin: 0;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.lsll-step-time {
    margin-left: 6px;
    font-variant-numeric: tabular-nums;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
}

.lsll-step-case {
    margin: 0;
    font-weight: 600;
}

.lsll-alg-note,
.lsll-hint {
    margin: 0;
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* ── Smart cube ─────────────────────────────────────────────────────────── */

.smart-status {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 24px;
    color: var(--text-2);
    font-size: var(--fs-sm);
}

.smart-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--surface-3);
}

.smart-dot[data-state="on"] {
    background: var(--good);
}

.smart-dot[data-state="busy"] {
    background: var(--warn);
    animation: recallPulse 1.2s ease-in-out infinite;
}

/* ── Solve replays & move stats ─────────────────────────────────────────── */

.clickable-tag.has-replay {
    box-shadow: inset 0 -2px 0 var(--accent-soft);
}

.clickable-tag.has-replay:hover {
    background: var(--accent-soft);
    color: var(--accent-text);
}























.alg-insights {
    grid-column: 1 / -1;
    padding: var(--sp-2) 10px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    font-size: var(--fs-xs);
}

.alg-insights-title {
    margin-bottom: 4px;
    color: var(--text-3);
    font-weight: 600;
}

.alg-insights ul {
    margin: 0;
    padding-left: 16px;
    color: var(--text-2);
    line-height: 1.5;
}

.alg-insights code {
    font: 500 11px var(--font-mono);
    color: var(--text);
}

.case-stats-empty {
    grid-column: 1 / -1;
    color: var(--text-3);
    font-size: var(--fs-xs);
    line-height: 1.45;
}







/* ── Learning mode (trainer.html?learn=…) ──────────────────────────────── */

/* The upcoming case, above the cube */
.learn-card {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    width: min(520px, 100%);
    margin-bottom: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-md);
    background: var(--surface);
    user-select: text;
    -webkit-user-select: text;
}

.learn-card[hidden] {
    display: none;
}

.learn-card-head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.learn-card-head .btn {
    margin-left: auto;
}

.learn-badge {
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.learn-card.is-new .learn-badge { background: var(--accent-soft); color: var(--accent-text); }
.learn-card.is-learning .learn-badge { background: var(--bad-soft); color: var(--bad); }
.learn-card.is-review .learn-badge { background: var(--good-soft); color: var(--good); }

.learn-card-name {
    font-weight: 600;
}

.learn-card-title {
    font-weight: 600;
}

.learn-card-text {
    color: var(--text-2);
    font-size: var(--fs-sm);
    line-height: 1.5;
}

.learn-card.is-done {
    align-items: flex-start;
}

.learn-new {
    display: flex;
    gap: var(--sp-3);
    align-items: center;
}

.learn-new-img {
    flex: none;
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.learn-alg {
    font-size: var(--fs-md);
}

.btn-sm {
    height: 26px;
    padding: 0 8px;
    font-size: var(--fs-xs);
}

/* Today's counts in the header */
.learn-count.count-new { color: var(--accent-text); }
.learn-count.count-learning { color: var(--bad); }
.learn-count.count-review { color: var(--good); }

/* Rating after a solve */
.learn-rating {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.learn-rating[hidden] {
    display: none;
}

.learn-rating > label {
    color: var(--text-3);
    font-size: var(--fs-xs);
    font-weight: 600;
}

.rate-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.rate-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--text);
    font: 500 var(--fs-sm) / 1.2 var(--font-sans);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.rate-btn:hover {
    background: var(--surface-3);
}

.rate-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.rate-when {
    color: var(--text-3);
    font: 500 var(--fs-xs) var(--font-mono);
}

.rate-1 .rate-name { color: var(--bad); }
.rate-2 .rate-name { color: var(--warn); }
.rate-3 .rate-name { color: var(--good); }
.rate-4 .rate-name { color: var(--accent-text); }

.rate-btn.is-suggested {
    border-color: var(--line-strong);
    border-style: dashed;
}

.rate-btn.is-picked {
    border-color: var(--accent);
    border-style: solid;
    background: var(--accent-soft);
}

.rate-note {
    color: var(--text-2);
    font-size: var(--fs-xs);
    line-height: 1.5;
}

.rate-hint {
    display: block;
    color: var(--text-3);
}

/* Recap complete (uses the case info window's look, styles/caseInfo.css) */
.recap-done-card {
    width: min(440px, 100%);
}

.recap-done-card p {
    color: var(--text-2);
    font-size: var(--fs-sm);
    line-height: 1.5;
}

.recap-done-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}
