/* ================================================================
   WanGame Eval — Evaluation Card + Rating UI
   ================================================================ */

/* Override shared .page constraints — evaluate needs full width */
#page-evaluate.page {
    max-width: none;
    padding: 0 4px;
}

/* Toolbar */
.eval-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    margin-bottom: 4px;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.toolbar-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.toolbar-controls {
    display: flex;
    gap: 4px;
}

.eval-chunk-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Dots */
.eval-dots {
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 0 8px;
    margin-bottom: 6px;
}

.eval-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
}

.eval-dot.active {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    transform: scale(1.4);
}

.eval-dot.committed {
    background: var(--good);
}

.eval-dot.skipped {
    background: var(--warn);
}

/* Controls row: speed + size sliders */
.eval-controls-row {
    display: flex;
    gap: 16px;
    padding: 4px 12px 8px;
    align-items: center;
    justify-content: center;
}

.control-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
}

.control-label input[type="range"] {
    width: 80px;
    height: 4px;
    accent-color: var(--accent);
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.control-label input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.control-value {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 28px;
    text-align: right;
}

/* Card container */
.eval-card-container {
    position: relative;
    margin: 0 auto;
    max-width: 90vw;
    transition: max-width 0.2s ease;
}

.eval-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s ease;
    will-change: transform;
}

.eval-card.swiping-left {
    transform: translateX(-120%) rotate(-15deg);
    opacity: 0;
}

.eval-card.swiping-right {
    transform: translateX(120%) rotate(15deg);
    opacity: 0;
}

.eval-card.swiping-up {
    transform: translateY(-120%);
    opacity: 0;
}

.eval-card.entering {
    animation: cardEnter 0.15s ease forwards;
}

/* Video */
.eval-video-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    cursor: pointer;
}

.eval-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.eval-video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s;
}

.eval-video-overlay.show {
    opacity: 1;
}

.eval-overlay-icon {
    font-size: 48px;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

/* Time / frame badge */
.eval-time-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
    pointer-events: none;
}

/* Meta — compact single line */
.eval-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    flex-wrap: wrap;
}

.eval-caption {
    font-size: 13px;
    font-weight: 600;
}

.eval-tag {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Swipe indicators */
.swipe-indicator {
    position: absolute;
    font-size: 64px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 10;
}

.swipe-indicator.left {
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
}

.swipe-indicator.right {
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
}

.swipe-indicator.top {
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
}

/* Rating buttons */
.eval-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 20px 16px;
    padding-bottom: calc(20px + var(--safe-bottom));
}

.btn-rate {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 28px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    min-width: 90px;
}

.btn-rate.bad {
    border-color: var(--bad);
    background: var(--bad-glow);
    color: var(--bad);
}

.btn-rate.skip {
    border-color: var(--warn);
    background: rgba(245, 158, 11, 0.08);
    color: var(--warn);
}

.btn-rate.good {
    border-color: var(--good);
    background: var(--good-glow);
    color: var(--good);
}

.btn-rate-icon {
    font-size: 24px;
}

.btn-rate:hover {
    transform: translateY(-3px);
}

.btn-rate:active {
    transform: scale(0.95);
}

.btn-rate.bad:hover {
    box-shadow: 0 8px 24px var(--bad-glow);
    transform: translateY(-3px);
}

.btn-rate.skip:hover {
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.15);
    transform: translateY(-3px);
}

.btn-rate.good:hover {
    box-shadow: 0 8px 24px var(--good-glow);
    transform: translateY(-3px);
}

.key-hint {
    opacity: 0.4;
    font-size: 10px;
    margin-left: 2px;
    border: 1px solid currentColor;
    border-radius: 3px;
    padding: 0 3px;
    vertical-align: middle;
}

.btn-rate.pressed {
    transform: scale(0.92);
    filter: brightness(1.5);
    transition: none;
}

/* ====== Review Bad Videos Page ====== */
.review-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    overflow: hidden;
    transition: var(--transition);
}

.review-card.needs-review {
    border-left: 3px solid var(--bad);
}

.review-card.reviewed {
    border-left: 3px solid var(--good);
    opacity: 0.7;
}

