﻿/* ==========================================================================
   MAGE 20TH: SECRET LIBRARY - VISUAL CORE
   Theme: Paradox Dark Strategy
   Refactored Version: 2.3 (Clean Code Edition)
   Architect: Refactor Bey
   ========================================================================== */

/* ==========================================================================
   1. THEME VARIABLES & ROOT CONFIGURATION
   ========================================================================== */
:root {
    /* --- Colors: Backgrounds (Paradox Dark) --- */
    --bg-body: #121212;
    --bg-panel: #1c1c1e;
    --bg-card: #252526;
    --bg-input: #0e0e0e;
    /* --- Colors: Borders & Structure --- */
    --border: #333333;
    --border-hover: #555555;
    --radius: 3px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    /* --- Colors: Mage Spheres & Feedback --- */
    --primary: #9d70ff;
    --primary-hover: #b794f6;
    --primary-dim: rgba(157, 112, 255, 0.1);
    --primary-glow: 0 0 15px rgba(157, 112, 255, 0.2);
    --accent: #29b6f6; /* Cyan - Mind/Spirit */
    --success: #66bb6a; /* Green - Life/Matter */
    --warning: #ffa726; /* Orange - Forces/Time */
    --danger: #ef5350; /* Red - Entropy/Prime */
    --danger-glow: 0 0 15px rgba(239, 83, 80, 0.3);
    /* --- Typography --- */
    --text-main: #f0f0f0;
    --text-muted: #a0a0a0;
    --font-main: 'Inter', sans-serif;
    --font-header: 'Montserrat', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    /* --- Layout Dimensions --- */
    --header-height: 60px;
    --ease: cubic-bezier(0.2, 0, 0, 1);
    /* --- Z-Index Layer Map --- */
    --z-header: 50;
    --z-footer: 100;
    --z-modal: 10001;
    --z-error: 11000;
    --z-tooltip: 12000;
}

/* ==========================================================================
   2. GLOBAL RESET & BASE STYLES
   ========================================================================== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-body);
    background-image: linear-gradient(180deg, #161616 0%, #0a0a0a 100%);
    color: var(--text-main);
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    letter-spacing: 0.01em;
}

/* ==========================================================================
   3. HERO HEADER COMPONENT
   ========================================================================== */
.hero-header {
    background: #181818;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 20px;
    height: var(--header-height);
    z-index: var(--z-header);
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.brand-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    line-height: 1;
}

.brand-title {
    font-family: var(--font-header);
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    color: #fff;
    text-transform: uppercase;
    margin: 0;
    white-space: nowrap;
}

.brand-subtitle {
    display: block;
    font-family: var(--font-header);
    font-size: 0.6rem;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-top: 4px;
}

/* --- Search Bar --- */
.search-container {
    width: 100vw;
    max-width: 400px;
    position: relative;
}

.search-bar {
    width: 100%;
    background: #0e0e0e;
    border: 1px solid var(--border);
    padding: 8px 15px 8px 35px;
    border-radius: var(--radius);
    color: #fff;
    font-family: var(--font-main);
    font-size: 0.85rem;
    height: 36px;
    outline: none;
    transition: border-color 0.2s;
}

    .search-bar:focus {
        border-color: var(--primary);
        background: #000;
    }

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    pointer-events: none;
    font-size: 0.8rem;
}

/* ==========================================================================
   4. NAVIGATION SYSTEM (Tabs)
   ========================================================================== */
.nav-tabs {
    display: flex;
    background: #1c1c1e;
    border-bottom: 1px solid var(--border);
    padding: 0 10px;
    flex-shrink: 0;
    overflow-x: auto;
}

.nav-btn {
    flex: 1;
    min-width: 80px;
    padding: 16px 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-header);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

    .nav-btn:hover {
        color: #fff;
        background: rgba(255, 255, 255, 0.03);
    }

    .nav-btn.active {
        color: #fff;
    }

        .nav-btn.active::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 3px;
            background: var(--primary);
        }

