/* ========================================
   Codeforces IDE - Web Edition
   Premium Dark Theme Styles
   ======================================== */

/* CSS Variables - Dark Theme (Default) */
:root {
    /* Colors */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-elevated: #30363d;

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --accent-primary: #58a6ff;
    --accent-success: #3fb950;
    --accent-warning: #d29922;
    --accent-error: #f85149;

    --border-color: #30363d;
    --border-focus: #58a6ff;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-accent: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);

    /* Spacing */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Fonts */
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #eaeef2;
    --bg-elevated: #d0d7de;

    --text-primary: #1f2328;
    --text-secondary: #57606a;
    --text-muted: #8b949e;

    --accent-primary: #0969da;
    --accent-success: #1a7f37;
    --accent-warning: #9a6700;
    --accent-error: #cf222e;

    --border-color: #d0d7de;
    --border-focus: #0969da;

    --shadow-sm: 0 1px 3px rgba(31, 35, 40, 0.12);
    --shadow-md: 0 4px 6px rgba(31, 35, 40, 0.16);
    --shadow-lg: 0 10px 25px rgba(31, 35, 40, 0.2);
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* ========================================
   Loading Screen
   ======================================== */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-content {
    text-align: center;
}

.loading-logo {
    font-size: 64px;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.loading-content h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.loading-bar {
    width: 280px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto 12px;
}

.loading-progress {
    height: 100%;
    width: 30%;
    background: var(--gradient-success);
    border-radius: 3px;
    transition: width 0.3s ease;
    animation: loading-anim 1.5s ease-in-out infinite;
}

@keyframes loading-anim {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(400%);
    }
}

.loading-status {
    font-size: 13px;
    color: var(--text-muted);
}

/* ========================================
   App Container
   ======================================== */
.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.app.hidden {
    display: none;
}

/* ========================================
   Header
   ======================================== */
.header {
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 24px;
}

.app-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    background: var(--gradient-primary);
    color: white;
    border-radius: 10px;
    text-transform: uppercase;
}

.header-center {
    display: flex;
    align-items: center;
}

/* Runtime Status Badge */
.runtime-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.runtime-status.cooking {
    border-color: rgba(255, 193, 7, 0.3);
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.runtime-status.ready {
    border-color: rgba(46, 204, 113, 0.3);
    background: rgba(46, 204, 113, 0.1);
    color: #2ecc71;
}

.runtime-status.error {
    border-color: rgba(231, 76, 60, 0.3);
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 5px currentColor;
}

.cooking .status-dot {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: scale(0.9);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }

    100% {
        opacity: 0.5;
        transform: scale(0.9);
    }
}

.timer {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-tertiary);
    padding: 6px 14px;
    border-radius: var(--radius-md);
}

.timer-icon {
    font-size: 16px;
}

.timer-display {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 500;
    color: var(--accent-success);
    min-width: 70px;
}

.timer-btn {
    width: 28px;
    height: 28px;
    background: var(--bg-elevated);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.timer-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
}

.header-btn.primary {
    background: var(--accent-success);
    border-color: var(--accent-success);
    color: white;
}

.header-btn.primary:hover {
    background: #2ea043;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.header-btn.running {
    background: var(--accent-warning);
    border-color: var(--accent-warning);
    animation: running-pulse 1s ease-in-out infinite;
}

@keyframes running-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* ========================================
   Main Content
   ======================================== */
/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Resizer */
.resizer {
    width: 6px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    border-left: 1px solid var(--border-color);
    cursor: col-resize;
    transition: background 0.2s;
    z-index: 5;
    flex-shrink: 0;
}

.resizer:hover,
.resizer.resizing {
    background: var(--accent-primary);
}

/* ========================================
   Problem Statement Panel (Leftmost)
   ======================================== */
.problem-panel {
    width: 280px;
    min-width: 200px;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    transition: width 0.2s ease;
}

.problem-panel.collapsed {
    width: 40px;
    min-width: 40px;
}

.problem-panel.collapsed .problem-content {
    display: none;
}

.problem-panel.collapsed .section-header span {
    display: none;
}

.problem-panel .section-header {
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.problem-actions {
    display: flex;
    gap: 4px;
}

.problem-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#problemStatement {
    flex: 1;
    width: 100%;
    padding: 10px;
    background: var(--bg-primary);
    border: none;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 12px;
    line-height: 1.5;
    resize: none;
    outline: none;
}

#problemStatement::placeholder {
    color: var(--text-muted);
}

