/* ===========================
   CSS VARIABLES & RESET
   =========================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --secondary: #10b981;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg3: #f1f5f9;
    --bg4: #e2e8f0;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text3: #94a3b8;
    --border: #e5e7eb;
    --border2: #cbd5e1;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --accent: #8b5cf6;
    --accent2: #7c3aed;
    --navbar-bg: #ffffff;
    --gradient: linear-gradient(135deg, #8b5cf6 0%, #10b981 100%);
    --code-bg: #f8fafc;
    --code-text: #1e293b;
    --green: #10b981;
    --purple: #8b5cf6;
    --orange: #f59e0b;
    --pink: #ec4899;
    --yellow: #fbbf24;
    --red: #ef4444;
    --highlight-row: rgba(139, 92, 246, 0.05);
    --highlight-cell: rgba(139, 92, 246, 0.15);
    --partition-a: rgba(139, 92, 246, 0.05);
    --partition-b: rgba(16, 185, 129, 0.05);
    --partition-c: rgba(245, 158, 11, 0.05);
    --frame-bg: rgba(251, 191, 36, 0.08);
    --radius: 10px;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --font-sans: 'Inter', sans-serif;
}

[data-theme="dark"] {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-card: #1f2937;
    --bg3: #2d3748;
    --bg4: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text3: #9ca3af;
    --border: #374151;
    --border2: #4b5563;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --navbar-bg: #111827;
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    --highlight-row: rgba(139, 92, 246, 0.1);
    --partition-a: rgba(139, 92, 246, 0.1);
    --partition-b: rgba(16, 185, 129, 0.1);
    --partition-c: rgba(245, 158, 11, 0.1);
    --frame-bg: rgba(251, 191, 36, 0.15);
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

/* ===========================
   SCROLLBAR
   =========================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ===========================
   HERO SECTION
   =========================== */

.hero {
    background: var(--gradient);
    padding: 4rem 2rem;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
    border-bottom: 2px solid var(--border);
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
}

.hero-h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.hero-para {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.hero-stats span {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .hero {
    background: linear-gradient(to right, #111827, #1f2937);
}

[data-theme="dark"] .hero-para {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .hero-h1 {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .hero-stats span {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    border: 1px solid #7c3aed;
}

/* ===========================
   MAIN CONTAINER
   =========================== */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.app {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: 1fr;
    gap: 1.5rem;
    min-height: calc(100vh - 300px);
}

@media (max-width: 968px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
}

/* ===========================
   SIDEBAR
   =========================== */

.sidebar {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px var(--shadow);
}

.sidebar-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.fn-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fn-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    text-align: left;
    transition: all 0.15s;
    position: relative;
    overflow: hidden;
}

.fn-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-primary);
}

.fn-btn.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(16, 185, 129, 0.08));
    border-color: var(--primary);
    color: var(--primary);
}

.fn-btn.active .fn-dot {
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.fn-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border2);
    flex-shrink: 0;
    transition: all 0.15s;
}

.fn-tag {
    margin-left: auto;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.fn-tag.rank {
    background: rgba(139, 92, 246, 0.15);
    color: var(--purple);
}

.fn-tag.agg {
    background: rgba(16, 185, 129, 0.15);
    color: var(--green);
}

.fn-tag.val {
    background: rgba(245, 158, 11, 0.15);
    color: var(--orange);
}

.fn-tag.nav {
    background: rgba(236, 72, 153, 0.15);
    color: var(--pink);
}

/* Dataset selector */
.dataset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.ds-btn {
    padding: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.ds-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.ds-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(139, 92, 246, 0.08);
}

.ds-icon {
    font-size: 1.1rem;
    display: block;
    margin-bottom: 3px;
}

/* Config options */
.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.config-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.toggle {
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    border: 1px solid var(--border2);
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle.on {
    background: var(--primary);
    border-color: var(--primary);
}

.toggle::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: left 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle.on::after {
    left: 22px;
}

select.styled {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    margin-top: 6px;
}

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

/* ===========================
   MAIN CONTENT
   =========================== */

.main {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px var(--shadow);
}

/* SQL Panel */
.sql-panel {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.panel-title {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-title::before {
    content: '';
    width: 3px;
    height: 16px;
    background: var(--primary);
    border-radius: 2px;
    display: inline-block;
}

.panel-btn {
    padding: 6px 12px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.panel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.sql-code {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
    position: relative;
    color: var(--code-text);
}

.sql-code .keyword {
    color: var(--primary);
    font-weight: 600;
}

.sql-code .function {
    color: var(--purple);
}

.sql-code .string {
    color: var(--green);
}

.sql-code .comment {
    color: var(--text-secondary);
    font-style: italic;
}

.sql-code .number {
    color: var(--orange);
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 2px;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.tab {
    padding: 12px 20px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Content area */
.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* Table Styles */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 600px;
}

thead th {
    background: var(--bg-secondary);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: relative;
}

thead th.col-new {
    color: var(--primary);
    background: rgba(139, 92, 246, 0.06);
}

thead th.col-new::after {
    content: 'NEW';
    font-size: 0.6rem;
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    vertical-align: middle;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--highlight-row);
}

tbody td {
    padding: 10px 16px;
    color: var(--text-primary);
    white-space: nowrap;
}

tbody td.cell-highlight {
    background: var(--highlight-cell);
    color: var(--primary);
    font-weight: 600;
}

tbody td.cell-frame {
    background: var(--frame-bg);
    color: var(--yellow);
    font-weight: 500;
}

.partition-0 td:first-child {
    border-left: 3px solid var(--purple);
}

.partition-1 td:first-child {
    border-left: 3px solid var(--green);
}

.partition-2 td:first-child {
    border-left: 3px solid var(--orange);
}

.partition-0 {
    background: var(--partition-a);
}

.partition-1 {
    background: var(--partition-b);
}

.partition-2 {
    background: var(--partition-c);
}

/* Legends */
.legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* Badges */
.badge-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid;
}

.badge-blue {
    color: var(--primary);
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.08);
}

.badge-purple {
    color: var(--purple);
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.08);
}

.badge-green {
    color: var(--green);
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.08);
}

.badge-orange {
    color: var(--orange);
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.08);
}