/* ==========================================================================
   5. LAYOUT & CONTENT AREA
   ========================================================================== */
.content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 16px;
    background: var(--bg-body);
    position: relative;
}

.tab-page {
    display: none;
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 80px;
    animation: fadeIn 0.3s var(--ease);
}

    .tab-page.active {
        display: block;
    }

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
    }
}

/* --- Sub Navigation (Tools Tab) --- */
.sub-nav {
    display: flex;
    gap: 1px;
    margin-bottom: 24px;
    padding: 2px;
    background: var(--border);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.sub-nav-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: var(--bg-panel);
    color: var(--text-muted);
    font-family: var(--font-header);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
}

    .sub-nav-btn:hover {
        color: #fff;
        background: #2d2d30;
    }

    .sub-nav-btn.active {
        background: var(--primary);
        color: #fff;
    }

.sub-tab-content {
    display: none;
}

    .sub-tab-content.active {
        display: block;
        animation: fadeIn 0.2s;
    }

/* ==========================================================================
   6. CARDS, GRIDS & LISTS
   ========================================================================== */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: transform 0.2s, border-color 0.2s;
    box-shadow: var(--shadow-sm);
}

    .card:hover {
        border-color: var(--primary);
        transform: translateY(-2px);
    }

.card-title {
    font-family: var(--font-header);
    font-weight: 800;
    color: #fff;
    font-size: 0.95rem;
    margin-bottom: 12px;
    display: block;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

    .card-list li {
        margin-bottom: 8px;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .card-list span {
        color: var(--primary);
        font-weight: 700;
        background: rgba(255, 255, 255, 0.05);
        padding: 2px 6px;
        border-radius: 2px;
        font-size: 0.8em;
        min-width: 24px;
        text-align: center;
        font-family: var(--font-mono);
    }

/* ==========================================================================
   7. ACCORDION & DATA TABLES
   ========================================================================== */
.accordion {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.acc-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    transition: border-color 0.2s;
}

.acc-header {
    padding: 16px;
    background: var(--bg-panel);
    font-family: var(--font-header);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    color: #fff;
}

    .acc-header:hover {
        background: #2a2a2d;
    }

.acc-item.open {
    border-color: var(--primary);
}

    .acc-item.open .acc-header {
        background: #252526;
        color: var(--primary);
    }

.acc-content {
    display: none;
    border-top: 1px solid var(--border);
    background: #181818;
}

.acc-item.open .acc-content {
    display: block;
}

/* --- Data Rows (Rote/Merit Lists) --- */
.data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

    .data-row:last-child {
        border-bottom: none;
    }

.data-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    margin-right: 15px;
}

.data-name {
    font-weight: 600;
    color: #fff;
    display: block;
    margin-bottom: 2px;
}

.data-meta {
    font-family: var(--font-mono);
    color: var(--primary);
    font-size: 0.85rem;
    text-align: right;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 2px;
}

.data-desc {
    display: block;
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
}

.data-flavor {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.3;
    margin-top: 2px;
}

/* --- Standard Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-header);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: top;
}

/* --- Utility: Text Colors & Tags --- */
.hl-red {
    color: var(--danger);
    font-weight: bold;
}

.hl-green {
    color: var(--success);
    font-weight: bold;
}

.hl-yellow {
    color: var(--warning);
    font-weight: bold;
}

.hl-blue {
    color: var(--accent);
    font-weight: bold;
}

.hl-purple {
    color: var(--primary);
    font-weight: bold;
}

.hl-orange {
    color: #ff9800;
    font-weight: bold;
}

.tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-right: 5px;
}

.tag-blue {
    background: rgba(41, 182, 246, 0.2);
    color: var(--accent);
}

.tag-green {
    background: rgba(102, 187, 106, 0.2);
    color: var(--success);
}

