/* ========== BG PATTERN ========== */
.bg-pattern {
    position: fixed; top:0;left:0;right:0;bottom:0;
    background-image:
        radial-gradient(ellipse 80% 50% at 20% -20%, rgba(99,102,241,0.15), transparent),
        radial-gradient(ellipse 60% 40% at 80% 110%, rgba(139,92,246,0.1), transparent);
    pointer-events: none; z-index: 0;
}

/* ========== HEADER ========== */
.header {
    position: relative; z-index: 100; height: 64px;
    background: var(--bg-glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 20px; display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
    width: 40px; height: 40px; background: var(--accent-gradient); border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-glow); animation: pulse-glow 3s ease-in-out infinite;
    cursor: pointer;
}
@keyframes pulse-glow { 0%,100%{box-shadow:0 0 20px var(--accent-glow)} 50%{box-shadow:0 0 35px var(--accent-glow)} }
.logo-text {
    font-size: 18px; font-weight: 700;
    background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.header-badge {
    background: rgba(99,102,241,0.1); color: var(--accent-primary);
    font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px;
    border: 1px solid rgba(99,102,241,0.2); margin-left: 8px;
}
.beta-badge {
    background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(239,68,68,0.1));
    color: #f59e0b; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 6px;
    border: 1px solid rgba(245,158,11,0.3); margin-left: 6px; letter-spacing: 0.5px; text-transform: uppercase;
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-btn {
    background: var(--bg-tertiary); border: 1px solid var(--border-medium); color: var(--text-secondary);
    padding: 8px 14px; border-radius: var(--radius-md); cursor: pointer;
    font-size: 13px; font-weight: 500; font-family: inherit;
    transition: all var(--transition-fast); display: flex; align-items: center; gap: 6px;
}
.header-btn:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--accent-primary); }

/* Nav Dropdown */
.nav-dropdown { position: relative; }
.nav-trigger {
    background: var(--bg-tertiary); border: 1px solid var(--border-medium); color: var(--text-secondary);
    padding: 8px 12px; border-radius: var(--radius-md); cursor: pointer;
    font-size: 13px; font-weight: 500; font-family: inherit;
    transition: all var(--transition-fast); display: flex; align-items: center; gap: 6px;
}
.nav-trigger:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--accent-primary); }
.nav-menu {
    position: absolute; top: calc(100% + 8px); right: 0; min-width: 220px;
    background: var(--bg-elevated); border: 1px solid var(--border-medium);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    padding: 6px; opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: all 0.2s ease; z-index: 200;
}
.nav-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: var(--radius-sm); color: var(--text-secondary);
    text-decoration: none; font-size: 13px; font-weight: 500; transition: all var(--transition-fast);
}
.nav-item:hover { background: rgba(99,102,241,0.08); color: var(--text-primary); }
.nav-item.active { background: rgba(99,102,241,0.1); color: var(--accent-primary); font-weight: 600; }
.nav-item-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-sep { height: 1px; background: var(--border-subtle); margin: 4px 8px; }

/* ========== CONTAINER ========== */
.container { display: flex; height: calc(100vh - 64px); position: relative; }

/* ========== SIDEBAR ========== */
.sidebar {
    width: 340px; min-width: 240px; max-width: 500px;
    background: var(--bg-secondary); border-right: 1px solid var(--border-subtle);
    display: flex; flex-direction: column; overflow: hidden;
    position: relative; transition: width var(--transition-medium);
}
.sidebar.collapsed { width: 0 !important; min-width: 0; border-right: none; }

.sidebar-resize-handle {
    position: absolute; right: 0; top: 0; bottom: 0; width: 12px;
    cursor: ew-resize; background: transparent; z-index: 100;
    display: flex; align-items: center; justify-content: center;
}
.sidebar-resize-handle::before {
    content: ''; width: 4px; height: 40px;
    background: var(--border-medium); border-radius: 2px; transition: all var(--transition-fast);
}
.sidebar-resize-handle:hover::before { background: var(--accent-primary); height: 60px; box-shadow: 0 0 8px var(--accent-glow); }
.sidebar-resize-handle.dragging::before { background: var(--accent-primary); height: 80px; box-shadow: 0 0 12px var(--accent-glow); }

