        :root {
            --bg: #000000;
            --card-bg: #1e1e1e;
            --pill-bg: #333;
            --text-main: #eee;
            --text-dim: #666;
            --accent: #4caf50;
            --reject: #ff453a;
            --gold: #ffd700;
            --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        }

        body {
            background-color: var(--bg);
            color: var(--text-main);
            font-family: var(--font);
            margin: 0;
            height: 100vh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            user-select: none;
            -webkit-tap-highlight-color: transparent;
        }

        header {
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            z-index: 10;
            flex-shrink: 0;
            height: 40px;
            box-sizing: content-box;
        }
        
        .brand {
            display: flex;
            align-items: center;
            line-height: 0;
        }

        .brand-logo {
            display: block;
            width: auto;
            height: 24px;
            opacity: 0.4;
        }
        
        .menu-btn {
            background: none; border: none; color: var(--text-main); font-size: 1.5rem; cursor: pointer;
            padding: 10px; line-height: 1; margin-right: -10px;
        }

        #stage {
            flex: 1;
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            perspective: 1000px;
            padding: 20px;
            transform: translateZ(0);
        }

        /* STATES */
        .system-msg {
            text-align: center; color: #666; animation: fadeIn 1s ease;
            position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%;
            font-size: 1rem; font-weight: 500;
            z-index: 0; pointer-events: none;
        }
        
        .err-technical {
            display: block; margin-top: 8px; 
            font-family: monospace; font-size: 0.75rem; 
            color: #333; 
        }

        .empty-state {
            text-align: center; color: #444; animation: fadeIn 0.5s ease;
            margin-top: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 80%;
            z-index: 0;
        }
        .empty-state h2 { margin: 0 0 15px 0; font-size: 1.6rem; color: #eee; font-weight: 700; }
        .empty-state p { margin: 0; color: #888; font-size: 1rem; line-height: 1.5; }
        
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

        /* CARD */
        .card {
            background: var(--card-bg);
            width: 100%;
            max-width: 340px;
            height: 55vh;
            border-radius: 24px;
            padding: 30px;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            text-align: center;
            position: absolute;
            box-shadow: 0 15px 50px rgba(0,0,0,0.9);
            border: 1px solid #333;
            will-change: transform, opacity;
            transform-origin: 50% 100%;
            -webkit-user-select: none;
            user-select: none;
        }

        .card.active { cursor: grab; z-index: 100; }
        .card.editing { z-index: 200; border-color: #555; box-shadow: 0 20px 60px rgba(0,0,0,0.9); transition: none; }
        .card.stacked { pointer-events: none; filter: brightness(0.92); border-top: 1px solid #666; }

        .card.animate { transition: transform 0.3s ease-out, opacity 0.3s ease; }
        .card.spring { transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
        .card-text { font-size: 1.5rem; line-height: 1.5; font-weight: 600; pointer-events: auto; width: 100%; word-wrap: break-word; white-space: pre-wrap; -webkit-user-select: none; user-select: none; }
        
        .link-pill {
            display: inline-flex; align-items: center; vertical-align: middle; max-width: 90%;
            background: var(--pill-bg); padding: 4px 12px 4px 8px; border-radius: 50px;
            color: #fff; text-decoration: none; font-size: 0.85rem; font-weight: 500;
            margin: 2px 4px 2px 0; border: 1px solid #444; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
            cursor: pointer; user-select: none;
        }
        .link-pill[contenteditable="false"] { user-select: none; cursor: default; }
        .link-icon { margin-right: 6px; color: var(--text-dim); font-size: 1rem; }
        .link-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

        .card-input-div {
            font-size: 1.5rem; line-height: 1.5; font-weight: 600;
            color: var(--text-main); background: transparent; border: none;
            width: 100%; height: 100%; text-align: center; outline: none; 
            font-family: inherit; padding: 0; margin: 0; overflow-y: auto; white-space: pre-wrap;
            -webkit-user-select: text;
            user-select: text;
        }
        .card-input-div:empty::before { content: attr(data-placeholder); color: #444; display: block; }
        .card-input-div a { color: inherit; text-decoration: none; pointer-events: none; }

        .card-meta {
            margin-top: 30px; font-size: 0.8rem; color: var(--text-dim);
            text-transform: uppercase; letter-spacing: 1px; pointer-events: none;
            display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%;
        }
        
        .promo-badge {
            display: inline-flex; align-items: baseline; justify-content: center; gap: 6px;
            color: var(--theme-color, var(--gold));
            border: 1px solid var(--theme-border, rgba(255, 215, 0, 0.4));
            background: var(--theme-bg, rgba(255, 215, 0, 0.08));
            padding: 7px 16px; border-radius: 20px; text-decoration: none; font-weight: 700; font-size: 0.75rem;
            letter-spacing: 0.5px; transition: 0.2s; cursor: pointer; pointer-events: auto; touch-action: manipulation;
        }
        .promo-badge:active { 
            background: var(--theme-color, var(--gold)); 
            color: #000; 
            transform: scale(0.95); 
        }
        .promo-badge svg { width: 0.85em; height: 0.85em; display: inline-block; fill: currentColor; transform: translateY(1px); }

        .promo-hint {
            font-size: 0.65rem; color: #555; font-weight: 500; letter-spacing: 0.5px;
            opacity: 0.8;
            margin-top: 0; 
        }

        .card-btn-wrapper {
            width: 60px; height: 60px;
            display: flex; align-items: center; justify-content: center;
            pointer-events: auto; z-index: 100; cursor: pointer;
            touch-action: manipulation;
        }

        .card-icon {
            width: 22px; height: 22px; border-radius: 50%; background: transparent;
            display: flex; justify-content: center; align-items: center;
            opacity: 1; transition: transform 0.1s, background 0.1s;
        }

        .icon-delete { border: 2px solid var(--reject); color: var(--reject); }
        .card-btn-wrapper:active .icon-delete { background: var(--reject); color: #1e1e1e; transform: scale(0.9); }
        .icon-save { border: 2px solid var(--accent); color: var(--accent); }
        .card-btn-wrapper:active .icon-save { background: var(--accent); color: #1e1e1e; transform: scale(0.9); }

        .card-copy {
            position: absolute;
            top: 16px;
            right: 16px;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: auto;
            cursor: pointer;
            z-index: 120;
            touch-action: manipulation;
        }

        .icon-copy {
            width: 18px;
            height: 18px;
            color: var(--text-main);
            opacity: 0.25;
            transition: opacity 0.2s ease, transform 0.1s ease;
        }
        
        .icon-copy svg {
            width: 100%;
            height: 100%;
            display: block;
            color: var(--text-main);
            pointer-events: none;
        }

        .card-copy:hover .icon-copy {
            opacity: 0.4;
        }

        .card-copy:active .icon-copy {
            transform: scale(0.95);
            opacity: 0.8;
        }

        .copy-label {
            position: absolute;
            right: 32px;
            top: 50%;
            transform: translateY(-50%);
            font-size: 0.65rem;
            letter-spacing: 0.3px;
            color: var(--text-main);
            opacity: 0;
            white-space: nowrap;
            pointer-events: none;
            transition: opacity 0.2s ease;
        }

        .card-copy.show-copied .copy-label {
            opacity: 0.45;
        }

        /* CONTROLS */
        .controls {
            height: 120px; display: flex; justify-content: center; align-items: center; gap: 30px;
            z-index: 1000; padding-bottom: 35px; transition: opacity 0.2s ease;
            pointer-events: none;
        }
        .controls.hidden { opacity: 0; pointer-events: none; }

        .btn {
            border-radius: 50%; border: 1px solid #333;
            background: #111; color: var(--text-main); 
            cursor: pointer; display: flex; justify-content: center; align-items: center;
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            z-index: 1001; pointer-events: auto; 
            -webkit-user-select: none; touch-action: manipulation;
            box-shadow: 0 10px 20px rgba(0,0,0,0.5);
        }
        
        .btn-main { width: 70px; height: 70px; font-size: 1.8rem; }
        .btn-add { width: 50px; height: 50px; font-size: 1.6rem; color: #555; border-color: #222; background: transparent; box-shadow: none; }
        .btn.hidden-btn { opacity: 0; transform: scale(0.5); pointer-events: none; }
        
        .btn-yes:active { border-color: var(--accent); color: var(--accent); background: #222; transform: scale(0.95); }
        .btn-no:active { border-color: var(--reject); color: var(--reject); background: #222; transform: scale(0.95); }
        .btn-add:active { color: #fff; border-color: #fff; background: #222; transform: scale(0.95); box-shadow: 0 0 15px rgba(255,255,255,0.1); }

        /* DRAG & DROP OVERLAY */
        #dragOverlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0, 0, 0, 0.85);
            z-index: 5000;
            display: flex; flex-direction: column; justify-content: center; align-items: center;
            pointer-events: none; opacity: 0; transition: opacity 0.2s;
            backdrop-filter: blur(5px);
        }
        #dragOverlay.active { opacity: 1; pointer-events: auto; }
        .drag-box {
            width: 80%; height: 60%;
            border: 2px dashed var(--accent);
            border-radius: 24px;
            display: flex; flex-direction: column; justify-content: center; align-items: center;
            color: var(--accent);
            background: rgba(76, 175, 80, 0.1);
        }
        .drag-text { margin-top: 20px; font-size: 1.2rem; font-weight: 600; text-align: center; }
        .drag-icon { font-size: 3rem; }

        /* LIBRARY & MODALS */
        .library-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg); z-index: 2000; display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
        .library-overlay.open { transform: translateY(0); }
        
        .lib-header { 
            padding: 15px 20px; 
            display: flex; justify-content: space-between; align-items: center; 
            border-bottom: 1px solid #222; flex-shrink: 0; 
            height: 40px; box-sizing: content-box;
        }
        
        .lib-title { font-size: 1.5rem; font-weight: 800; line-height: 1; }
        
        .lib-actions { display: flex; align-items: center; }
        .lib-refresh {
            background: none; border: none; color: var(--text-dim);
            display: flex; align-items: center; justify-content: center;
            padding: 8px; cursor: pointer; transition: color 0.2s;
            margin-right: -5px; 
        }
        .lib-refresh:active { color: var(--text-main); }
        .lib-refresh svg { width: 20px; height: 20px; fill: currentColor; }
        @keyframes spin { 100% { transform: rotate(360deg); } }
        .icon-spin svg { animation: spin 1s linear infinite; }

        .lib-close { 
            background: none; border: none; color: var(--text-main); 
            font-size: 1.5rem; cursor: pointer; 
            padding: 10px; line-height: 1; margin-right: -10px; 
        }

        .lib-content { flex: 1; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; }
        .lib-footer { padding: 20px; background: var(--bg); border-top: 1px solid #222; flex-shrink: 0; }
        
        .lib-section-header { 
            display: flex; justify-content: space-between; align-items: center; 
            margin-bottom: 15px; 
        }
        
        .lib-subtitle { 
            font-size: 0.8rem; text-transform: uppercase; 
            color: var(--text-dim); letter-spacing: 1px; font-weight: 700; 
            margin: 0;
        }
        
        .lib-footer .lib-subtitle { margin-bottom: 15px; }
        
        .deck-list { display: flex; flex-direction: column; gap: 10px; }
        .deck-item { background: var(--card-bg); padding: 0 15px; height: 70px; border-radius: 12px; border: 1px solid #333; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
        .deck-info { display: flex; flex-direction: column; gap: 4px; }
        .deck-name { font-weight: 600; font-size: 1rem; }
        .deck-count { font-size: 0.8rem; color: #666; }
        .deck-action { color: var(--reject); font-size: 1.2rem; cursor: pointer; padding: 10px; display: flex; align-items: center; justify-content: center; height: 100%; }
        .deck-placeholder { width: 40px; } 
        .add-deck-btn { width: 100%; padding: 15px; border: 1px dashed #444; border-radius: 12px; color: var(--text-dim); background: transparent; font-size: 0.9rem; cursor: pointer; margin-bottom: 15px; transition: 0.2s; flex-shrink: 0; }
        .add-deck-btn:active { background: #222; color: #fff; border-color: #666; }
        .data-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
        .action-btn { background: #1a1a1a; border: 1px solid #444; color: var(--text-main); padding: 15px; border-radius: 12px; font-size: 0.9rem; cursor: pointer; text-align: center; }
        .action-btn:active { background: #333; }

        .modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); backdrop-filter: blur(10px); display: none; justify-content: center; align-items: center; z-index: 3000; opacity: 0; transition: opacity 0.2s; will-change: opacity; }
        .modal.open { display: flex; opacity: 1; }
        .modal-content { background: #1a1a1a; padding: 25px; border-radius: 24px; width: 85%; max-width: 320px; border: 1px solid #333; box-shadow: 0 20px 60px rgba(0,0,0,0.9); transform: scale(0.95); transition: transform 0.2s; text-align: center; }
        .modal.open .modal-content { transform: scale(1); }
        .modal-title { font-size: 1.1rem; font-weight: bold; margin-bottom: 10px; color: #fff; }
        .modal-desc { font-size: 0.9rem; color: #aaa; margin-bottom: 25px; line-height: 1.4; }
        .modal-input { width: 100%; background: #000; border: 1px solid #333; color: white; padding: 12px; border-radius: 8px; font-size: 1rem; box-sizing: border-box; margin-bottom: 20px; outline: none; }
        .modal-actions { display: flex; gap: 10px; }
        .modal-btn { flex: 1; padding: 12px; border-radius: 12px; border: none; font-size: 1rem; font-weight: 600; cursor: pointer; }
        .btn-cancel { background: #3a3a3a; color: #fff; }
        .btn-confirm { background: var(--accent); color: #000; }
        .btn-confirm-delete { background: var(--reject); color: #fff; }

        .console-link { position: fixed; bottom: 10px; left: 10px; color: #333; font-size: 0.7rem; text-decoration: none; cursor: pointer; z-index: 200; }
        #debugConsole { position: fixed; bottom: 0; left: 0; width: 100%; height: 40vh; background: #0a0a0a; border-top: 1px solid #333; display: none; flex-direction: column; z-index: 4000; font-family: monospace; padding: 10px; box-sizing: border-box; color: #0f0; }
        .debug-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid #222; }
        
        .debug-btn {
            background: #333; color: #fff; border: 1px solid #555; padding: 0 10px; 
            cursor: pointer; font-size: 0.8rem;
        }
        .debug-btn:active { background: #555; }
    