.tag-red {
    background: rgba(239, 83, 80, 0.2);
    color: var(--danger);
}

.tag-purple {
    background: rgba(157, 112, 255, 0.2);
    color: var(--primary);
}

.clean-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

    .clean-list li {
        margin-bottom: 10px;
        border-bottom: 1px dashed var(--border);
        padding-bottom: 10px;
    }

        .clean-list li:last-child {
            border-bottom: none;
        }

/* ==========================================================================
   8. RITUALMATIC DASHBOARD (Logic Core UI)
   ========================================================================== */
.rit-dashboard-v3 {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* --- 8.1 Toolbar & Header --- */
.rit-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-panel);
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.rit-title {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.5px;
}

/* Mode Switch */
.mode-switch {
    display: flex;
    background: var(--bg-input);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.mode-opt {
    flex: 1;
    text-align: center;
    padding: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-muted);
    transition: all 0.2s;
}

    .mode-opt.active {
        background: var(--bg-card);
        color: #fff;
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--border);
    }

/* --- 8.2 Input Elements --- */
.stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 0.5fr;
    gap: 12px;
}

.rit-select, .btn-square, .counter {
    height: 42px !important;
    display: flex;
    align-items: center;
}

select, .rit-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: #fff;
    padding: 0 16px;
    border-radius: 10px;
    outline: none;
    font-family: var(--font-header);
    font-weight: 600;
    appearance: none;
    /* Custom SVG Arrow */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

    select:focus {
        border-color: var(--primary);
    }

