:root {
    --bg-color: #0f1115;
    --panel-bg: #161920;
    --text-main: #e2e8f0;
    --accent: #3b82f6;
    --success: #10b981;
    --error: #ef4444;
    --border: #334155;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "Fira Code", "Courier New", Courier, monospace;
    --telemetry-bg: rgba(0, 0, 0, 0.4);
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-main);
    padding: 20px;
    display: flex;
    justify-content: center;
    margin: 0;
}

.container {
    max-width: 1000px;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

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

.panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

h2 {
    font-size: 18px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 20px;
}

label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.char-count {
    color: var(--accent);
    font-weight: bold;
}

.input-group {
    position: relative;
    margin-bottom: 15px;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 10px;
    padding-right: 40px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    color: white;
    font-family: var(--font-mono);
    box-sizing: border-box;
    font-size: 14px;
}

input:focus {
    outline: none;
    border-color: var(--accent);
}

.peek-btn {
    position: absolute;
    right: 10px;
    top: 10px;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.6;
    user-select: none;
}

button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    background-color: var(--accent);
    color: white;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 15px;
    font-size: 14px;
    transition: background 0.2s ease;
}

button:hover {
    opacity: 0.9;
}

.output-box {
    padding: 15px;
    background-color: #000;
    border: 1px dashed var(--border);
    border-radius: 6px;
    font-family: var(--font-mono);
    word-break: break-all;
    text-align: center;
    color: var(--accent);
    margin-bottom: 15px;
    font-size: 13px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Telemetry Layouts */
.telemetry-panel {
    background-color: var(--telemetry-bg);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 15px;
    font-family: var(--font-mono);
    font-size: 11px;
}

.telemetry-title {
    font-weight: bold;
    color: #94a3b8;
    margin-bottom: 8px;
    font-size: 10px;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 4px;
}

.telemetry-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.telemetry-label {
    color: #64748b;
}

.telemetry-value {
    color: #cbd5e1;
    word-break: break-all;
    text-align: right;
    max-width: 65%;
}

.highlight-blue { color: #60a5fa; }
.highlight-green { color: #34d399; }
.highlight-purple { color: #c084fc; }

#qrcode {
    display: flex;
    justify-content: center;
    margin-top: 15px;
    background: white;
    padding: 15px;
    border-radius: 6px;
}

#qrcode:empty {
    display: none;
}

#reader {
    width: 100%;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 15px;
}

/* ===== DECOY TABLE GRID LAYOUT ===== */
.decoy-grid {
    display: grid;
    grid-template-columns: 140px 140px 30px 1fr 1fr 100px;
    gap: 2px;
    font-size: 0.75rem;
    max-height: 40vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px;
}

/* Grid Header Cells */
.decoy-grid .gh {
    background: var(--bg-tertiary);
    font-weight: 700;
    color: var(--accent);
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Center-align specific header columns */
.decoy-grid .gh:nth-child(3) { text-align: center; }
.decoy-grid .gh:nth-child(6) { text-align: center; }

/* Grid Content Cells */
.decoy-grid .gc {
    padding: 3px 6px;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.7rem;
}

/* Center-align specific content columns */
.decoy-grid .gc:nth-child(3),
.decoy-grid .gc:nth-child(4),
.decoy-grid .gc:nth-child(6) {
    text-align: center;
}

/* Right-align numeric columns */
.decoy-grid .gc:nth-child(1),
.decoy-grid .gc:nth-child(2) {
    text-align: right;
    font-family: var(--font-mono);
}

/* Hover effects */
.decoy-grid .gc:hover {
    background: var(--bg-tertiary);
    cursor: default;
}

/* ===== HIGHLIGHTING CLASSES ===== */

/* GREEN: Exact Target Match */
.decoy-target {
    background: rgba(16, 185, 129, 0.1);
    transition: background 0.2s ease;
}

/* RED: Valid Decoy (wrong payload/alphabet) */
.decoy-decoy {
    background: rgba(239, 68, 68, 0.05);
    transition: background 0.2s ease;
}

/* GRAY: Invalid token (checksum mismatch) */
.decoy-invalid {
    background: rgba(99, 115, 139, 0.05);
    transition: background 0.2s ease;
}

/* ===== PAGER CONTROLS ===== */

.pager-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    flex-wrap: wrap;
}

.pager-btn {
    width: auto !important;
    padding: 4px 10px !important;
    margin: 0 !important;
    background: rgba(59, 130, 246, 0.15) !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    color: #94a3b8 !important;
    font-size: 10px !important;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.pager-btn:hover {
    background: rgba(59, 130, 246, 0.25) !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
}

.pager-btn:active {
    transform: translateY(1px);
}

.pager-info {
    min-width: 180px;
    font-family: monospace;
    font-size: 0.8rem;
    color: #94a3b8;
    text-align: center;
}

.decoy-slider {
    flex-grow: 1;
    max-width: 300px;
    accent-color: #10b981;
}

/* ===== OFFSET HEADER ===== */
.offset-header {
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 4px;
    padding: 2px 4px;
    background: var(--bg-secondary);
    border-radius: 4px;
    word-break: break-all;
}

/* ===== SCROLLBAR STYLING ===== */
.decoy-grid::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.decoy-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.decoy-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.decoy-grid::-webkit-scrollbar-track {
    background: transparent;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */

@media (max-width: 768px) {
    .decoy-grid {
        grid-template-columns: 100px 100px 25px 1fr 1fr 80px;
        font-size: 0.65rem;
        max-height: 35vh;
    }
    
    .decoy-grid .gh,
    .decoy-grid .gc {
        padding: 2px 4px;
    }
}

@media (max-width: 480px) {
    .decoy-grid {
        grid-template-columns: 80px 80px 20px 1fr 1fr 60px;
        gap: 1px;
    }
    
    .pager-controls {
        gap: 4px;
    }
    
    .pager-btn {
        padding: 3px 8px !important;
        font-size: 9px !important;
    }
}

/* ===== ANIMATION ENHANCEMENTS ===== */

@keyframes pulse-green {
    0%, 100% { background: rgba(16, 185, 129, 0.1); }
    50% { background: rgba(16, 185, 129, 0.15); }
}

@keyframes pulse-red {
    0%, 100% { background: rgba(239, 68, 68, 0.05); }
    50% { background: rgba(239, 68, 68, 0.08); }
}

.decoy-target.highlight {
    animation: pulse-green 2s infinite;
}

.decoy-decoy.highlight {
    animation: pulse-red 2s infinite;
}

/* ===== TOKEN DISPLAY ENHANCEMENTS ===== */

.token-cell {
    color: #c084fc; /* Purple for decoys */
    font-family: monospace;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 2px 4px;
    border-radius: 3px;
}

.token-cell:hover {
    background: rgba(124, 58, 237, 0.1);
    transform: scale(1.02);
}

.token-cell.target {
    color: #10b981; /* Green for target */
    font-weight: bold;
}

.token-cell.target:hover {
    background: rgba(16, 185, 129, 0.1);
}

.token-cell.decoy {
    color: #ef4444; /* Red for decoy */
}

.token-cell.decoy:hover {
    background: rgba(239, 68, 68, 0.08);
}

/* Clicked/expanded state */
.token-cell.expanded {
    font-size: 0.9em;
    padding: 3px 4px;
}

.secret-cell {
    color: #cbd5e1;
    font-family: monospace;
    white-space: pre;
    word-break: break-word;
}

.secret-cell.target {
    color: #10b981;
}

.secret-cell.decoy {
    color: #ef4444;
}

/* ===== STATUS INDICATORS ===== */

.status-target {
    color: #10b981;
    font-weight: bold;
}

.status-decoy {
    color: #ef4444;
}

/* ===== DECOY SPACE CONTAINER ===== */

#decoySpace {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.5);
    overflow-x: auto;
    overflow-y: hidden;
    height: 380px;
    position: relative;
    padding: 10px;
}