.review-card.reviewed:hover {
    opacity: 1;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
}

.review-label {
    font-weight: 500;
    font-size: 14px;
}

.review-step {
    font-size: 12px;
    color: var(--text-muted);
}

.review-body {
    display: flex;
    gap: 16px;
    padding: 14px;
    align-items: flex-start;
}

.review-video {
    width: 240px;
    min-width: 200px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: #000;
}

.review-tags {
    flex: 1;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.issue-tag {
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.issue-tag:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.issue-tag.active {
    background: var(--bad-glow);
    border-color: var(--bad);
    color: var(--bad);
    font-weight: 500;
}

.review-other-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.review-other-row .form-input {
    flex: 1;
}

@media (max-width: 600px) {
    .review-body {
        flex-direction: column;
    }

    .review-video {
        width: 100%;
    }
}

/* ------ Empty / setup state ------ */
.eval-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}

.eval-empty-inner {
    max-width: 480px;
    padding: 20px;
}

.eval-empty-msg {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.eval-empty-state h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.eval-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

.eval-summary-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 12px;
}

.eval-stat {
    font-size: 15px;
    font-weight: 500;
}

.eval-stat.good {
    color: var(--good);
}

.eval-stat.bad {
    color: var(--bad);
}

.eval-stat.skip {
    color: var(--text-secondary);
}

/* ------ Matrix overview ------ */
.matrix-overview {
    text-align: center;
    padding: 10px 0;
    max-width: 520px;
    margin: 0 auto;
}

.matrix-overview h2 {
    font-size: 22px;
    margin-bottom: 4px;
}

.matrix-overview .subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.matrix-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.matrix-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    min-width: 70px;
    transition: var(--transition);
}

.matrix-stat.accent {
    border-color: var(--accent-glow);
}

.matrix-stat-value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.matrix-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

.matrix-info {
    font-size: 12px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    margin-bottom: 20px;
    display: inline-block;
}

/* Chunk config */
.chunk-config {
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
}

.chunk-config h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.config-row {
    margin-bottom: 16px;
}

.config-row:last-child {
    margin-bottom: 0;
}

.config-row>label {
    font-size: 13px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 8px;
}

.toggle-group {
    display: flex;
    gap: 8px;
}

.toggle-btn {
    flex: 1;
    padding: 12px;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1.4;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.toggle-btn.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--text-primary);
}

.toggle-desc {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 400;
}

.toggle-btn.active .toggle-desc {
    color: var(--text-secondary);
}

.chunk-sizes {
    display: flex;
    gap: 8px;
}

.size-btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.size-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.size-btn.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--text-primary);
}

.size-custom {
    flex: 1;
    max-width: 80px;
    text-align: center;
    padding: 8px !important;
    font-size: 14px !important;
}

.step-custom-row {
    display: flex;
    gap: 8px;
    max-width: 320px;
}

.step-custom-row .form-input {
    flex: 1;
}

/* Mobile */
@media (max-width: 500px) {
    .matrix-stat {
        padding: 10px 14px;
        min-width: 55px;
    }

    .matrix-stat-value {
        font-size: 20px;
    }

    .toggle-group {
        flex-direction: column;
    }
}

@media (max-width: 400px) {
    .eval-actions {
        gap: 10px;
    }

    .btn-rate {
        padding: 12px 20px;
        min-width: 75px;
    }
}

/* ====== Matrix Comparison Page ====== */
.matrix-filters {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
}

.matrix-filter-group {
    margin-bottom: 12px;
}

.matrix-filter-group:last-child {
    margin-bottom: 0;
}

.matrix-filter-group>label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.matrix-filter-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.matrix-step-chip {
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace, monospace;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.matrix-step-chip:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.matrix-step-chip.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
}

.matrix-cat-chip {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    margin-right: 4px;
    margin-bottom: 4px;
}

.matrix-cat-chip:hover {
    border-color: var(--cat-color);
    color: var(--cat-color);
}

.matrix-cat-chip.active {
    background: color-mix(in srgb, var(--cat-color) 15%, transparent);
    border-color: var(--cat-color);
    color: var(--cat-color);
}