/* Counter Component */
.counter {
    width: 100%;
    justify-content: space-between;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.cnt-display {
    font-size: 1.1rem;
    font-weight: 700;
    flex: 1;
    text-align: center;
    border: none;
    color: #fff;
}

.btn-cnt {
    width: 40px;
    height: 100%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .btn-cnt:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

/* Square Checkbox Button */
.btn-square {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    justify-content: center;
    transition: all 0.2s ease;
}

    .btn-square:hover {
        border-color: #fff;
        background: #222;
    }

    .btn-square.checked {
        background: var(--primary);
        border-color: var(--primary);
    }

.btn-square-inner {
    width: 12px;
    height: 12px;
    border: 2px solid #666;
    border-radius: 2px;
    transition: 0.2s;
}

.btn-square.checked .btn-square-inner {
    background: #fff;
    border-color: #fff;
    transform: scale(1.2);
}

/* --- 8.3 Work Area Panels --- */
.work-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.work-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.section-title {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 4px;
    display: block;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rit-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    cursor: help;
    letter-spacing: 0.5px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.grid-3-tool {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* Tool Toggle Buttons */
.btn-tool {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 10px 4px;
    border-radius: 12px;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .btn-tool:hover {
        border-color: var(--text-muted);
        color: #fff;
    }

    .btn-tool.active {
        background: var(--primary-dim);
        border-color: var(--primary);
        color: #fff;
    }

    .btn-tool.neg.active {
        background: rgba(239, 68, 68, 0.15);
        border-color: var(--danger);
        color: var(--danger);
    }

/* Tool Badge (Quintessence Counter) */
.tool-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    margin-left: 6px;
    padding: 1px 5px;
    border-radius: 4px;
    min-width: 14px;
    height: 14px;
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-tool.active .tool-badge {
    background: #fff;
    color: var(--primary);
    border-color: #fff;
}

/* --- 8.4 Sliders & Mini Selectors --- */
.slider-wrapper {
    background: var(--bg-input);
    padding: 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.slider-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.7rem;
    font-weight: 700;
    align-items: center;
}

.slider-val {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    font-family: var(--font-mono);
    text-align: center;
    margin-bottom: 5px;
}

.slider-cost {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--success);
}

.mini-sel {
    appearance: none;
    -webkit-appearance: none;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    padding: 6px 28px 6px 10px;
    width: auto;
    min-width: 120px;
    transition: all 0.2s ease;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239d70ff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
}

    .mini-sel:hover {
        background-color: rgba(139, 92, 246, 0.15);
        border-color: var(--primary);
        color: #fff;
        box-shadow: 0 0 10px rgba(139, 92, 246, 0.1);
    }

    .mini-sel:focus {
        outline: none;
        border-color: var(--primary-hover);
        background-color: #000;
    }

    .mini-sel option {
        background-color: #1c1c1e;
        color: #fff;
        padding: 10px;
    }

input[type=range] {
    width: 100%;
    cursor: pointer;
    margin: 0;
    accent-color: var(--primary);
    height: 6px;
    border-radius: 3px;
}

/* --- 8.5 Result Bar & Actions --- */
.result-bar {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    background: #000;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    align-items: stretch;
}

.result-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px;
}

.res-lbl {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

.res-val {
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
    background: none;
    border: none;
    text-align: center;
    width: 100%;
    font-family: var(--font-header);
}

.val-diff {
    color: #c4b5fd;
}

.val-goal {
    color: #6ee7b7;
}

.modified {
    color: var(--warning) !important;
    text-decoration: underline;
    text-decoration-style: dotted;
}

/* Cast Button Variants */
.btn-cast-compact {
    width: 100%;
    height: 100%;
    min-width: 120px;
    padding: 0 20px;
    font-size: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    font-family: var(--font-header);
}

    .btn-cast-compact:hover {
        filter: brightness(1.1);
    }

.style-inst {
    background: #e65100;
}

.style-rit {
    background: #673ab7;
}

.style-pause {
    background: #f57f17;
    animation: pulse 2s infinite;
}

/* Safety Button */
.btn-safety {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    padding: 8px;
    border-radius: var(--radius);
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.3);
    color: #f97316;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.65rem;
    text-transform: uppercase;
    transition: 0.2s;
    margin-top: 8px;
    font-family: var(--font-header);
}

    .btn-safety.active {
        background: #f97316;
        color: #000;
        border-color: #f97316;
    }

/* ==========================================================================
   9. LOGS & GENERATORS
   ========================================================================== */
#log-container {
    display: none;
    background: #000;
    padding: 20px;
    border-radius: var(--radius);
    margin-top: 24px;
    border: 1px solid var(--border);
}

.log-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-muted);
    margin-bottom: 16px;
    text-transform: uppercase;
    font-family: var(--font-header);
}