.sidebar-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border-subtle);
    background: linear-gradient(135deg, rgba(99,102,241,0.03), rgba(139,92,246,0.03));
}
.sidebar-title {
    font-size: 13px; font-weight: 700; color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
}

.equations-list { flex: 1; overflow-y: auto; padding: 16px; }

/* ========== EQUATION CARD ========== */
.eq-card {
    background: var(--bg-secondary); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); margin-bottom: 12px; overflow: hidden;
    box-shadow: var(--shadow-sm); transition: all var(--transition-fast);
}
.eq-card:hover { box-shadow: var(--shadow-md); border-color: rgba(99,102,241,0.2); }

.eq-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; cursor: pointer;
    background: linear-gradient(135deg, rgba(99,102,241,0.04), rgba(139,92,246,0.04));
    transition: background var(--transition-fast);
}
.eq-card-header:hover { background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.08)); }

.eq-card-title {
    font-size: 12px; font-weight: 700; color: var(--accent-primary);
    display: flex; align-items: center; gap: 8px;
}
.eq-card-title .icon { font-size: 14px; }

.eq-card-formula {
    font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600;
    color: var(--text-secondary); background: rgba(99,102,241,0.08);
    padding: 2px 8px; border-radius: 4px; margin-left: 4px;
}
.eq-card-formula var { font-style: italic; color: var(--accent-primary); }

.eq-card-badge {
    background: var(--accent-gradient); color: white;
    font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
}
.eq-card-toggle {
    background: none; border: none; font-size: 12px; cursor: pointer;
    color: var(--text-muted); transition: transform var(--transition-fast);
    width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%;
}
.eq-card-toggle:hover { background: var(--bg-tertiary); }
.eq-card-toggle.open { transform: rotate(180deg); }

.eq-card-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.eq-card-content.open { max-height: 3000px; }
.eq-card-inner { padding: 16px; border-top: 1px solid var(--border-subtle); }

/* ========== EQUATION ROW ========== */
.eq-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; background: var(--bg-tertiary);
    border: 1px solid transparent; border-radius: var(--radius-sm);
    margin-bottom: 8px; transition: all var(--transition-fast);
}
.eq-row:hover { border-color: var(--border-medium); }
.eq-row.main {
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(139,92,246,0.1));
    border-color: rgba(99,102,241,0.2);
}

.eq-color {
    width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
    border: 3px solid white; box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(0,0,0,0.1);
    flex-shrink: 0; transition: transform var(--transition-fast);
}
.eq-color:hover { transform: scale(1.15); }

.eq-body {
    display: flex; align-items: center; gap: 4px; flex: 1;
    font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 500; flex-wrap: wrap;
}
.eq-body var { font-style: italic; color: var(--accent-primary); font-weight: 600; }

.eq-input {
    width: 52px; padding: 4px 2px; border: 1px solid var(--border-medium);
    border-radius: 6px; font-family: 'JetBrains Mono', monospace;
    font-size: 13px; font-weight: 600; text-align: center;
    background: white; cursor: pointer; transition: all var(--transition-fast);
    color: var(--text-primary);
}
.eq-input:hover { border-color: var(--accent-primary); }
.eq-input:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }

.eq-actions { display: flex; gap: 4px; }
.eq-btn {
    background: none; border: none; font-size: 14px; cursor: pointer;
    padding: 4px 6px; border-radius: 4px; opacity: 0.6;
    transition: all var(--transition-fast);
}
.eq-btn:hover { opacity: 1; background: var(--bg-secondary); }
.eq-btn.off { opacity: 0.3; }
.eq-btn.delete:hover { color: var(--error); background: #fef2f2; }
.eq-row.main .eq-btn.delete { display: none; }

/* Slider Box */
.slider-box {
    margin-top: 12px; padding: 14px; background: white;
    border-radius: var(--radius-sm); border: 1px solid var(--border-subtle);
}
.slider-eq-display {
    font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 600;
    text-align: center; padding: 10px;
    background: linear-gradient(135deg, rgba(99,102,241,0.05), rgba(139,92,246,0.05));
    border-radius: var(--radius-sm); margin-bottom: 14px;
    border: 1px solid rgba(99,102,241,0.1);
}
.slider-eq-display var { font-style: italic; color: var(--accent-primary); }

/* ========== SLIDER ========== */
.slider-group { margin-top: 10px; }
.slider-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
}
.slider-label {
    font-size: 11px; font-weight: 600; color: var(--text-secondary);
}
.slider-label var { font-style: italic; color: var(--accent-primary); }
.slider-value {
    font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700;
    color: var(--text-primary); cursor: pointer; background: var(--bg-tertiary);
    padding: 2px 10px; border-radius: 6px; border: 1px solid var(--border-subtle);
    transition: all var(--transition-fast);
}
.slider-value:hover { border-color: var(--accent-primary); background: rgba(99,102,241,0.08); }

.slider-wrapper { position: relative; height: 32px; display: flex; align-items: center; gap: 8px; }
.slider-track-area { position: relative; flex: 1; height: 32px; display: flex; align-items: center; }
.slider-track {
    position: absolute; width: 100%; height: 6px;
    background: var(--bg-tertiary); border-radius: 3px; overflow: hidden;
    border: 1px solid var(--border-subtle);
}
.slider-fill { height: 100%; border-radius: 3px; transition: width 0.1s ease; }
.slider-input {
    width: 100%; height: 32px; -webkit-appearance: none; appearance: none;
    background: transparent; cursor: pointer; position: relative; z-index: 2;
}

/* Play Button */
.play-btn {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    border: 1.5px solid var(--border-medium); background: var(--bg-secondary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast); position: relative;
}
.play-btn:hover { border-color: var(--accent-primary); background: rgba(99,102,241,0.06); }
.play-btn.playing { border-color: var(--accent-primary); background: rgba(99,102,241,0.1); }
.play-btn svg { width: 14px; height: 14px; }
.play-btn .play-icon { display: block; }
.play-btn .pause-icon { display: none; }
.play-btn.playing .play-icon { display: none; }
.play-btn.playing .pause-icon { display: block; }
.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
    background: white; border: 2px solid var(--accent-primary);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15); cursor: pointer;
    transition: transform var(--transition-fast);
}
.slider-input::-webkit-slider-thumb:hover { transform: scale(1.2); box-shadow: 0 2px 10px var(--accent-glow); }
.slider-input::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: white; border: 2px solid var(--accent-primary);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15); cursor: pointer;
}

/* ========== INFO BOX ========== */
.info-box {
    margin-top: 8px; padding: 10px 12px; background: linear-gradient(135deg, rgba(99,102,241,0.04), rgba(139,92,246,0.04));
    border: 1px solid rgba(99,102,241,0.1); border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-secondary);
    line-height: 1.7;
}
.info-box .info-label { font-weight: 700; color: var(--accent-primary); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.info-box .info-row { display: flex; justify-content: space-between; align-items: center; }
.info-box .info-val { font-weight: 600; color: var(--text-primary); }

.info-box .info-pos { color: #10b981; }
.info-box .info-zero { color: #f59e0b; }
.info-box .info-neg { color: #ef4444; }

/* ========== ADD BUTTON ========== */
.add-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px; margin-top: 10px; border-radius: var(--radius-sm);
    border: 2px dashed var(--border-medium); background: transparent;
    color: var(--text-muted); font-size: 12px; font-weight: 600;
    font-family: inherit; cursor: pointer; transition: all var(--transition-fast);
}
.add-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); background: rgba(99,102,241,0.04); }

/* ========== GRAPH ========== */
.graph-container {
    flex: 1; position: relative; background: var(--graph-bg); overflow: hidden;
}
.graph-container canvas {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: grab;
}

.graph-controls {
    position: absolute; right: 16px; top: 16px;
    display: flex; flex-direction: column; gap: 6px; z-index: 10;
}
.ctrl-btn {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--bg-glass); backdrop-filter: blur(10px);
    border: 1px solid var(--border-medium); color: var(--text-secondary);
    font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast);
}
.ctrl-btn:hover { background: var(--accent-primary); color: white; border-color: var(--accent-primary); }