/* Callout */
.callout {
    background: rgba(139, 92, 246, 0.06);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-left: 3px solid var(--primary);
    border-radius: 0 8px 8px 0;
    padding: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.callout strong {
    color: var(--primary);
}

.callout i {
    color: var(--primary);
    font-size: 1.1rem;
}

/* Section */
.section {
    margin-bottom: 2rem;
}

.section-title {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Step Animation */
.steps-container {
    margin-top: 1rem;
}

.step-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.step-btn {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.step-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.step-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    font-weight: 600;
}

.step-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    animation: fadeSlideIn 0.25s ease;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-title {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.8rem;
}

.step-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1rem;
}

/* Frame Visualizer */
.frame-vis {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.frame-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    align-items: center;
    font-size: 0.8rem;
}

.frame-cell {
    min-width: 65px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
    transition: all 0.2s;
    flex-shrink: 0;
}

.frame-cell.current {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
}

.frame-cell.in-frame {
    background: var(--frame-bg);
    border-color: rgba(251, 191, 36, 0.4);
    color: var(--yellow);
}

.frame-cell.out-frame {
    opacity: 0.35;
}

.frame-label {
    min-width: 100px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: right;
    padding-right: 10px;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
    transition: border-color 0.2s, transform 0.2s;
}

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

.card-title {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-icon {
    font-size: 1.1rem;
}

.card-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Cheatsheet Grid */
.cheatsheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.cs-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.cs-header {
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.cs-body {
    padding: 12px 16px;
}

.cs-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.cs-row:last-child {
    border-bottom: none;
}

.cs-fn {
    color: var(--primary);
    font-weight: 600;
}

.cs-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: right;
    max-width: 140px;
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 1rem;
}

.search-bar input {
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    flex: 1;
}

.search-bar input:focus {
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-secondary);
}

.search-icon {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Performance Bar */
.perf-bar-wrap {
    background: var(--bg-secondary);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-top: 8px;
}

.perf-bar {
    height: 100%;
    border-radius: 4px;
    background: var(--gradient);
    transition: width 0.8s cubic-bezier(.22,1,.36,1);
}

/* Row Badge */
.row-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 8px;
}

.row-badge strong {
    color: var(--text-primary);
}

/* Playground */
.playground {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

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

.playground-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
}

.playground-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

textarea.code-input {
    width: 100%;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--code-text);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 1rem;
    resize: vertical;
    min-height: 150px;
    line-height: 1.7;
}

textarea.code-input:focus {
    outline: none;
    border-color: var(--primary);
}

textarea.code-input::placeholder {
    color: var(--text-secondary);
}

