/* ==========================================================================
   DATA STRUCTURES & ALGORITHMS VISUALIZER — ACADEMIC DESIGN SYSTEM (v2)
   Fully Optimized for Desktop, Tablet (768px), and Mobile (375px / 390px)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens & Academic Palette
   -------------------------------------------------------------------------- */
:root {
    /* Brand & Primary */
    --primary: #1E3A8A;           /* Deep Academic Navy */
    --primary-light: #2563EB;     /* Royal Action Blue */
    --primary-hover: #1D4ED8;     /* Darker Action Blue */
    --primary-subtle: #EFF6FF;    /* Light Blue Tint */
    --primary-border: #BFDBFE;

    /* Semantic Accents */
    --success: #059669;           /* Emerald */
    --success-hover: #047857;
    --success-subtle: #ECFDF5;
    --success-border: #A7F3D0;

    --danger: #DC2626;            /* Crimson */
    --danger-hover: #B91C1C;
    --danger-subtle: #FEF2F2;
    --danger-border: #FECACA;

    --warning: #D97706;           /* Amber */
    --warning-hover: #B45309;
    --warning-subtle: #FFFBEB;
    --warning-border: #FDE68A;

    --neutral-dark: #0F172A;      /* Slate 900 */
    --text-primary: #1E293B;      /* Slate 800 */
    --text-secondary: #475569;    /* Slate 600 */
    --text-muted: #64748B;        /* Slate 500 */
    --text-light: #94A3B8;        /* Slate 400 */
    --text-white: #FFFFFF;

    /* Backgrounds & Surfaces */
    --bg-page: #F8FAFC;           /* Clean Slate 50 */
    --bg-card: #FFFFFF;           /* Crisp White */
    --bg-subtle: #F1F5F9;         /* Slate 100 */
    --bg-stage: #F8FAFC;          /* Canvas Stage */
    --bg-sidebar: #0F172A;        /* Dark Slate Sidebar */

    /* Borders & Outlines */
    --border: #E2E8F0;            /* Slate 200 */
    --border-strong: #CBD5E1;     /* Slate 300 */
    --border-focus: #2563EB;

    /* Metrics & Touch Targets */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --touch-min: 44px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);

    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;

    --transition: all 0.2s ease-in-out;
}

/* --------------------------------------------------------------------------
   2. Reset & Base Typography
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    min-height: 100%;
    overflow-x: hidden;
    font-family: var(--font-main);
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   3. Shared Academic Navigation & Drawer
   -------------------------------------------------------------------------- */
.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-overlay.active {
    display: block;
    opacity: 1;
}

.side-navbar {
    position: fixed;
    top: 0;
    left: -320px;
    width: min(300px, 85vw);
    height: 100%;
    background-color: var(--bg-sidebar);
    color: var(--text-white);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.side-navbar.active {
    left: 0;
}

.side-navbar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background-color: #0B1120;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.side-navbar-brand-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    flex-shrink: 0;
}

.side-navbar-brand {
    font-size: 1.05rem;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: 0.3px;
    line-height: 1.2;
}

.side-navbar-sub {
    font-size: 0.68rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.side-navbar-close {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.side-navbar-close:hover {
    color: #FFFFFF;
    background-color: rgba(255, 255, 255, 0.1);
}

.side-navbar-scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 10px 24px;
    flex: 1;
}

.side-navbar-category {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 12px 12px 6px;
}

.side-navbar-links {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.side-navbar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    min-height: var(--touch-min);
    color: #CBD5E1;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.side-navbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-svg-icon {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    stroke: currentColor;
}

.side-navbar-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
}