.zoom-info {
    position: absolute; right: 16px; top: 142px;
    font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-muted);
    background: var(--bg-glass); backdrop-filter: blur(10px);
    padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border-subtle);
}

/* ========== CLICK LABEL ========== */
.click-label {
    position: absolute; pointer-events: none; z-index: 20;
    font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600;
    padding: 6px 12px; border-radius: var(--radius-sm);
    background: var(--bg-glass); backdrop-filter: blur(10px);
    border: 1px solid var(--border-medium); box-shadow: var(--shadow-md);
    opacity: 0; transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}
.click-label.show { opacity: 1; transform: translateY(0); }

/* ========== PINNED PANEL ========== */
.pinned-panel {
    position: absolute; left: 16px; top: 16px;
    background: var(--bg-glass); backdrop-filter: blur(10px);
    border: 1px solid var(--border-medium); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 12px; min-width: 200px;
    max-height: calc(100% - 32px); overflow-y: auto;
    display: none; z-index: 10;
}
.pinned-panel.show { display: block; }
.pinned-list { max-height: 200px; overflow-y: auto; }
.pinned-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
    font-size: 12px; font-weight: 700; color: var(--text-primary);
}
.clear-btn {
    background: none; border: none; color: var(--text-muted); font-size: 11px;
    cursor: pointer; font-family: inherit; font-weight: 600;
}
.clear-btn:hover { color: var(--error); }
.pinned-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600;
}
.pinned-item button {
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    font-size: 14px; padding: 0 4px;
}
.pinned-item button:hover { color: var(--error); }

/* ========== TOAST ========== */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--text-primary); color: white; padding: 10px 20px; border-radius: var(--radius-md);
    font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg);
    opacity: 0; transition: all 0.3s ease; z-index: 9999; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== STYLE PANEL ========== */
.style-panel {
    position: fixed; z-index: 500; background: var(--bg-elevated);
    border: 1px solid var(--border-medium); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 12px;
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: all 0.2s ease;
}
.style-panel.show { opacity: 1; visibility: visible; transform: translateY(0); }
.color-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.color-opt {
    width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
    border: 2px solid transparent; transition: all var(--transition-fast);
}
.color-opt:hover { transform: scale(1.15); }
.color-opt.sel { border-color: var(--text-primary); box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text-primary); }

/* ========== NUMPAD ========== */
.numpad-overlay {
    position: fixed; inset: 0; z-index: 600; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center;
}
.numpad-overlay.show { display: flex; }
.numpad {
    background: var(--bg-elevated); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 20px; min-width: 260px;
    border: 1px solid var(--border-medium);
}
.numpad-display {
    text-align: center; font-family: 'JetBrains Mono', monospace;
    font-size: 28px; font-weight: 700; color: var(--text-primary);
    padding: 12px; margin-bottom: 16px; background: var(--bg-primary);
    border-radius: var(--radius-sm); border: 1px solid var(--border-subtle);
}
.numpad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.num-btn {
    height: 48px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
    background: var(--bg-secondary); color: var(--text-primary);
    font-size: 18px; font-weight: 600; font-family: inherit; cursor: pointer;
    transition: all var(--transition-fast);
}
.num-btn:hover { background: var(--bg-tertiary); }
.num-btn:active { transform: scale(0.95); }
.num-btn.neg { color: var(--accent-primary); font-weight: 700; }
.num-btn.del { color: var(--error); }
.num-btn.cancel { grid-column: span 1; background: var(--bg-tertiary); color: var(--text-muted); font-size: 13px; }
.num-btn.ok { grid-column: span 2; background: var(--accent-gradient); color: white; font-size: 14px; border: none; }