.log-scroll {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.entry {
    background: #111;
    padding: 16px;
    border-radius: 2px;
    border-left: 4px solid #444;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: fadeIn 0.3s ease-out;
}

    .entry.success {
        border-color: var(--success);
        background: rgba(102, 187, 106, 0.05);
    }

    .entry.fail {
        border-color: var(--warning);
        background: rgba(255, 167, 38, 0.05);
    }

    .entry.botch {
        border-color: var(--danger);
        background: rgba(239, 83, 80, 0.05);
    }

.prog-bg {
    height: 10px;
    background: var(--bg-input);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

.prog-fill {
    height: 100%;
    background: var(--success);
    width: 0%;
    transition: width 0.3s;
}

/* Generators Section */
.gen-btn {
    width: 100%;
    padding: 16px;
    background: #252526;
    border: 1px solid var(--border);
    color: var(--primary);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    margin-bottom: 5px;
    transition: 0.2s;
    font-family: var(--font-header);
    letter-spacing: 1px;
}

    .gen-btn:hover {
        background: var(--primary);
        color: #fff;
        border-color: var(--primary);
        box-shadow: var(--primary-glow);
    }

.gen-res {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    min-height: 24px;
    padding: 12px;
    margin-bottom: 15px;
    font-family: var(--font-mono);
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid var(--accent);
    border-radius: 0 2px 2px 0;
    text-align: left;
    display: flex;
    align-items: center;
}

#res-flaw {
    border-left-color: var(--danger);
    color: #ef9a9a;
}

.gen-input {
    width: 70px;
    text-align: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: #fff;
    border-radius: var(--radius);
    padding: 12px;
    font-weight: 700;
    font-family: var(--font-mono);
    outline: none;
    transition: all 0.2s;
}

    .gen-input:focus {
        border-color: var(--primary);
    }

/* ==========================================================================
   10. MODALS, TOOLTIPS & OVERLAYS
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: var(--z-modal);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(5px);
}

#error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: var(--z-error);
    display: none !important;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s;
}

.modal-box {
    background: #1c1c24;
    border: 1px solid var(--danger);
    border-radius: 4px;
    padding: 32px;
    max-width: 350px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--primary);
    border-radius: 4px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.2);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.modal-title {
    color: var(--danger);
    font-weight: 900;
    font-size: 1.4rem;
    margin-bottom: 12px;
    text-transform: uppercase;
    font-family: var(--font-header);
}

.modal-text {
    color: #ccc;
    font-size: 1rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-btn {
    background: var(--danger);
    border: none;
    color: #fff;
    padding: 14px 24px;
    border-radius: 4px;
    font-weight: 800;
    cursor: pointer;
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: var(--font-header);
}

    .modal-btn:hover {
        background: #d32f2f;
    }

.close-btn {
    color: var(--text-muted);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

    .close-btn:hover {
        color: var(--danger);
    }

/* Tooltip */
#tooltip {
    display: none;
    position: fixed;
    background: rgba(18, 18, 18, 0.95);
    border: 1px solid var(--primary);
    padding: 12px;
    border-radius: 4px;
    z-index: var(--z-tooltip);
    pointer-events: none;
    color: #fff;
    font-size: 0.8rem;
    max-width: 280px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.tt-title {
    display: block;
    font-family: var(--font-header);
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.tt-desc {
    display: block;
    margin-bottom: 8px;
    line-height: 1.4;
    color: #ddd;
}

.tt-ref {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--font-mono);
    border-top: 1px dashed #333;
    padding-top: 4px;
}

/* ==========================================================================
   11. SITE FOOTER
   ========================================================================== */
.site-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    padding: 5px 20px;
    font-size: 0.6rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: #111;
    z-index: var(--z-footer);
    flex-wrap: wrap;
}

.footer-legal-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 300px;
}

.darkpack-logo {
    width: 30px;
    height: auto;
    opacity: 0.6;
}

    .darkpack-logo:hover {
        opacity: 1;
    }

.legal-text {
    font-size: 0.55rem;
    color: #666;
    margin: 0;
    line-height: 1.2;
    text-align: left;
    font-family: var(--font-main);
}

    .legal-text a {
        color: var(--text-muted);
        text-decoration: underline;
    }

.unofficial-badge {
    display: inline-block;
    font-size: 0.55rem;
    color: var(--warning);
    font-weight: 700;
    margin-right: 5px;
    white-space: nowrap;
    text-transform: uppercase;
}

.btn-report {
    margin-left: 15px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    height: 28px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    flex-shrink: 0;
}

    .btn-report:hover {
        border-color: var(--danger);
        color: var(--danger);
        background: rgba(239, 68, 68, 0.1);
    }

/* ==========================================================================
   12. RESPONSIVE DESIGN (Media Queries)
   ========================================================================== */
@media (max-width: 768px) {
    .site-footer {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }

    .footer-legal-container {
        flex-direction: column;
        text-align: center;
    }

    .legal-text {
        text-align: center;
    }

    .stat-row {
        grid-template-columns: 1fr 1fr;
    }

    .work-area {
        grid-template-columns: 1fr;
    }

    .result-bar {
        grid-template-columns: 1fr 1fr;
    }

    .btn-cast-compact {
        grid-column: span 2;
        height: 50px;
        margin-top: 5px;
    }
}