.side-navbar-link.active {
    background-color: var(--primary-light);
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.nav-open-btn {
    position: fixed;
    top: 14px;
    left: 14px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    min-height: 40px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    z-index: 997;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.nav-open-btn:hover {
    background-color: var(--bg-subtle);
    border-color: var(--text-muted);
    box-shadow: var(--shadow-md);
}

/* --------------------------------------------------------------------------
   4. Page Layout & Fluid Academic Typography
   -------------------------------------------------------------------------- */
.page-container, .main-content {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 76px 20px 48px;
    transition: margin-left 0.3s ease;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
    background-color: var(--primary-subtle);
    color: var(--primary-light);
    border: 1px solid var(--primary-border);
}

.badge-tree {
    background-color: var(--success-subtle);
    color: var(--success);
    border-color: var(--success-border);
}

.page-title {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    font-weight: 800;
    color: var(--neutral-dark);
    letter-spacing: -0.5px;
    line-height: 1.25;
    margin-bottom: 8px;
    word-break: break-word;
}

.page-desc {
    font-size: clamp(0.9rem, 2.5vw, 1.05rem);
    color: var(--text-secondary);
    max-width: 780px;
    margin: 0 auto;
    line-height: 1.6;
}

/* --------------------------------------------------------------------------
   5. Concept Brief & Properties Card
   -------------------------------------------------------------------------- */
.concept-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.concept-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--neutral-dark);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.concept-body {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.concept-props {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.prop-item {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
}

.prop-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.prop-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--neutral-dark);
    font-family: var(--font-mono);
    word-break: break-word;
}

/* --------------------------------------------------------------------------
   6. Structured Interactive Controls Panel
   -------------------------------------------------------------------------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

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

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--neutral-dark);
}

.control-section {
    margin-bottom: 20px;
}

.control-section:last-child {
    margin-bottom: 0;
}

.control-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

/* --------------------------------------------------------------------------
   7. Buttons System & Inputs (Touch-Friendly)
   -------------------------------------------------------------------------- */
.btn, button, .cqv-button, .cLL-btn, .control-btn, .operation-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    min-height: var(--touch-min);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    background-color: var(--primary-light);
    color: var(--text-white);
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.25;
    user-select: none;
    touch-action: manipulation;
}

.btn:hover, button:hover, .cqv-button:hover, .cLL-btn:hover, .control-btn:hover, .operation-btn:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-sm);
}

.btn:active, button:active {
    transform: translateY(1px);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
    background-color: var(--bg-subtle);
    border-color: var(--text-muted);
}

.btn-danger {
    background-color: var(--danger);
    color: var(--text-white);
}
.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-success {
    background-color: var(--success);
    color: var(--text-white);
}
.btn-success:hover {
    background-color: var(--success-hover);
}

.btn:disabled, button:disabled, .btn-disabled, .disabled {
    background-color: #F1F5F9 !important;
    color: #94A3B8 !important;
    border: 1px solid #E2E8F0 !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
    transform: none !important;
    box-shadow: none !important;
    pointer-events: none;
}