/* ========== MOBILE ========== */
.mobile-menu {
    display: none; width: 40px; height: 40px; background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
    cursor: pointer; align-items: center; justify-content: center;
    font-size: 18px; margin-right: 12px;
}
.mobile-menu:hover { background: var(--accent-primary); color: white; border-color: transparent; }

.sidebar-overlay {
    display: none; position: fixed; top: 64px; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); z-index: 49;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed; left: 0; top: 64px; bottom: 0;
        width: 85% !important; max-width: 340px; z-index: 50;
        transform: translateX(-100%); transition: transform 0.3s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar { overflow-y: auto; }
    .sidebar-resize-handle { display: none; }
    .mobile-menu { display: flex !important; }
    .header-badge { display: none; }
    .beta-badge { display: none; }
}

@media (max-width: 600px) {
    .pinned-panel { left: 8px; top: 8px; padding: 8px; min-width: 160px; font-size: 11px; max-height: 40vh; }
    .graph-controls { right: 8px; top: 8px; }
    .zoom-info { right: 8px; top: 118px; }
    .ctrl-btn { width: 32px; height: 32px; font-size: 14px; }
    .splash-logo-mark { width: 70px; height: 70px; }
    .splash-brand-name { font-size: 26px; }
}

@media (max-width: 480px) {
    .header { padding: 0 12px; height: 56px; }
    .header-btn span:last-child { display: none; }
    .nav-trigger span:last-child { display: none; }
    .logo-text { font-size: 15px; }
    .numpad { min-width: 240px; padding: 16px; }
    .numpad-display { font-size: 24px; padding: 10px; }
    .num-btn { height: 44px; font-size: 16px; }
}
/* ========== TABLE PANEL ========== */
.table-panel {
    position: absolute; right: 16px; bottom: 16px;
    background: var(--bg-glass); backdrop-filter: blur(12px);
    border: 1px solid var(--border-medium); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); min-width: 240px; max-width: 400px;
    max-height: 50vh; display: none; z-index: 10;
    overflow: hidden;
}
.table-panel.show { display: block; }
.table-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-bottom: 1px solid var(--border-subtle);
    font-size: 12px; font-weight: 700; color: var(--text-primary);
}
.table-close {
    background: none; border: none; cursor: pointer; font-size: 16px;
    color: var(--text-muted); width: 24px; height: 24px; display: flex;
    align-items: center; justify-content: center; border-radius: 50%;
}
.table-close:hover { background: var(--bg-tertiary); color: var(--error); }
.table-scroll { overflow: auto; max-height: calc(50vh - 44px); }
.val-table { width: 100%; border-collapse: collapse; font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.val-table th {
    position: sticky; top: 0; background: var(--bg-secondary);
    padding: 6px 10px; text-align: center; font-weight: 700;
    border-bottom: 2px solid var(--border-medium); z-index: 1;
}
.val-table td {
    padding: 4px 10px; text-align: center; border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}
.val-table tr:hover td { background: rgba(99, 102, 241, 0.05); }
.val-table td:first-child { font-weight: 600; color: var(--text-secondary); }

/* ========== TABLE TOGGLE BUTTON ========== */
.table-btn {
    position: absolute; right: 16px; bottom: 16px;
    width: 40px; height: 40px;
    background: var(--bg-glass); backdrop-filter: blur(10px);
    border: 1px solid var(--border-medium); border-radius: var(--radius-sm);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 16px; box-shadow: var(--shadow-sm); z-index: 9;
    transition: all var(--transition-fast);
}
.table-btn:hover { background: var(--accent-primary); color: white; border-color: transparent; }
.table-btn.active { background: var(--accent-primary); color: white; border-color: transparent; }

/* ========== INTERSECTION BADGE ========== */
.intersection-badge {
    position: absolute; right: 62px; bottom: 16px;
    background: var(--bg-glass); backdrop-filter: blur(10px);
    border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius-sm);
    padding: 4px 10px; font-size: 11px; font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    color: #ef4444; z-index: 9; display: none;
    box-shadow: var(--shadow-sm);
}
.intersection-badge.show { display: flex; align-items: center; gap: 4px; }