.run-btn {
    margin-top: 1rem;
    padding: 10px 20px;
    background: var(--gradient);
    border: none;
    border-radius: 8px;
    color: white;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.run-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.output-table-wrap {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    max-height: 300px;
    overflow: auto;
    font-size: 0.85rem;
}

.output-table-wrap table {
    min-width: 0;
}

/* Chips */
.chip-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.chip {
    padding: 5px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.12s;
}

.chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.chip.active-chip {
    border-color: var(--purple);
    color: var(--purple);
    background: rgba(139, 92, 246, 0.1);
}

/* Annotation */
.annotation-block {
    position: relative;
    border: 1px dashed var(--border2);
    border-radius: 8px;
    padding: 12px 14px 12px 40px;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    background: var(--bg-secondary);
}

.annotation-block::before {
    content: attr(data-num);
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.7rem;
}

.annotation-block strong {
    color: var(--text-primary);
}

/* Loading Dots */
.loading-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    animation: dotBounce 1.2s infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Tooltip */
[data-tip] {
    position: relative;
    cursor: help;
}

[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 50;
    box-shadow: 0 2px 8px var(--shadow);
}

[data-tip]:hover::after {
    opacity: 1;
}

/* Notification */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 16px 24px;
    background: var(--gradient);
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    transform: translateX(400px);
    transition: transform 0.4s ease;
    z-index: 1000;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification.show {
    transform: translateX(0);
}

.notification.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.notification.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.notification.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* ===========================
   ANIMATIONS
   =========================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */

@media (max-width: 968px) {
    .hero-h1 {
        font-size: 2.5rem;
    }
    
    .hero-para {
        font-size: 1rem;
    }
    
    .hero-stats {
        gap: 1rem;
    }
    
    .hero-stats span {
        padding: 6px 15px;
        font-size: 0.85rem;
    }
    
    .container {
        padding: 2rem 1rem;
    }
    
    .tab-nav {
        overflow-x: auto;
        padding: 0 1rem;
    }
    
    .tab {
        padding: 10px 16px;
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .hero-h1 {
        font-size: 2rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .hero-para {
        font-size: 0.95rem;
    }
    
    .hero-stats {
        gap: 0.8rem;
    }
    
    .hero-stats span {
        padding: 5px 12px;
        font-size: 0.8rem;
    }
    
    .container {
        padding: 1.5rem 1rem;
    }
    
    .sql-panel {
        padding: 1rem;
    }
    
    .content-area {
        padding: 1rem;
    }
    
    .sql-code {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    .frame-cell {
        min-width: 50px;
        padding: 4px 6px;
        font-size: 0.75rem;
    }
    
    .frame-label {
        min-width: 80px;
        font-size: 0.75rem;
    }
    
    .cookie-buttons {
        flex-direction: column;
    }
    
    .cookie-btn {
        width: 100%;
        justify-content: center;
    }
    
    .cookie-settings-buttons {
        flex-direction: column;
    }
    
    .cookie-settings-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .hero-h1 {
        font-size: 1.5rem;
    }
    
    .hero-para {
        font-size: 0.85rem;
    }
    
    .hero-stats {
        flex-direction: column;
        align-items: center;
    }
    
    .hero-stats span {
        width: 100%;
        max-width: 200px;
    }
    
    .container {
        padding: 1rem 0.8rem;
    }
    
    .sidebar-section {
        padding: 1rem;
    }
    
    .fn-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    .ds-btn {
        padding: 8px;
        font-size: 0.75rem;
    }
    
    .config-label {
        font-size: 0.8rem;
    }
    
    .sql-panel {
        padding: 0.8rem;
    }
    
    .panel-title {
        font-size: 0.75rem;
    }
    
    .panel-btn {
        padding: 4px 10px;
        font-size: 0.75rem;
    }
    
    .tab-nav {
        padding: 0 0.8rem;
    }
    
    .tab {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    
    .content-area {
        padding: 0.8rem;
    }
    
    table {
        font-size: 0.75rem;
    }
    
    thead th {
        padding: 8px 12px;
    }
    
    tbody td {
        padding: 8px 12px;
    }
    
    .callout {
        padding: 0.8rem;
        font-size: 0.8rem;
    }
    
    .section-title {
        font-size: 0.8rem;
    }
    
    .step-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .step-title {
        font-size: 1rem;
    }
    
    .step-desc {
        font-size: 0.8rem;
    }
    
    .card-title {
        font-size: 0.85rem;
    }
    
    .card-body {
        font-size: 0.8rem;
    }
    
    .cs-fn {
        font-size: 0.8rem;
    }
    
    .cs-desc {
        font-size: 0.75rem;
    }
    
    .playground-panel {
        padding: 1rem;
    }
    
    textarea.code-input {
        padding: 0.8rem;
        font-size: 0.8rem;
    }
    
    .run-btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }
    
    .output-table-wrap {
        padding: 0.8rem;
    }
    
    .notification {
        left: 10px;
        right: 10px;
        width: calc(100% - 20px);
        transform: translateY(-100px);
    }
    
    .notification.show {
        transform: translateY(0);
    }
}