input[type="text"], input[type="number"], input[type="search"], select {
    padding: 10px 12px;
    min-height: var(--touch-min);
    font-size: 0.95rem;
    font-family: inherit;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

input:focus, select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

input:disabled, select:disabled {
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   8. Visualization Viewport Stages (Responsive)
   -------------------------------------------------------------------------- */
.viz-stage {
    background: var(--bg-stage);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 20px 0;
    min-height: 180px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.viz-stage-label {
    position: absolute;
    top: 10px;
    left: 12px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

/* Stack Stage */
.stack-box {
    width: 100%;
    max-width: 240px;
    height: 260px;
    margin: 10px auto;
    border: 3px solid var(--primary-light);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    background-color: #FFFFFF;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column-reverse;
    padding: 8px;
    gap: 6px;
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.04);
}

.stack-bar {
    width: 100%;
    min-height: 38px;
    background-color: var(--primary-light);
    color: #FFFFFF;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    box-shadow: var(--shadow-sm);
    animation: stackPushSpring 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transition: all 0.25s ease;
    will-change: transform, opacity;
}

.stack-bar-pop {
    animation: stackPopFly 0.28s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
}

.stack-highlight {
    background-color: var(--warning) !important;
    color: #FFFFFF !important;
    animation: pulseHighlight 0.6s ease-in-out;
}

/* Queue Stage */
.queue-display {
    display: flex;
    flex-wrap: nowrap;
    gap: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 16px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    min-height: 110px;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
}

.car {
    min-width: 80px;
    height: 48px;
    background: var(--primary-light);
    color: #FFFFFF;
    border-radius: 10px 10px 4px 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    box-shadow: var(--shadow-md);
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    animation: queueSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
    will-change: transform, opacity;
}

.car:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.car-exit {
    animation: queueSlideOut 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
}

.car::before, .car::after {
    content: "";
    position: absolute;
    bottom: -6px;
    width: 18px;
    height: 18px;
    background: var(--neutral-dark);
    border-radius: 50%;
    border: 2px solid #FFFFFF;
}
.car::before { left: 8px; }
.car::after { right: 8px; }

/* Circular Queue Stage */
.cqv-queue-container {
    position: relative;
    width: min(320px, 90vw);
    height: min(320px, 90vw);
    margin: 20px auto;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    background-color: #FFFFFF;
    box-shadow: var(--shadow-sm);
    overflow: visible;
}

.cqv-queue-slot {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border-strong);
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    border-radius: 50%;
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    background-color: #FFFFFF;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
}

.cqv-queue-slot-filled {
    background-color: var(--primary-light);
    color: #FFFFFF;
    border-color: var(--primary-hover);
    box-shadow: var(--shadow-sm);
}

.cqv-front-last-indicator {
    position: absolute;
    font-weight: 700;
    color: #FFFFFF;
    background-color: var(--neutral-dark);
    border-radius: var(--radius-sm);
    padding: 3px 6px;
    font-size: 0.65rem;
    transform: translate(-50%, -50%);
    box-shadow: var(--shadow-sm);
    z-index: 5;
}

/* Priority Queue Stage */
.queue-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    justify-content: flex-start;
    min-height: 90px;
    padding: 12px 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.queue-item {
    width: 44px;
    height: 44px;
    text-align: center;
    color: #FFFFFF;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 44px;
    border-radius: var(--radius-md);
    background-color: var(--primary-light);
    position: relative;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.25s ease;
    flex-shrink: 0;
}

.queue-item-priority {
    background-color: var(--warning);
}

.priority-label {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--warning);
    font-weight: 800;
}

.priority-highlight {
    background-color: var(--bg-subtle);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    min-height: var(--touch-min);
}

/* Linked List Stages */
.scroll-box {
    width: 100%;
    min-height: 130px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 14px;
    background-color: var(--bg-stage);
    margin: 16px 0;
}

.node-container {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    min-width: max-content;
}

.node-box, .node {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border: 1.5px solid var(--primary-light);
    border-radius: var(--radius-md);
    background-color: #FFFFFF;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    min-width: 76px;
    text-align: center;
    flex-shrink: 0;
    animation: nodeSpringIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    will-change: transform, opacity;
}

.node-box:hover, .node:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.node-highlight {
    animation: pointerSweep 0.8s ease-in-out !important;
    border-color: #2563EB !important;
}

.arrow {
    font-size: 1.3rem;
    color: var(--primary-light);
    font-weight: bold;
    user-select: none;
    flex-shrink: 0;
    animation: fadeIn 0.3s ease;
}

/* AVL Canvas */
.avl-canvas {
    display: block;
    margin: 16px auto;
    background-color: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    max-width: 100%;
    height: auto;
    touch-action: pan-y;
}

/* --------------------------------------------------------------------------
   9. State Monitor, Outputs & Logs
   -------------------------------------------------------------------------- */
.output-box, #output {
    background-color: #0F172A;
    border: 1px solid #1E293B;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: #F8FAFC;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 16px 0;
    text-align: center;
    word-break: break-word;
    width: 100%;
}

.log-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 16px 0;
    text-align: left;
    width: 100%;
}

.log-content {
    background-color: var(--bg-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    max-height: 140px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.alert-banner {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    margin: 14px 0;
    text-align: center;
    display: none;
    border: 1px solid transparent;
    word-break: break-word;
}

.alert-info { background-color: var(--primary-subtle); color: var(--primary-hover); border-color: var(--primary-border); }
.alert-success { background-color: var(--success-subtle); color: var(--success); border-color: var(--success-border); }
.alert-warning { background-color: var(--warning-subtle); color: var(--warning); border-color: var(--warning-border); }
.alert-error { background-color: var(--danger-subtle); color: var(--danger); border-color: var(--danger-border); }

/* --------------------------------------------------------------------------
   10. Educational Reference Cards & Dashboard Grid
   -------------------------------------------------------------------------- */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 14px;
}

.check {
    background: var(--bg-stage);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: left;
}

.check h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--neutral-dark);
    margin-bottom: 4px;
}