@media (max-width: 600px) {
    .table-panel { right: 8px; bottom: 8px; min-width: 200px; max-width: 85vw; max-height: 40vh; }
    .table-btn { right: 8px; bottom: 8px; width: 34px; height: 34px; font-size: 14px; }
    .intersection-badge { right: 48px; bottom: 8px; font-size: 10px; padding: 3px 8px; }
}

/* ========== TUTORIAL SYSTEM ========== */
.tut-overlay {
    display: none;
}
.tut-overlay.show { display: block; }

/* 4 karanlık şerit — highlight'ın etrafını çevirir, üstüne tıklamayı engellemez */
.tut-backdrop-panel {
    position: fixed; z-index: 9001;
    background: rgba(0,0,0,0.45);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    display: none;
}

.tut-highlight {
    position: fixed; z-index: 9002;
    border-radius: 8px; border: 2px solid #6366f1;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2), 0 0 20px rgba(99,102,241,0.15);
    display: none;
}
.tut-highlight.pulse {
    animation: tutPulse 1.5s ease-in-out infinite;
}
@keyframes tutPulse {
    0%, 100% { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.2), 0 0 20px rgba(99,102,241,0.15); }
    50% { border-color: #a855f7; box-shadow: 0 0 0 5px rgba(168,85,247,0.25), 0 0 30px rgba(168,85,247,0.2); }
}

/* Koyu tema uyumlu tooltip */
.tut-tooltip {
    position: fixed; z-index: 9010;
    background: #fff;
    border: none;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05);
    max-width: 360px; min-width: 270px;
    transform: translateY(10px); opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    user-select: none;
}
.tut-tooltip.show { transform: translateY(0); opacity: 1; }
/* Sürükleme imleci — sadece header */
.tut-tooltip-header {
    padding: 14px 18px 0; display: flex; align-items: center; gap: 10px;
    cursor: grab;
}
.tut-tooltip-header:active { cursor: grabbing; }
.tut-tooltip-icon {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--accent-gradient); display: flex;
    align-items: center; justify-content: center;
    font-size: 15px; flex-shrink: 0;
}
.tut-tooltip-step {
    font-size: 10px; font-weight: 700; color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace; letter-spacing: 0.5px;
}
.tut-tooltip-title {
    font-size: 14px; font-weight: 700; color: var(--text-primary);
    margin-top: 2px;
}
.tut-tooltip-body {
    padding: 10px 18px; font-size: 12.5px; line-height: 1.65;
    color: var(--text-secondary);
}
.tut-tooltip-body strong { color: var(--text-primary); }
.tut-tooltip-body code {
    background: var(--bg-tertiary); padding: 2px 6px;
    border-radius: 4px; font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px; color: var(--accent-primary);
}
.tut-tooltip-body .tut-math {
    display: inline-block; background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(168,85,247,0.08));
    padding: 4px 10px; border-radius: 6px; margin: 4px 0;
    font-family: 'JetBrains Mono', monospace; font-size: 12px;
    font-weight: 600; color: #6366f1; border: 1px solid rgba(99,102,241,0.15);
}
.tut-tooltip-task {
    margin: 6px 18px; padding: 9px 12px;
    background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(168,85,247,0.06));
    border-radius: 10px; border-left: 3px solid var(--accent-primary);
    font-size: 12px; font-weight: 600; color: var(--text-primary);
}
.tut-tooltip-task::before { content: '🎯 '; }

