:root {
    --bg-dark: #0d1117;
    --bg-card: #161b22;
    --bg-card-hover: #1f242c;
    --border-color: #30363d;
    --border-highlight: #58a6ff;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-emerald: #2ea043;
    --accent-emerald-light: #3fb950;
    --accent-gold: #d29922;
    --accent-blue: #388bfd;
    --suit-red: #f85149;
    --suit-black: #e6edf3;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.4);
    --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: 60px;
}

/* Header */
.app-header {
    background: linear-gradient(180deg, #161b22 0%, #0d1117 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 18px 32px;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-icon {
    font-size: 1.6rem;
    display: flex;
    gap: 4px;
    background: #21262d;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.suit-spades { color: #f0f6fc; }
.suit-hearts { color: var(--suit-red); }
.suit-diamonds { color: var(--suit-red); }
.suit-clubs { color: #58a6ff; }

.brand-text h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.brand-text h1 span {
    color: var(--accent-emerald-light);
    font-size: 1.2rem;
    font-weight: 700;
    background: rgba(63, 185, 80, 0.15);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-left: 4px;
}

.brand-text p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.device-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #21262d;
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-emerald-light);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-emerald-light);
}

/* Main Container */
.app-main {
    max-width: 1400px;
    margin: 28px auto 0;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Card Panel */
.card-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
}

.panel-header {
    margin-bottom: 20px;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: #0d1117;
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent-emerald-light);
    background: rgba(46, 160, 67, 0.05);
}

.upload-icon-wrapper {
    width: 56px;
    height: 56px;
    background: #21262d;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: var(--accent-emerald-light);
    border: 1px solid var(--border-color);
}

.upload-icon {
    width: 28px;
    height: 28px;
}

.drop-text h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.drop-text h3 span {
    color: var(--accent-emerald-light);
    text-decoration: underline;
}

.file-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.format-badges {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.badge {
    background: #21262d;
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.file-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #21262d;
    border: 1px solid var(--accent-emerald);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    margin-top: 14px;
}

.file-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.file-icon {
    font-size: 1.5rem;
}

.file-meta strong {
    display: block;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.file-meta span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn-clear {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

.btn-clear:hover {
    color: var(--suit-red);
}

/* Config Bar */
.config-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 170px;
}

.config-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.val-display {
    color: var(--accent-emerald-light);
    font-family: var(--font-mono);
}

.config-group select {
    background: #0d1117;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    outline: none;
    font-family: var(--font-main);
}

.config-group select:focus {
    border-color: var(--accent-emerald-light);
}

.config-group input[type="range"] {
    accent-color: var(--accent-emerald-light);
    cursor: pointer;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--accent-emerald);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-emerald-light);
    box-shadow: 0 0 16px rgba(46, 160, 67, 0.4);
}

.btn-primary:disabled {
    background-color: #21262d;
    color: var(--text-muted);
    cursor: not-allowed;
    border-color: var(--border-color);
}

.btn-secondary {
    background-color: #21262d;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: #30363d;
    border-color: var(--text-muted);
}

.btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Progress Section */
.progress-section {
    margin-top: 24px;
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.progress-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.pulse-indicator {
    width: 10px;
    height: 10px;
    background-color: var(--accent-emerald-light);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 10px var(--accent-emerald-light); }
    100% { transform: scale(0.9); opacity: 0.8; }
}

.progress-percent {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent-emerald-light);
    font-size: 1.1rem;
}

.progress-bar-track {
    width: 100%;
    height: 8px;
    background-color: #21262d;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-emerald) 0%, var(--accent-emerald-light) 100%);
    transition: width 0.2s ease;
}

.progress-subinfo {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    margin-top: 8px;
}

/* ==========================================================================
   PREMIUM LIVE DISCOVERED CARDS SHOWCASE
   ========================================================================== */

.live-discovery-showcase,
.live-chips-container {
    margin-top: 18px;
    padding: 18px 20px;
    background: linear-gradient(145deg, rgba(22, 27, 34, 0.95) 0%, rgba(13, 17, 23, 0.98) 100%);
    border: 1px solid rgba(88, 166, 255, 0.22);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.live-discovery-showcase::before,
.live-chips-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #388bfd, #2ea043, #d29922, #f85149);
    opacity: 0.9;
}

/* Header */
.discovery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(48, 54, 61, 0.75);
    flex-wrap: wrap;
}