.check p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* Dashboard Topic Cards (index.html) */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.topic-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
}

.topic-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.topic-card-icon {
    font-size: 1.75rem;
    margin-bottom: 10px;
}

.topic-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--neutral-dark);
    margin-bottom: 6px;
}

.topic-card-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 14px;
}

.topic-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-light);
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 1100;
    pointer-events: none;
}

.toast-message {
    width: 100%;
    max-width: 400px;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    background-color: var(--neutral-dark);
    color: #FFFFFF;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success { background-color: var(--success); }
.toast-error { background-color: var(--danger); }
.toast-warning { background-color: var(--warning); }
.toast-info { background-color: var(--primary-light); }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes highlight {
    0% { background-color: #FEF08A; }
    100% { background-color: transparent; }
}

.highlight {
    animation: highlight 2.5s ease-out;
}

/* --------------------------------------------------------------------------
   11. Granular Responsive Breakpoints (375px, 390px, 640px, 768px, 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .page-container, .main-content {
        padding: 72px 16px 36px;
    }

    .card {
        padding: 18px 14px;
    }

    .concept-card {
        padding: 16px;
    }

    .controls-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .page-container, .main-content {
        padding: 70px 12px 32px;
    }

    .controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .controls-row input, 
    .controls-row select, 
    .controls-row button, 
    .controls-row .btn, 
    .controls-row .priority-highlight {
        width: 100% !important;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .concept-props {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 390px) {
    .page-container, .main-content {
        padding: 68px 10px 28px;
    }

    .page-title {
        font-size: 1.35rem;
    }

    .card {
        padding: 14px 10px;
    }

    .stack-box {
        max-width: 100%;
        height: 220px;
    }

    .cqv-queue-container {
        width: 270px;
        height: 270px;
    }
}

/* --------------------------------------------------------------------------
   12. GPU-Accelerated Keyframe Animations & Micro-Interactions
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes stackPushSpring {
    0% {
        transform: translateY(-40px) scale(0.85);
        opacity: 0;
    }
    60% {
        transform: translateY(6px) scale(1.04);
        opacity: 1;
    }
    80% {
        transform: translateY(-2px) scale(0.99);
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes stackPopFly {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    35% {
        transform: translateY(-10px) scale(1.06);
        background-color: var(--danger);
        color: #FFFFFF;
    }
    100% {
        transform: translateY(-60px) scale(0.7);
        opacity: 0;
    }
}

@keyframes queueSlideIn {
    0% {
        transform: translateX(50px) scale(0.85);
        opacity: 0;
    }
    70% {
        transform: translateX(-6px) scale(1.03);
        opacity: 1;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes queueSlideOut {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(-50px) scale(0.8);
        opacity: 0;
    }
}

@keyframes nodeSpringIn {
    0% {
        transform: scale(0.7) translateY(20px);
        opacity: 0;
    }
    65% {
        transform: scale(1.08) translateY(-4px);
        opacity: 1;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes nodeFadeOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.6) translateY(-20px);
        opacity: 0;
    }
}

@keyframes pointerSweep {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
        border-color: var(--primary-light);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(37, 99, 235, 0.25);
        border-color: #2563EB;
        transform: scale(1.07);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
        transform: scale(1);
    }
}

@keyframes ringSlotPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.22);
        box-shadow: 0 0 16px rgba(37, 99, 235, 0.6);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes pulseHighlight {
    0% {
        background-color: var(--warning);
        transform: scale(1);
    }
    50% {
        background-color: #F59E0B;
        transform: scale(1.08);
        box-shadow: 0 0 14px rgba(245, 158, 11, 0.6);
    }
    100% {
        background-color: var(--warning);
        transform: scale(1);
    }
}