.tut-tooltip-footer {
    padding: 10px 18px 14px; display: flex; justify-content: space-between;
    align-items: center; gap: 8px;
}
.tut-progress {
    display: flex; gap: 4px; align-items: center;
}
.tut-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--border-medium); transition: all 0.2s ease;
}
.tut-dot.done { background: var(--accent-primary); }
.tut-dot.current { background: var(--accent-primary); width: 18px; border-radius: 3px; }

.tut-btns { display: flex; gap: 6px; }
.tut-btn {
    padding: 6px 14px; border-radius: 8px; border: none;
    font-family: inherit; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.15s ease;
}
.tut-btn-skip {
    background: var(--bg-tertiary); color: var(--text-muted);
}
.tut-btn-skip:hover { background: var(--border-medium); }
.tut-btn-next {
    background: var(--accent-gradient); color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.tut-btn-next:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.tut-btn-next:disabled { opacity: 0.35; cursor: default; transform: none; box-shadow: none; }

.tut-success {
    display: none; margin: 6px 18px; padding: 7px 12px;
    background: rgba(16,185,129,0.1); border-radius: 8px;
    border: 1px solid rgba(16,185,129,0.2);
    font-size: 12px; font-weight: 600; color: #10b981;
    text-align: center;
}
.tut-success.show { display: block; animation: tutFadeIn 0.3s ease; }
@keyframes tutFadeIn { from { opacity:0; transform:scale(0.95); } to { opacity:1; transform:scale(1); } }

/* Tutorial start panel */
.tut-start-panel {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.97);
    z-index: 9010; background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2); max-width: 420px; width: 90%;
    display: none; opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease;
}
.tut-start-panel.show { display: block; opacity: 1; transform: translate(-50%, -50%) scale(1); }
.tut-start-header {
    padding: 24px 24px 0; text-align: center;
}
.tut-start-header h2 {
    font-size: 18px; font-weight: 800; margin-top: 10px;
    background: var(--accent-gradient); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.tut-start-header p { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.tut-lesson-list { padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; }
.tut-lesson-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 13px;
    border-radius: 12px; border: 1px solid var(--border-subtle);
    cursor: pointer; transition: all 0.15s ease;
}
.tut-lesson-item:hover { border-color: var(--accent-primary); background: rgba(99,102,241,0.04); }
.tut-lesson-num {
    width: 26px; height: 26px; border-radius: 7px;
    background: var(--bg-tertiary); display: flex;
    align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace; flex-shrink: 0;
}
.tut-lesson-info { flex: 1; }
.tut-lesson-info strong { font-size: 13px; display: block; color: var(--text-primary); }
.tut-lesson-info span { font-size: 11px; color: var(--text-muted); }
.tut-start-footer { padding: 10px 18px 18px; text-align: center; }
.tut-start-close {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 12px; font-family: inherit; padding: 6px 12px;
}
.tut-start-close:hover { color: var(--text-primary); }

@media (max-width: 600px) {
    .tut-tooltip { max-width: 300px; min-width: 240px; }
    .tut-start-panel { width: 95%; }
    .tut-tooltip-body { font-size: 12px; }
}
.tut-tooltip.show { transform: translateY(0); opacity: 1; }

.tut-tooltip-header {
    padding: 16px 20px 0; display: flex; align-items: center; gap: 8px;
}
.tut-tooltip-icon {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--accent-gradient); display: flex;
    align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.tut-tooltip-step {
    font-size: 11px; font-weight: 700; color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace;
}
.tut-tooltip-title {
    font-size: 15px; font-weight: 700; color: var(--text-primary);
    margin-top: 2px;
}
.tut-tooltip-body {
    padding: 12px 20px; font-size: 13px; line-height: 1.65;
    color: var(--text-secondary);
}
.tut-tooltip-body strong { color: var(--text-primary); }
.tut-tooltip-body code {
    background: var(--bg-tertiary); padding: 2px 6px;
    border-radius: 4px; font-family: 'JetBrains Mono', monospace;
    font-size: 12px; color: var(--accent-primary);
}
.tut-tooltip-body .tut-math {
    display: inline-block; background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(168,85,247,0.08));
    padding: 4px 10px; border-radius: 6px; margin: 6px 0;
    font-family: 'JetBrains Mono', monospace; font-size: 13px;
    font-weight: 600; color: #6366f1; border: 1px solid rgba(99,102,241,0.15);
}
.tut-tooltip-task {
    margin: 10px 20px; padding: 10px 14px;
    background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(168,85,247,0.06));
    border-radius: 10px; border-left: 3px solid var(--accent-primary);
    font-size: 12px; font-weight: 600; color: var(--text-primary);
}
.tut-tooltip-task::before { content: '🎯 '; }