.matrix-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.matrix-grid {
    padding-bottom: 40px;
}

.matrix-header-row,
.matrix-row {
    display: grid;
    gap: 6px;
    margin-bottom: 6px;
    align-items: start;
}

.matrix-header-row {
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 5;
    padding: 6px 0;
}

.matrix-corner {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px;
}

.matrix-col-header {
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    font-family: monospace;
    color: var(--accent);
    padding: 8px;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.matrix-cat-divider {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 16px 0 8px;
    padding: 6px 0;
    border-top: 1px solid var(--border);
}

.matrix-prompt-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border);
    min-height: 40px;
}

.matrix-prompt-idx {
    font-family: monospace;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(88, 166, 255, 0.12);
    padding: 2px 6px;
    border-radius: 4px;
}

.matrix-row-controls {
    margin-left: auto;
    display: flex;
    gap: 2px;
}

.matrix-row-controls button {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.matrix-row-controls button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.matrix-video-cell {
    position: relative;
    background: var(--bg-card);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.15s;
}

.matrix-video-cell:hover {
    border-color: var(--accent);
}

.matrix-video-cell video {
    width: 100%;
    display: block;
}

.matrix-size-tag {
    position: absolute;
    bottom: 3px;
    right: 3px;
    font-size: 9px;
    font-family: monospace;
    background: rgba(0, 0, 0, 0.75);
    color: var(--text-muted);
    padding: 1px 4px;
    border-radius: 3px;
}

.matrix-video-cell.focused {
    border: 3px solid #ffd700 !important;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.4), 0 0 20px rgba(255, 215, 0, 0.5), inset 0 0 8px rgba(255, 215, 0, 0.15);
    transform: scale(1.03);
    z-index: 10;
    animation: matrix-focus-pulse 1.5s ease-in-out infinite;
}

@keyframes matrix-focus-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.4), 0 0 20px rgba(255, 215, 0, 0.5);
    }

    50% {
        box-shadow: 0 0 0 5px rgba(255, 215, 0, 0.6), 0 0 30px rgba(255, 215, 0, 0.7);
    }
}

.matrix-rating-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    padding: 2px 5px;
    pointer-events: none;
}

.matrix-rating-badge.good {
    background: rgba(63, 185, 80, 0.3);
}

.matrix-rating-badge.bad {
    background: rgba(248, 81, 73, 0.3);
}

.matrix-rating-badge.skip {
    background: rgba(210, 153, 34, 0.3);
}

/* ====== Review Overview ====== */
.review-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.review-filter-tabs {
    display: flex;
    gap: 6px;
}

.review-filter-tabs .btn.active {
    background: var(--accent);
    color: #fff;
}

.issue-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    background: rgba(248, 81, 73, 0.15);
    color: #f85149;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    margin: 2px;
}

.review-tags-summary {
    margin-top: 8px;
}

/* ====== Reason Tagger ====== */
.tagger-reasons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    max-width: 700px;
    margin: 0 auto;
}

.tagger-reason-btn {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.tagger-reason-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.tagger-reason-btn.active {
    background: rgba(248, 81, 73, 0.15);
    border-color: #f85149;
    color: #f85149;
}

.tagger-other-row {
    max-width: 500px;
    margin: 8px auto;
    padding: 0 16px;
}

.tagger-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px;
}

.key-hint {
    font-size: 10px;
    font-weight: 700;
    opacity: 0.5;
    border: 1px solid currentColor;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 4px;
}

/* Keyboard shortcut caps */
kbd {
    display: inline-block;
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    padding: 2px 5px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    vertical-align: middle;
    margin: 0 1px;
}

.btn-rate kbd {
    font-size: 10px;
    opacity: 0.6;
    margin-left: 4px;
}

.matrix-key-hints {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.8;
}

/* Cache warm status badge */
.cache-status-badge {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    white-space: nowrap;
}

/* N/A badge for missing videos */
.matrix-na-badge {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    letter-spacing: 0.5px;
}

/* Loading indicator while video is downloading */
.matrix-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.2s ease;
    pointer-events: none;
}