.discovery-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.discovery-title-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.live-discovery-title,
.live-chips-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
    margin: 0;
    white-space: nowrap;
}

/* Pulsing live radar dot */
.live-pulse-indicator {
    position: relative;
    width: 12px;
    height: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pulse-core {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #3fb950;
    box-shadow: 0 0 10px #3fb950;
}

.pulse-ring {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #3fb950;
    opacity: 0.7;
    animation: liveRingPulse 1.8s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}

@keyframes liveRingPulse {
    0% { transform: scale(0.4); opacity: 0.95; }
    70% { transform: scale(1.6); opacity: 0; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* Counter Badge */
.discovery-counter-badge {
    background: rgba(46, 160, 67, 0.14);
    border: 1px solid rgba(46, 160, 67, 0.4);
    color: #3fb950;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 700;
    padding: 3px 11px;
    border-radius: 20px;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* View Mode Switcher */
.view-mode-toggle {
    display: inline-flex;
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.view-mode-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.74rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

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

.view-mode-btn.active {
    background: #21262d;
    color: var(--border-highlight);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Empty State / Waiting Scanner */
.discovery-empty-state {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 24px 20px;
    background: rgba(13, 17, 23, 0.5);
    border: 1px dashed rgba(48, 54, 61, 0.85);
    border-radius: var(--radius-md);
    animation: fadeIn 0.3s ease;
}

.scanner-radar-wrap {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.scanner-icon {
    font-size: 1.6rem;
    z-index: 2;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.scanner-radar-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1.5px solid #58a6ff;
    opacity: 0.5;
}

.scanner-radar-ring.ring-1 {
    animation: radarRipple 2s infinite ease-out;
}

.scanner-radar-ring.ring-2 {
    animation: radarRipple 2s infinite 1s ease-out;
}

@keyframes radarRipple {
    0% { transform: scale(0.6); opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
}

.empty-state-text h4 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.empty-state-text p {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

.empty-state-text p strong {
    color: var(--text-primary);
}

/* Cards Deck Layout */
.discovery-deck-grid.view-grid,
.live-chips-list.view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    width: 100%;
}

.discovery-deck-grid.view-reel,
.live-chips-list.view-reel {
    display: flex;
    overflow-x: auto;
    gap: 14px;
    padding: 4px 2px 12px 2px;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: #30363d transparent;
    width: 100%;
}

.discovery-deck-grid.view-reel::-webkit-scrollbar,
.live-chips-list.view-reel::-webkit-scrollbar {
    height: 6px;
}

.discovery-deck-grid.view-reel::-webkit-scrollbar-track,
.live-chips-list.view-reel::-webkit-scrollbar-track {
    background: rgba(13, 17, 23, 0.4);
    border-radius: 3px;
}

.discovery-deck-grid.view-reel::-webkit-scrollbar-thumb,
.live-chips-list.view-reel::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

.discovery-deck-grid.view-reel .discovered-card-item,
.live-chips-list.view-reel .discovered-card-item {
    min-width: 270px;
    max-width: 270px;
    flex-shrink: 0;
    scroll-snap-align: start;
}

/* ==========================================================================
   INDIVIDUAL DISCOVERED CARD ITEM TILE
   ========================================================================== */

.discovered-card-item {
    background: linear-gradient(160deg, #1b2028 0%, #13171f 100%);
    border: 1px solid rgba(208, 215, 222, 0.12);
    border-radius: var(--radius-md);
    padding: 12px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, border-color 0.22s ease;
    animation: cardGlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    overflow: hidden;
}

.discovered-card-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(88, 166, 255, 0.35);
    border-color: rgba(88, 166, 255, 0.4);
}

.discovered-card-item.suit-hearts,
.discovered-card-item.suit-diamonds {
    border-top: 2px solid #f85149;
}

.discovered-card-item.suit-spades {
    border-top: 2px solid #58a6ff;
}

.discovered-card-item.suit-clubs {
    border-top: 2px solid #3fb950;
}

@keyframes cardGlideIn {
    0% {
        opacity: 0;
        transform: translateY(14px) scale(0.94);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Card Item Top Bar */
.card-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
}

.card-seq-pill {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-time-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.card-conf-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 12px;
    font-size: 0.68rem;
}

.card-conf-pill .conf-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.card-conf-pill.high {
    background: rgba(46, 160, 67, 0.18);
    color: #3fb950;
    border: 1px solid rgba(46, 160, 67, 0.4);
}
.card-conf-pill.high .conf-dot { background: #3fb950; }

.card-conf-pill.medium {
    background: rgba(210, 153, 34, 0.18);
    color: #d29922;
    border: 1px solid rgba(210, 153, 34, 0.4);
}
.card-conf-pill.medium .conf-dot { background: #d29922; }

.card-conf-pill.low {
    background: rgba(248, 81, 73, 0.18);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.4);
}
.card-conf-pill.low .conf-dot { background: #f85149; }

/* Visual Duo: Mini Card View + Mini Image View */
.card-visual-duo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: stretch;
    padding: 4px 0;
}

.mini-card-view-wrapper,
.mini-image-view-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.visual-sublabel {
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
}

/* ==========================================================================
   MINI CARD VIEW (Playing Card Representation)
   ========================================================================== */

.mini-card-view {
    width: 58px;
    height: 82px;
    background: linear-gradient(150deg, #ffffff 0%, #f7f9fa 100%);
    border: 1px solid #d0d7de;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.9);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 5px;
    user-select: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mini-card-view:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

.mini-card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    z-index: 2;
}

.mini-card-corner.top-left {
    align-self: flex-start;
}

.mini-card-corner.bottom-right {
    align-self: flex-end;
    transform: rotate(180deg);
}

.mini-rank {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 0.82rem;
    line-height: 1;
    letter-spacing: -0.5px;
}

.mini-suit {
    font-size: 0.72rem;
    line-height: 1;
    margin-top: 1px;
}

.mini-card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}

.mini-center-suit {
    font-size: 1.6rem;
    line-height: 1;
    opacity: 0.88;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.1));
}

.mini-card-sheen {
    position: absolute;
    top: -60%;
    left: -60%;
    width: 220%;
    height: 220%;
    background: linear-gradient(45deg, transparent 42%, rgba(255, 255, 255, 0.6) 50%, transparent 58%);
    pointer-events: none;
    transform: rotate(25deg);
    opacity: 0.7;
}

/* Mini card color themes */
.mini-card-view.suit-hearts,
.mini-card-view.suit-diamonds,
.mini-card-view.suit-red {
    color: #cf222e;
}

.mini-card-view.suit-spades,
.mini-card-view.suit-clubs,
.mini-card-view.suit-black {
    color: #0f141c;
}

/* ==========================================================================
   MINI IMAGE VIEW (Camera Video Crop)
   ========================================================================== */

.mini-image-view {
    width: 58px;
    height: 82px;
    background: #090d14;
    border: 1px solid rgba(88, 166, 255, 0.35);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    cursor: zoom-in;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.mini-image-view:hover {
    transform: scale(1.05);
    border-color: #58a6ff;
    box-shadow: 0 6px 18px rgba(56, 139, 253, 0.3);
}

.mini-crop-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.mini-image-view:hover .mini-crop-img {
    transform: scale(1.15);
}

.image-crop-badge {
    position: absolute;
    top: 3px;
    left: 3px;
    background: rgba(13, 17, 23, 0.88);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #58a6ff;
    font-family: var(--font-mono);
    font-size: 0.54rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    letter-spacing: 0.4px;
    z-index: 2;
    pointer-events: none;
}

.img-zoom-overlay {
    position: absolute;
    inset: 0;
    background: rgba(9, 13, 20, 0.72);
    backdrop-filter: blur(1.5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #ffffff;
    font-size: 0.64rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 3;
}

.mini-image-view:hover .img-zoom-overlay {
    opacity: 1;
}

.mini-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 0.6rem;
    text-align: center;
    padding: 4px;
}

.mini-image-placeholder span {
    font-size: 1.2rem;
}

/* Card Item Metadata & Jump Action */
.card-item-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.card-item-name {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-item-submeta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.card-suit-meta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.btn-card-jump {
    background: rgba(33, 38, 45, 0.7);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.72rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-card-jump:hover {
    background: #1f6feb;
    border-color: #388bfd;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(56, 139, 253, 0.35);
}

.btn-card-jump svg {
    flex-shrink: 0;
}

/* Legacy tag fallback */
.chip-tag {
    background: #21262d;
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    animation: fadeInScale 0.3s ease;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Results Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.metric-icon {
    font-size: 2rem;
    background: #0d1117;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.metric-details {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.metric-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    margin: 2px 0;
}

.metric-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Workspace Layout */
.workspace-layout {
    display: grid;
    grid-template-columns: 480px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1100px) {
    .workspace-layout {
        grid-template-columns: 1fr;
    }
}

/* Video Panel */
.video-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel-header-mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header-mini h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.overlay-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #30363d;
    transition: .3s;
    border-radius: 18px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-emerald);
}

input:checked + .slider:before {
    transform: translateX(16px);
}

.video-container {
    position: relative;
    width: 100%;
    background: #05070a;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 280px;
    max-height: 560px;
    border: 1px solid var(--border-color);
}

#videoPlayer {
    max-width: 100%;
    max-height: 560px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

#overlayCanvas {
    position: absolute;
    pointer-events: none;
    z-index: 5;
}

.video-meta-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.current-cards-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 32px;
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
}

.strip-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.strip-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.placeholder-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.video-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-pill {
    background: #21262d;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.78rem;
    cursor: pointer;
}

.btn-pill:hover {
    background: #30363d;
}

.playback-time {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Table Panel */
.table-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.table-title-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-title-area h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.table-count {
    background: #21262d;
    color: var(--accent-emerald-light);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.table-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: #21262d;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-sm:hover {
    background: #30363d;
    border-color: var(--text-muted);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 220px;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    background: #0d1117;
    border: 1px solid var(--border-color);
    padding: 8px 30px 8px 32px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font-main);
}

.search-box input:focus {
    outline: none;
    border-color: var(--border-highlight);
}

#btnClearSearch {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
}

.suit-filters {
    display: flex;
    gap: 6px;
}

.filter-pill {
    background: #0d1117;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-pill:hover {
    background: #21262d;
    color: var(--text-primary);
}

.filter-pill.active {
    background: #21262d;
    border-color: var(--accent-emerald-light);
    color: var(--accent-emerald-light);
}

.sort-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.sort-box select {
    background: #0d1117;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

/* Table Container */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.detected-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.detected-table thead {
    background: #0d1117;
    border-bottom: 2px solid var(--border-color);
}

.detected-table th {
    padding: 12px 14px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.detected-table tbody tr {
    border-bottom: 1px solid #21262d;
    transition: background-color 0.15s;
}

.detected-table tbody tr:hover {
    background-color: var(--bg-card-hover);
}

.detected-table td {
    padding: 12px 14px;
    vertical-align: middle;
}

/* Playing Card Graphic Chip */
.card-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 32px;
    background: #ffffff;
    color: #111111;
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 0.95rem;
    border-radius: 4px;
    border: 1px solid #d0d7de;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.5px;
}

.card-chip.suit-hearts,
.card-chip.suit-diamonds {
    color: #cf222e;
}

.card-chip.suit-spades,
.card-chip.suit-clubs {
    color: #0d1117;
}

/* Thumbnail Snapshot */
.thumb-cell {
    position: relative;
}

.card-thumb {
    width: 50px;
    height: 65px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: #0d1117;
    cursor: zoom-in;
    transition: transform 0.2s, box-shadow 0.2s;
    display: block;
}

.card-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    border-color: var(--border-highlight);
    z-index: 10;
}

.card-name-cell {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Suit Badge */
.suit-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #21262d;
    white-space: nowrap;
}

.suit-badge.suit-hearts,
.suit-badge.suit-diamonds {
    color: var(--suit-red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.suit-badge.suit-spades,
.suit-badge.suit-clubs {
    color: #f0f6fc;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.rank-badge {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Confidence Meter */
.conf-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conf-val {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.conf-bar {
    width: 100%;
    height: 5px;
    background: #21262d;
    border-radius: 3px;
    overflow: hidden;
}

.conf-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent-emerald);
}

.conf-fill.high { background: var(--accent-emerald-light); }
.conf-fill.medium { background: var(--accent-gold); }
.conf-fill.low { background: var(--suit-red); }

.frames-cell {
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.time-range {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.btn-jump {
    background: #21262d;
    border: 1px solid var(--border-color);
    color: var(--accent-emerald-light);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-jump:hover {
    background: var(--accent-emerald);
    color: #ffffff;
    border-color: var(--accent-emerald);
}

.empty-state {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
}

/* Modal Lightbox */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.modal-img-container {
    width: 180px;
    height: 240px;
    background: #0d1117;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-img-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.modal-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
}

.meta-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.meta-val {
    font-size: 0.95rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Sequence & First Seen Badges */
.seq-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(46, 160, 67, 0.15);
    color: var(--accent-emerald-light);
    border: 1px solid rgba(46, 160, 67, 0.4);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}

.time-tag {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-primary);
    background: #0d1117;
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