.tut-tooltip-footer {
    padding: 12px 20px 16px; display: flex; justify-content: space-between;
    align-items: center; gap: 8px;
}
.tut-progress {
    display: flex; gap: 4px; align-items: center;
}
.tut-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--border-medium); transition: all 0.2s ease;
}
.tut-dot.done { background: var(--accent-primary); }
.tut-dot.current { background: var(--accent-primary); width: 18px; border-radius: 3px; }

.tut-btns { display: flex; gap: 6px; }
.tut-btn {
    padding: 7px 16px; border-radius: 8px; border: none;
    font-family: inherit; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.15s ease;
}
.tut-btn-skip {
    background: var(--bg-tertiary); color: var(--text-muted);
}
.tut-btn-skip:hover { background: var(--border-medium); }
.tut-btn-next {
    background: var(--accent-gradient); color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.tut-btn-next:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.tut-btn-next:disabled { opacity: 0.5; cursor: default; transform: none; }

.tut-success {
    display: none; margin: 8px 20px; padding: 8px 12px;
    background: rgba(16,185,129,0.1); border-radius: 8px;
    border: 1px solid rgba(16,185,129,0.2);
    font-size: 12px; font-weight: 600; color: #10b981;
    text-align: center;
}
.tut-success.show { display: block; animation: tutFadeIn 0.3s ease; }
@keyframes tutFadeIn { from { opacity:0; transform:scale(0.95); } to { opacity:1; transform:scale(1); } }

/* Tutorial start panel */
.tut-start-panel {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 9010; background: #fff; border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2); max-width: 420px; width: 90%;
    display: none; opacity: 0; transition: opacity 0.3s ease;
}
.tut-start-panel.show { display: block; opacity: 1; }
.tut-start-header {
    padding: 28px 28px 0; text-align: center;
}
.tut-start-header h2 {
    font-size: 20px; font-weight: 800; margin-top: 12px;
    background: var(--accent-gradient); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.tut-start-header p { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.tut-lesson-list { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.tut-lesson-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    border-radius: 12px; border: 1px solid var(--border-subtle);
    cursor: pointer; transition: all 0.15s ease;
}
.tut-lesson-item:hover { border-color: var(--accent-primary); background: rgba(99,102,241,0.04); }
.tut-lesson-num {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--bg-tertiary); display: flex;
    align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace; flex-shrink: 0;
}
.tut-lesson-info { flex: 1; }
.tut-lesson-info strong { font-size: 13px; display: block; color: var(--text-primary); }
.tut-lesson-info span { font-size: 11px; color: var(--text-muted); }
.tut-start-footer { padding: 12px 20px 20px; text-align: center; }
.tut-start-close {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 12px; font-family: inherit; padding: 6px 12px;
}
.tut-start-close:hover { color: var(--text-primary); }

@media (max-width: 600px) {
    .tut-tooltip { max-width: 300px; min-width: 240px; }
    .tut-start-panel { width: 95%; }
    .tut-tooltip-body { font-size: 12px; }
}