.problem-resizer {
    width: 4px;
    background: var(--bg-secondary);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.2s;
}

.problem-resizer:hover {
    background: var(--accent-primary);
}

/* Left Panel: Editor + IO (adjusted) */
.left-panel {
    flex: 1;
    /* Take remaining space */
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

.editor-section {
    flex: 1;
    /* Take all available space */
    display: flex;
    flex-direction: column;
    min-height: 300px;
    /* Ensure editor is always substantial */
    border-bottom: 1px solid var(--border-color);
}

.editor-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* CodeMirror Overrides */
.CodeMirror {
    height: 100% !important;
    font-family: var(--font-mono) !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

.CodeMirror-gutters {
    background: var(--bg-secondary) !important;
    border-right: 1px solid var(--border-color) !important;
    white-space: nowrap;
    width: 25px !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    z-index: 10 !important;
}

.CodeMirror-lines {
    padding-left: 35px !important;
}

/* Ensure scrollbar doesn't overlap gutter */
.CodeMirror-sizer {
    margin-left: 35px !important;
}

.CodeMirror-linenumber {
    color: var(--text-muted) !important;
    padding: 0 4px !important;
    min-width: 18px !important;
    text-align: right;
}

.CodeMirror-cursor {
    border-left: 2px solid var(--accent-primary) !important;
}

.CodeMirror-activeline-background {
    background: rgba(88, 166, 255, 0.1) !important;
}

.CodeMirror-selected {
    background: rgba(88, 166, 255, 0.2) !important;
}

/* IO Section (Bottom Left) */
.io-section {
    flex: 0 0 220px;
    /* Fixed height for IO */
    display: flex;
    min-height: 150px;
    max-height: 50%;
    /* Prevent taking over */
}

.io-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    min-width: 0;
}

.io-box:last-child {
    border-right: none;
}

.section-header {
    height: 32px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.io-textarea,
.output-area {
    flex: 1;
    width: 100%;
    height: 100%;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 13px;
    border: none;
    resize: none;
    outline: none;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.output-area {
    overflow-y: auto;
    white-space: pre-wrap;
}

/* Right Panel Grid Layout - 2 Columns */
.right-panel-grid {
    display: flex;
    flex: 1;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    min-width: 0;
}

.panel-column {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    min-width: 0;
    border-right: 1px solid var(--border-color);
}

.panel-column:last-child {
    border-right: none;
}

/* Variable Column fixed width */
.variables-column {
    width: 250px;
    flex-shrink: 0;
}

/* Visualizer Column takes remaining space */
.visualizer-column {
    flex: 1;
    min-width: 0;
    /* Removed max-width */
}

/* Fullscreen Mode for Visualizer */
.visualizer-column.fullscreen {
    position: fixed;
    top: 50px;
    /* Below header */
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: var(--bg-secondary);
    width: 100% !important;
    height: calc(100vh - 50px) !important;
}

/* Header actions alignment */
.header-actions {
    display: flex;
    gap: 4px;
}

.visualizer-panel {
    flex: 1;
    padding: 6px;
    overflow-y: auto;
}

.iteration-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 6px;
    margin-bottom: 8px;
    border-left: 3px solid var(--accent-primary);
}

.iteration-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.iteration-name {
    font-weight: 600;
    font-size: 11px;
    color: var(--accent-primary);
}

.iteration-table {
    width: 100%;
    font-size: 9px;
    font-family: var(--font-mono);
    border-collapse: collapse;
}

.iteration-table th {
    background: var(--bg-elevated);
    padding: 2px 4px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
}

.iteration-table td {
    padding: 2px 4px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.iteration-table tr:last-child td {
    border-bottom: none;
    background: var(--bg-elevated);
    font-weight: 600;
}

.panel-section {
    display: flex;
    flex-direction: column;
}

.testcases-section {
    flex: 1;
    overflow: hidden;
}

/* Test cases in column */
.testcases-column .testcases-panel {
    flex: 1;
    padding: 6px;
    overflow-y: auto;
}

/* Compact Test Case Styling */
.testcase-card {
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 4px 6px;
    border-left: 2px solid var(--text-muted);
    margin-bottom: 4px;
}

.testcase-card.pass {
    border-left-color: var(--accent-success);
}

.testcase-card.fail {
    border-left-color: var(--accent-error);
}

.testcase-header {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}

.testcase-num {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}

.testcase-status {
    font-size: 10px;
    margin-left: auto;
}

.testcase-card.pass .testcase-status {
    color: var(--accent-success);
}

.testcase-card.fail .testcase-status {
    color: var(--accent-error);
}

.delete-btn {
    font-size: 10px;
    padding: 0 4px;
    opacity: 0.5;
}

.testcase-card:hover .delete-btn {
    opacity: 1;
}

.testcase-io {
    display: flex;
    gap: 4px;
}

.testcase-io>div {
    flex: 1;
}

.tc-input {
    width: 100%;
    height: 24px;
    font-size: 9px;
    font-family: var(--font-mono);
    background: var(--bg-primary);
    border: none;
    border-radius: 2px;
    color: var(--text-primary);
    padding: 2px 4px;
    resize: none;
}

.tc-actual {
    font-size: 9px;
    font-family: var(--font-mono);
    margin-top: 2px;
    padding: 2px 4px;
    border-radius: 2px;
    background: var(--bg-primary);
}

.tc-actual.pass {
    color: var(--accent-success);
}

.tc-actual.fail {
    color: var(--accent-error);
}

.action-btn {
    flex: 1;
    padding: 4px 8px;
    font-size: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--bg-elevated);
}

.action-btn.primary {
    background: var(--accent-success);
    border-color: var(--accent-success);
    color: white;
}

.action-btn.primary:hover {
    background: #2ea043;
}

.variables-panel {
    flex: 1;
    padding: 6px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Compact Variable Item */
.var-item {
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.var-item:hover {
    border-color: var(--border-color);
    background: var(--bg-elevated);
}

.var-header {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 6px;
}

.var-icon {
    font-size: 10px;
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-weight: bold;
    opacity: 0.8;
    width: 16px;
    text-align: center;
}

.var-name {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.var-spacer {
    display: none;
}

/* Compact value display */
.var-value {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent-success);
    background: var(--bg-primary);
    padding: 4px 6px;
    margin-top: 4px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 60px;
    overflow-y: auto;
}

.var-value:hover {
    white-space: pre-wrap;
    max-height: 150px;
}

.var-type {
    font-size: 10px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.var-actions {
    display: flex;
    gap: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.var-item:hover .var-actions {
    opacity: 1;
}

/* Loop variable special styling */
.var-loop {
    border-left: 3px solid var(--accent-warning);
}

.loop-info {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent-warning);
    padding: 2px 4px;
    background: rgba(255, 193, 7, 0.1);
    border-radius: 3px;
    margin-top: 2px;
}

/* Function special styling */
.var-function {
    border-left: 3px solid var(--accent-primary);
}

.func-return {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent-primary);
    padding: 2px 4px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 3px;
    margin-top: 2px;
}

.var-action {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 2px;
}

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

/* ========================================
   Right Panel Tabs
   ======================================== */
.right-panel-tabs {
    display: flex;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    background: var(--bg-secondary);
}

.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

/* Test Cases Panel */
.testcases-panel {
    flex: 1;
    padding: 6px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.testcase-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    border-left: 3px solid var(--text-muted);
}

.testcase-card.pass {
    border-left-color: var(--accent-success);
}

.testcase-card.fail {
    border-left-color: var(--accent-error);
}

.testcase-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.testcase-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
}

.testcase-status {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--bg-elevated);
}

.testcase-card.pass .testcase-status {
    background: rgba(63, 185, 80, 0.2);
    color: var(--accent-success);
}

.testcase-card.fail .testcase-status {
    background: rgba(248, 81, 73, 0.2);
    color: var(--accent-error);
}

.testcase-io {
    display: flex;
    gap: 6px;
    font-size: 10px;
}

.testcase-io>div {
    flex: 1;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
    max-height: 40px;
    overflow: auto;
}

.testcase-actions {
    padding: 6px;
    display: flex;
    gap: 6px;
    border-top: 1px solid var(--border-color);
}

.testcase-actions .header-btn {
    flex: 1;
    justify-content: center;
    font-size: 11px;
    padding: 6px;
}

/* Complexity Panel */
.complexity-panel {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
}

.complexity-result {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 12px;
}

.complexity-badge {
    display: inline-block;
    font-size: 18px;
    font-weight: bold;
    font-family: var(--font-mono);
    color: var(--accent-primary);
    padding: 8px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
}

.complexity-details {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.complexity-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color);
}

.complexity-item:last-child {
    border-bottom: none;
}

/* Theme Transition */
body,
.app,
.header,
.main-content,
.left-panel,
.right-panel,
.editor-section,
.io-section,
.modal-content {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ========================================
   Modal
   ======================================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.snippets-modal {
    width: 700px;
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--accent-error);
    color: white;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 16px;
}

.modal-hint kbd {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.snippets-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.snippet-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.snippet-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.snippet-keyword {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.snippet-name {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Snippet Card Actions */
.snippet-card {
    position: relative;
}

.snippet-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    gap: 4px;
}

.snippet-card:hover .snippet-actions {
    display: flex;
}

.snippet-action-btn {
    width: 24px;
    height: 24px;
    background: var(--bg-elevated);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.snippet-action-btn:hover {
    color: white;
}

.snippet-action-btn.edit:hover {
    background: var(--accent-primary);
}

.snippet-action-btn.delete:hover {
    background: var(--accent-error);
}

/* Snippet Editor Modal */
.snippet-editor-modal {
    width: 600px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent-primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 900px) {
    .right-panel {
        width: 320px;
    }

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

@media (max-width: 700px) {
    .main-content {
        flex-direction: column;
    }

    .editor-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .right-panel {
        width: 100%;
        flex-direction: row;
    }

    .panel-section {
        flex: 1;
        border-right: 1px solid var(--border-color);
        border-bottom: none;
    }

    .panel-section:last-child {
        border-right: none;
    }

    .header-btn span:first-child {
        display: none;
    }
}

/* Quick Actions FAB */
.quick-actions {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.fab-main {
    width: 42px;
    /* Much smaller */
    height: 42px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab-main:hover {
    transform: scale(1.1);
    background: var(--accent-hover);
}

.fab-main.active {
    transform: rotate(45deg);
    background: var(--accent-danger);
}

.fab-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 5px;
    transform-origin: bottom right;
    transition: all 0.3s ease;
}

.fab-menu.hidden {
    opacity: 0;
    transform: scale(0.5) translateY(20px);
    pointer-events: none;
}

.fab-item {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
    white-space: nowrap;
}

.fab-item:hover {
    background: var(--bg-elevated);
    transform: translateX(-5px);
}

.fab-icon {
    font-weight: bold;
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

/* Quick Toolbar (in Variables Panel) */
.quick-toolbar {
    padding: 10px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

/* Inline Quick Actions (in Panel Header) */
.panel-header .quick-actions {
    position: static;
    flex-direction: row;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.quick-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.panel-header .quick-btn {
    padding: 4px 10px;
    min-width: auto;
    flex: none;
    font-size: 11px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.panel-header .quick-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    transform: translateY(-1px);
}

.quick-btn {
    flex: 1;
    min-width: 80px;
    padding: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.quick-btn .btn-icon {
    font-family: var(--font-mono);
    color: var(--accent-primary);
    font-weight: bold;
}

/* ========================================
   Per-Line Complexity Gutter (Time | Space)
   ======================================== */
#complexity-gutter {
    position: absolute;
    right: 0;
    top: 0;
    width: 54px;
    background: var(--bg-tertiary);
    border-left: 2px solid var(--accent-primary);
    font-family: var(--font-mono);
    font-size: 9px;
    overflow: hidden;
    z-index: 5;
    text-align: center;
}

.cg-header {
    font-size: 8px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
    padding: 2px 0;
    text-align: center;
}

.cg-line {
    padding: 0 2px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1px;
}

.cg-sep {
    color: var(--border-color);
    opacity: 0.5;
}

/* Complexity color gradient: green (1) → red (n!) */
.c-const {
    color: #3fb950;
    /* Bright green for O(1) */
}

.c-log {
    color: #58a6ff;
    /* Blue for O(log n) */
}

.c-linear {
    color: #7ee787;
    /* Light green for O(n) */
}

.c-nlogn {
    color: #d29922;
    /* Yellow-orange for O(n log n) */
}

.c-quad {
    color: #f0883e;
    /* Orange for O(n²) */
}

.c-cubic {
    color: #f85149;
    /* Red for O(n³) */
}

.c-factorial {
    color: #da3633;
    /* Dark red for O(n!) */
}

.c-space {
    color: #a371f7;
    /* Purple for space */
}

.c-space-n {
    color: #a371f7;
    /* Purple for O(n) space */
}

.c-space-1 {
    color: #7d8590;
    /* Gray for O(1) space */
}

/* ========================================
   Google Authentication Styles
   ======================================== */

/* Google Sign-In Button */
.google-signin {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.google-signin:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.google-signin svg {
    flex-shrink: 0;
}

/* User Profile (Signed In State) */
.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    padding: 4px 10px 4px 4px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--accent-success);
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.signout-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.signout-btn:hover {
    background: var(--accent-error);
    color: white;
}

/* Sync Status Indicator */
.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 500;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.sync-status.syncing {
    border-color: rgba(88, 166, 255, 0.5);
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent-primary);
}

.sync-status.syncing #syncIcon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.sync-status.synced {
    border-color: rgba(63, 185, 80, 0.5);
    background: rgba(63, 185, 80, 0.1);
    color: var(--accent-success);
}

.sync-status.error {
    border-color: rgba(248, 81, 73, 0.5);
    background: rgba(248, 81, 73, 0.1);
    color: var(--accent-error);
}

.sync-status.offline {
    border-color: var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* ========================================
   Execution Stats
   ======================================== */
.exec-stats {
    display: flex;
    gap: 10px;
    align-items: center;
}

.exec-time,
.exec-memory {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}

.exec-time.fast {
    color: var(--accent-success);
    background: rgba(63, 185, 80, 0.15);
}

.exec-time.medium {
    color: var(--accent-warning);
    background: rgba(210, 153, 34, 0.15);
}

.exec-time.slow {
    color: var(--accent-error);
    background: rgba(248, 81, 73, 0.15);
}

.exec-memory {
    color: var(--accent-primary);
    background: rgba(88, 166, 255, 0.15);
}

/* ========================================
   Problem Parser Modal
   ======================================== */
.problem-parser-modal {
    max-width: 600px;
}

.url-input-group {
    display: flex;
    gap: 8px;
}

.url-input-group input {
    flex: 1;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.parse-status {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    margin-top: 12px;
    font-size: 13px;
}

.parse-status.loading {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent-primary);
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.parse-status.error {
    background: rgba(248, 81, 73, 0.15);
    color: var(--accent-error);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.parse-status.success {
    background: rgba(63, 185, 80, 0.15);
    color: var(--accent-success);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.parsed-problem {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.problem-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.problem-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.problem-limits {
    display: flex;
    gap: 10px;
}

.problem-limits span {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.sample-tests {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    max-height: 250px;
    overflow-y: auto;
}

.sample-test {
    display: flex;
    gap: 10px;
}

.sample-test>div {
    flex: 1;
    background: var(--bg-primary);
    padding: 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
}

.sample-test label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-family: var(--font-ui);
}

.sample-test pre {
    margin: 0;
    white-space: pre-wrap;
    color: var(--text-primary);
}

/* ========================================
   Submit Modal
   ======================================== */
.submit-modal {
    max-width: 450px;
}

.submit-info {
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.3);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.submit-info p {
    font-size: 13px;
    color: var(--accent-primary);
    margin: 0;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.submit-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border-color: #10b981 !important;
}

.submit-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.toast.success {
    background: rgba(63, 185, 80, 0.2);
    border-color: var(--accent-success);
    color: var(--accent-success);
}

.toast.error {
    background: rgba(248, 81, 73, 0.2);
    border-color: var(--accent-error);
    color: var(--accent-error);
}

/* ========================================
   Autocomplete Dropdown (CodeMirror Hints)
   ======================================== */
.CodeMirror-hints {
    position: absolute;
    z-index: 100;
    overflow-y: auto;
    max-height: 280px;
    min-width: 300px;
    max-width: 450px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 4px 0;
}

.CodeMirror-hint {
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    white-space: nowrap;
    transition: background 0.1s;
}

.CodeMirror-hint:hover {
    background: var(--bg-tertiary);
}

.CodeMirror-hint-active {
    background: var(--accent-primary) !important;
    color: white !important;
}

.CodeMirror-hint-active .hint-type,
.CodeMirror-hint-active .hint-doc {
    color: rgba(255, 255, 255, 0.8) !important;
}

.hint-icon {
    font-size: 10px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    flex-shrink: 0;
}

.hint-icon.function {
    background: rgba(88, 166, 255, 0.2);
    color: var(--accent-primary);
}

.hint-icon.class {
    background: rgba(210, 153, 34, 0.2);
    color: var(--accent-warning);
}

.hint-icon.method {
    background: rgba(138, 135, 232, 0.2);
    color: #a78bfa;
}

.hint-icon.variable {
    background: rgba(63, 185, 80, 0.2);
    color: var(--accent-success);
}

.hint-icon.constant {
    background: rgba(248, 81, 73, 0.2);
    color: var(--accent-error);
}

.hint-icon.decorator {
    background: rgba(240, 147, 251, 0.2);
    color: #f093fb;
}

.hint-icon.snippet {
    background: rgba(45, 212, 191, 0.2);
    color: #2dd4bf;
}

.hint-name {
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hint-signature {
    font-size: 10px;
    color: var(--text-muted);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hint-doc {
    font-size: 10px;
    color: var(--text-secondary);
    margin-left: auto;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Autocomplete loading indicator */
.hint-loading {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* Parse Problem Button Special Style */
#parseProblemBtn span,
#submitCodeBtn span {
    font-size: 14px;
}

/* ========================================
   Additional Modal Styles
   ======================================== */
.modal-content.problem-parser-modal,
.modal-content.submit-modal {
    animation: modalSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Complexity Gutter Styles - FIXED */
.complexity-gutter {
    width: 100px !important;
    min-width: 100px !important;
    background: var(--bg-secondary) !important;
    border-right: 2px solid var(--border-color) !important;
}

.complexity-marker {
    text-align: center;
    padding: 0 4px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-mono);
    color: var(--text-primary);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0;
    background: transparent;
    white-space: nowrap;
    height: 100%;
    line-height: 1.5;
}

.cg-sep {
    color: var(--border-color);
    margin: 0 4px;
    opacity: 0.4;
}

.line-num {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    min-width: 20px;
    text-align: right;
    opacity: 0.8;
}

/* Complexity colors */
.c-const {
    color: var(--text-muted);
}

.c-linear {
    color: #4ade80;
}

.c-quad {
    color: #fbbf24;
}

.c-cubic {
    color: #f87171;
}

.c-log {
    color: #60a5fa;
}

.c-nlogn {
    color: #a78bfa;
}

/* Force CodeMirror to respect gutter width */
.CodeMirror-gutters {
    min-width: 100px !important;
    background: var(--bg-secondary) !important;
}

.CodeMirror-sizer {
    margin-left: 100px !important;
}

/* ========================================
   Variable Actions & Convert Dropdown
   ======================================== */
.var-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.convert-dropdown {
    position: relative;
}

.convert-btn {
    font-size: 12px;
}

.convert-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 100px;
    z-index: 100;
    padding: 4px 0;
    margin-top: 4px;
}

.convert-menu.hidden {
    display: none;
}

.convert-menu button {
    display: block;
    width: 100%;
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.convert-menu button:hover {
    background: var(--accent-primary);
    color: white;
}

/* ========================================
   Data Structure Visualizations
   ======================================== */
.ds-visual {
    margin-top: 6px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 11px;
}

.ds-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--accent-primary);
}

.ds-nodes {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ds-node {
    display: flex;
    align-items: center;
    gap: 6px;
}

.node-id {
    background: var(--accent-primary);
    color: white;
    padding: 2px 6px;
    border-radius: 50%;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.node-edges {
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Heap visualization */
.heap-levels {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.heap-level {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.heap-node {
    background: var(--accent-success);
    color: white;
    padding: 4px 8px;
    border-radius: 50%;
    font-weight: 500;
    min-width: 24px;
    text-align: center;
}

/* Matrix visualization */
.matrix-table {
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 10px;
}

.matrix-table td {
    border: 1px solid var(--border-color);
    padding: 3px 6px;
    text-align: center;
    min-width: 24px;
}

.matrix-table tr:nth-child(even) td {
    background: var(--bg-elevated);
}

.ds-raw,
.ds-tree-view {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    word-break: break-all;
}

/* ========================================
   Cursor Rules Modal Styles
   ======================================== */
.cursor-rules-modal {
    max-width: 600px;
    width: 90%;
}

.modal-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 16px;
}

.modal-hint code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.rules-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.rule-trigger {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent-primary);
    min-width: 60px;
}

.rule-arrow {
    color: var(--text-muted);
}

.rule-template {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: 60px;
    overflow-y: auto;
}

.rule-delete {
    background: transparent;
    border: none;
    color: var(--accent-error);
    cursor: pointer;
    font-size: 14px;
}

.add-rule-form {
    display: grid;
    grid-template-columns: 100px auto auto 1fr auto;
    gap: 10px;
    align-items: start;
}

.add-rule-form input,
.add-rule-form textarea,
.add-rule-form select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
}

.add-rule-form textarea {
    resize: vertical;
    min-height: 60px;
}

/* ========================================
   Alt Command Box Overlay
   ======================================== */
.alt-command-box {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    border: 2px solid var(--accent-primary);
    border-radius: var(--radius-lg);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.alt-label {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 14px;
}

.alt-command-text {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 60px;
}


/* Variable Highlight */
.cm-var-highlight {
    background-color: rgba(255, 255, 0, 0.2) !important;
    border-bottom: 1px solid rgba(255, 255, 0, 0.5);
    border-radius: 2px;
}

/* Loop Expansion (Expand on Hover) */
.iteration-card {
    transition: all 0.2s ease;
}

.iteration-header {
    position: relative;
    cursor: default;
}

.iteration-header::after {
    content: '▶';
    font-size: 10px;
    position: absolute;
    right: 8px;
    opacity: 0.5;
    transition: transform 0.2s;
    color: var(--text-muted);
}

.iteration-card:hover .iteration-header::after {
    transform: rotate(90deg);
}

.iteration-table-container {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.iteration-card:hover .iteration-table-container,
.iteration-card.pinned .iteration-table-container {
    max-height: 600px;
    opacity: 1;
}

/* Variable History Expansion */
.var-history:hover .history-short,
.var-history.pinned .history-short {
    display: none;
}

.var-history:hover .history-full,
.var-history.pinned .history-full {
    display: block !important;
    white-space: pre-line;
    line-height: 1.4;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    margin-top: 4px;
}

/* Pinned indicator */
.iteration-card.pinned,
.var-history.pinned {
    border-left: 2px solid var(--accent-success);
}

.iteration-card.pinned .iteration-header::before {
    content: '📌 ';
}

/* Variable Pin Level Styles */
.var-item {
    cursor: pointer;
    transition: border-left 0.2s, background 0.2s;
}

.var-item.pin-level-1 {
    border-left: 2px solid var(--accent-primary);
    background: rgba(88, 166, 255, 0.05);
}

.var-item.pin-level-2 {
    border-left: 2px solid var(--accent-success);
    background: rgba(63, 185, 80, 0.08);
}

.var-value-container {
    font-family: var(--font-mono);
    font-size: 12px;
    margin-top: 4px;
}

.var-current-value {
    color: var(--accent-primary);
    padding: 2px 4px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    margin-bottom: 4px;
}

.var-full-history {
    color: var(--accent-success);
    padding: 4px;
    background: var(--bg-elevated);
    border-radius: 3px;
    white-space: pre-line;
    line-height: 1.4;
    max-height: 150px;
    overflow-y: auto;
}

/* Scope Group Styles */
.scope-group {
    margin-bottom: 8px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.scope-header {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.scope-header:hover {
    background: var(--bg-elevated);
}

.scope-name {
    flex: 1;
}

.scope-count {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 400;
}

.scope-vars {
    padding: 4px;
}

.scope-group.collapsed .scope-vars {
    display: none;
}

.scope-group.collapsed .scope-header::before {
    content: '▶ ';
    font-size: 8px;
}

.scope-group:not(.collapsed) .scope-header::before {
    content: '▼ ';
    font-size: 8px;
}

/* Compact Variable Styles */
.var-item {
    font-size: 11px;
    margin-bottom: 2px !important;
    padding: 2px 4px !important;
    border-radius: 4px;
}

.var-header {
    height: 18px;
    /* Force compact height */
    gap: 4px;
}

.var-icon {
    font-size: 10px;
    width: 14px;
    height: 14px;
    line-height: 14px;
}

.var-name {
    font-size: 11px;
}

.var-type {
    font-size: 9px;
    opacity: 0.7;
}

/* Sub-Scope Styles (Methods inside Classes) */
.sub-scope-group {
    margin-left: 8px;
    margin-top: 4px;
    border-left: 1px solid var(--border-color);
    padding-left: 6px;
}

.sub-scope-header {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sub-scope-icon {
    font-family: var(--font-mono);
    color: var(--accent-warning);
}

/* Matrix View Styles */
.matrix-view-container {
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 8px;
    margin-top: 8px;
    border: 1px solid var(--border-color);
}

.matrix-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.matrix-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 11px;
    font-family: var(--font-mono);
}

.matrix-table th,
.matrix-table td {
    border: 1px solid var(--border-color);
    padding: 4px;
    text-align: center;
}

.matrix-table th {
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-weight: 600;
}

.matrix-header-row {
    background: var(--bg-elevated);
}

.matrix-cell {
    background: var(--bg-primary);
    vertical-align: top;
    min-width: 40px;
}

.matrix-cell:hover {
    background: var(--bg-elevated);
}

.empty-cell {
    background: var(--bg-secondary);
    opacity: 0.5;
}

.cell-val {
    display: flex;
    gap: 4px;
    justify-content: center;
    white-space: nowrap;
}

.var-name-micro {
    opacity: 0.6;
    font-size: 9px;
}

/* Minimize CodeMirror Gutter Space */
.CodeMirror-gutters {
    padding-left: 2px !important;
    padding-right: 2px !important;
}

.CodeMirror-linenumbers {
    padding: 0 4px 0 2px !important;
    min-width: 24px !important;
}

/* Remove foldgutter if not needed */
.CodeMirror-foldgutter {
    width: 0 !important;
    display: none;
}

/* Per-Variable Dropdown Menus */
.var-dropdown {
    position: relative;
    display: inline-block;
}

.var-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    min-width: 80px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.var-dropdown:hover .var-dropdown-menu {
    display: block;
}

.var-dropdown-menu button {
    display: block;
    width: 100%;
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 11px;
    text-align: left;
    cursor: pointer;
}

.var-dropdown-menu button:hover {
    background: var(--accent-primary);
    color: white;
}

/* Delta indicators for loop value changes */
.delta {
    font-size: 9px;
    margin-left: 3px;
    font-weight: 500;
}

.delta.positive {
    color: var(--accent-success);
}

.delta.negative {
    color: var(--accent-error);
}

/* Visual Tree Rendering */
.visual-tree {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

.tree-node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tree-node {
    background: var(--accent-primary);
    color: white;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 11px;
    font-family: var(--font-mono);
    white-space: nowrap;
    cursor: default;
    transition: transform 0.2s, box-shadow 0.2s;
}

.tree-node:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tree-label {
    font-weight: 500;
}

.tree-connector {
    width: 2px;
    height: 12px;
    background: var(--border-color);
}

.tree-children {
    display: flex;
    gap: 4px;
    position: relative;
}

/* Horizontal line across children */
.tree-children::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: var(--border-color);
}

/* Vertical connectors from horizontal line to children */
.tree-children>.tree-node-wrapper::before {
    content: '';
    display: block;
    width: 2px;
    height: 10px;
    background: var(--border-color);
    margin-bottom: 2px;
}

/* Null tree node (empty leaf) */
.tree-node.null {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 2px 6px;
    font-size: 9px;
    opacity: 0.5;
}

/* Expression calculation display in loops */
.expr-calc {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent-secondary);
    background: rgba(var(--accent-secondary-rgb), 0.1);
    padding: 1px 4px;
    border-radius: 3px;
}

/* Mermaid Tree Visualization */
.var-tree-viz {
    width: 100%;
    margin-top: 4px;
}

.tree-compact {
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree-mermaid-container {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-top: 4px;
}

.var-tree-viz:hover .tree-mermaid-container {
    opacity: 1;
    max-height: 300px;
    /* Adjust as needed */
    padding: 10px;
    overflow: auto;
    z-index: 100;
}

.mermaid {
    display: flex;
    justify-content: center;
}

/* Nodes styling overrides */
.node circle {
    stroke-width: 2px !important;
}


.nodeLabel {
    color: #fff !important;
    font-family: var(--font-primary) !important;
}

/* Nested Loop Block Visualization */
.nested-block-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-top: 8px;
}

.nested-block-outer {
    background: rgba(45, 51, 59, 0.6);
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
}

.nested-block-outer:hover {
    background: rgba(45, 51, 59, 0.9);
    border-color: rgba(88, 166, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nested-block-header {
    font-family: var(--font-mono);
    color: #58a6ff;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nested-block-inner-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nested-block-inner-item {
    background: rgba(56, 139, 253, 0.15);
    border: 1px solid rgba(56, 139, 253, 0.3);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #e6edf3;
    transition: background 0.2s;
}

.nested-block-inner-item:hover {
    background: rgba(56, 139, 253, 0.3);
}

.nested-block-empty {
    font-style: italic;
    color: #8b949e;
    font-size: 12px;
    padding: 4px;
}

/* Nested Loop Table Visualization */
.nested-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 12px;
    margin-top: 4px;
}

.nested-table th {
    text-align: left;
    padding: 4px 8px;
    color: #8b949e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
}

.nested-table td {
    padding: 4px 8px;
    color: #e6edf3;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nested-table tr:last-child td {
    border-bottom: none;
}

.nested-table tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}