:root {
    /* IBM Quantum Composer Colors */
    --ibm-red: #FA4D56;
    --ibm-purple: #6929C4;
    --ibm-blue: #0F62FE;
    --ibm-teal: #007D79;
    --ibm-light-blue: #1192E8;
    --ibm-green: #198038;
    --ibm-orange: #FF832B;
    --ibm-grey: #525252;
    --ibm-light-grey: #D1D1D1;
    --ibm-bg: #F8FAFC;

    /* Legacy colors */
    --primary: #4F46E5;
    --primary-dark: #3730A3;
    --secondary: #7C3AED;
    --success: #198038;
    --danger: #FA4D56;
    --dark: #0F172A;
    --light: #F8FAFC;
    --border: #E2E8F0;

    /* Modern Design Tokens */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-std: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-blur: blur(12px);
}

/* Global Heading Styles */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Poppins', sans-serif;
    color: var(--dark);
    line-height: 1.2;
    margin-bottom: 0.5em;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fbfcfe;
    min-height: 100vh;
    color: var(--dark);
    overflow-x: hidden;
    position: relative;
    letter-spacing: -0.01em;
}

#canvas-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    overflow-x: hidden;
}



/* Header Navigation */
.header {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
    padding: 12px 32px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    box-shadow: var(--shadow-sm);
    margin-bottom: 32px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-center {
    display: flex;
    gap: 32px;
}

.header-right {
    display: flex;
    justify-content: flex-end;
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
    line-height: 1;
}

.subtitle {
    color: #6b7280;
    font-size: 0.85rem;
    font-weight: 400;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-icon i {
    width: 24px;
    height: 24px;
}

/* Nav Link Styles */
.nav-link {
    text-decoration: none;
    color: #4b5563;
    font-weight: 500;
    font-size: 1rem;
    padding: 8px 0;
    position: relative;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--ibm-blue);
}

.nav-link.active {
    color: var(--ibm-blue);
    font-weight: 600;
}

.nav-link.active::after {
    content: '';
    display: block;
    width: 100%;
    height: 2px;
    background: var(--ibm-blue);
    position: absolute;
    bottom: 0;
    left: 0;
    border-radius: 2px;
}


/* Main Sections */
main {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
    overflow-x: hidden;
}

section {
    background: white;
    border-radius: var(--radius-md);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    max-width: 100% !important;
    overflow: hidden !important;
    transition: var(--transition-std);
}

section:hover {
    box-shadow: var(--shadow-lg);
}

section h2 {
    font-size: 1.125rem;
    margin-bottom: 16px;
    color: var(--dark);
    font-weight: 600;
}

/* Palette Section Layout */
.palette-section {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    /* Prevent section itself from scrolling */
}

.palette-section h2 {
    flex-shrink: 0;
    margin-bottom: 16px;
}

/* Scrollable Container for Gates */
.gate-palette-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    /* Space for scrollbar */
    /* Custom Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.gate-palette-scroll::-webkit-scrollbar {
    width: 6px;
}

.gate-palette-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.gate-palette-scroll::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 20px;
}

/* Gate Palette Sections */
.gate-category {
    margin-bottom: 24px;
}

.gate-category:last-child {
    margin-bottom: 12px;
}

.gate-category h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    font-family: 'Poppins', sans-serif;
}

.gate-group-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* Base Gate Button Style */
.gate-btn {
    padding: 0 12px;
    min-width: 50px;
    width: auto;
    height: 46px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    cursor: grab;
    transition: var(--transition-fast);
    user-select: none;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', sans-serif;
    position: relative;
    white-space: nowrap;
}

.gate-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    filter: brightness(1.1);
}

.gate-btn:active {
    cursor: grabbing;
    transform: scale(0.95);
}

/* --- Accent Colors for Gate Groups --- */

/* Basis & Pauli (Blue) */
.gate-btn[data-gate="I"],
.gate-btn[data-gate="X"],
.gate-btn[data-gate="Y"],
.gate-btn[data-gate="Z"] {
    background: #3b82f6;
}

/* Hadamard (Orange) */
.gate-btn[data-gate="H"] {
    background: #f97316;
}

/* Phase Gates (Purple) */
.gate-btn.phase {
    background: #a855f7;
}

/* Rotation/Parametric (Pink) */
.gate-btn.rotation {
    background: #ec4899;
}

/* Two Qubit (Indigo) */
.gate-btn.two-qubit {
    background: #6366f1;
}

/* Multi Qubit (Teal) */
.gate-btn.multi-qubit {
    background: #14b8a6;
}

/* Measure (Slate) */
.gate-btn.measure {
    background: #64748b;
    border: 1px solid #94a3b8;
}

/* Rotation Controls specific styling */
.rotation-controls {
    margin-top: 12px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rotation-controls label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4b5563;
}

.rotation-controls input {
    width: 100%;
    padding: 6px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: 'Poppins', sans-serif;
    text-align: center;
}

.preset-angles {
    display: flex;
    justify-content: space-between;
    gap: 4px;
}

.preset-btn {
    flex: 1;
    padding: 4px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    color: #4b5563;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #111827;
}

.gate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.gate-btn:active {
    cursor: grabbing;
}

/* IBM Color Coding */
.gate-btn[data-gate="H"] {
    background: var(--ibm-red);
}

.gate-btn.rotation {
    background: var(--ibm-orange);
}

.gate-btn.phase {
    background: var(--ibm-teal);
}

.gate-btn.two-qubit {
    background: var(--ibm-light-blue);
}

.gate-btn.multi-qubit {
    background: var(--ibm-purple);
}

.gate-btn.measure {
    background: var(--ibm-grey);
}

.gate-btn.selected {
    box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.4);
}

.gate-btn.dragging {
    opacity: 0.5;
}

/* Circuit Builder - IBM Composer Style */
.circuit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.controls {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-shrink: 0;
}

.controls label {
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
}

.controls input[type="number"] {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
    width: 60px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
}

.circuit-canvas {
    background: #FAFAFA;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 40px 0;
    min-height: 400px;
    position: relative;
    width: max-content;
    min-width: 100%;
    overflow: visible;
}

.qubit-wire {
    display: flex;
    align-items: center;
    margin-bottom: 55px;
    position: relative;
    min-height: 50px;
    width: 100%;
}

.qubit-wire:last-child {
    margin-bottom: 0;
}

.qubit-label {
    font-weight: 700;
    color: var(--dark);
    min-width: 65px;
    font-size: 0.85rem;
    font-family: 'Poppins', sans-serif;
    text-align: center;
    position: sticky;
    left: 0;
    background: rgba(250, 250, 250, 0.98);
    backdrop-filter: blur(8px);
    z-index: 100;
    padding: 15px 10px;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.auto-measure-indicator {
    position: sticky;
    right: 0;
    background: rgba(250, 250, 250, 0.98);
    backdrop-filter: blur(8px);
    padding: 0 15px;
    z-index: 100;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    min-width: 65px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    transition: all 0.2s;
    flex-shrink: 0;
}

.auto-measure-indicator:hover {
    color: #4F46E5;
    background: #f1f5f9;
}

.wire-line {
    flex: 1;
    height: 40px;
    /* Increased interactive height */
    position: relative;
    width: 100%;
    min-width: 100%;
    display: flex;
    align-items: center;
    gap: 50px;
    background: transparent;
    /* Container is transparent */
}

/* The actual visual line */
.wire-line::before {
    content: '';
    position: absolute;
    left: 0;
    right: -5000px;
    height: 1px;
    background: var(--ibm-light-grey);
    z-index: 0;
    pointer-events: none;
    top: 50%;
    transform: translateY(-50%);
}

/* Single-Qubit Gates - IBM Style */
.gate-slot {
    position: relative;
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    background: var(--ibm-purple);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
    font-family: 'Poppins', sans-serif;
    z-index: 5;
    overflow: visible;
}

/* Expansion of hit-area for much easier dropping - Bridge the 50px gaps */
.gate-slot::after {
    content: '';
    position: absolute;
    top: -20px;
    bottom: -20px;
    left: -26px;
    /* Bridge the 50px gap (25px each side + 1px overlap) */
    right: -26px;
    background: transparent;
    z-index: -1;
}

.gate-slot:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* IBM Color Coding for Gates */
.gate-slot[data-gate="H"] {
    background: var(--ibm-red);
}

.gate-slot[data-gate="X"],
.gate-slot[data-gate="Y"],
.gate-slot[data-gate="Z"] {
    background: var(--ibm-green);
}

.gate-slot[data-gate="RX"],
.gate-slot[data-gate="RY"],
.gate-slot[data-gate="RZ"] {
    background: var(--ibm-orange);
}

.gate-slot[data-gate="S"],
.gate-slot[data-gate="T"],
.gate-slot[data-gate="SDG"],
.gate-slot[data-gate="TDG"],
.gate-slot[data-gate="SX"] {
    background: #007D79;
}

.gate-slot[data-gate="MEASURE"],
.gate-slot[data-gate="RESET"],
.gate-slot[data-gate="BARRIER"],
.gate-slot[data-gate="CONTROL"],
.gate-slot[data-gate="IF"] {
    background: #525252;
    /* Professional Grey/Slate */
}

.gate-param {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: transparent;
    color: #94a3b8;
    padding: 2px 0;
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 1;
    visibility: visible;
    transition: all 0.2s ease;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    margin-top: 4px;
}

.gate-slot:hover .gate-param {
    opacity: 1;
    visibility: visible;
}

.gate-slot.empty {
    background: transparent;
    border: 2px dashed rgba(198, 198, 198, 0.4);
    border-radius: 4px;
    width: 50px;
    height: 42px;
    min-width: 50px;
    opacity: 0.6;
    font-size: 1.125rem;
    color: #A8A8A8;
    font-weight: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.gate-slot.empty:hover {
    opacity: 1;
    border-color: var(--ibm-blue);
    border-style: solid;
    color: var(--ibm-blue);
    background: rgba(15, 98, 254, 0.05);
    box-shadow: 0 0 0 2px rgba(15, 98, 254, 0.1);
}

/* Precision Dot for Controlled Gates */
.gate-dot {
    width: 12px;
    height: 12px;
    background: var(--ibm-light-blue);
    border-radius: 50%;
    z-index: 30;
}

/* Control dot for controlled gates - IBM Style */
.control-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--ibm-light-blue);
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    transition: all 0.15s;
    z-index: 2;
}

.control-dot:hover {
    transform: translateY(-50%) scale(1.3);
}

/* Target gate for CNOT - IBM Style */
.target-gate {
    position: absolute;
    min-width: 50px;
    height: 50px;
    background: white;
    border: 2px solid var(--ibm-light-blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 400;
    font-size: 1.75rem;
    color: var(--ibm-light-blue);
    cursor: pointer;
    transition: all 0.15s;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

.target-gate:hover {
    background: var(--ibm-light-blue);
    color: white;
    transform: translateY(-50%) scale(1.05);
}

/* SWAP X symbol - IBM Style */
.swap-x {
    position: absolute;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--ibm-light-blue);
    cursor: pointer;
    transition: all 0.15s;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

.swap-x:hover {
    transform: translateY(-50%) scale(1.2);
}

/* Connector lines - IBM Style */
.gate-connector {
    position: absolute;
    width: 1px;
    background: var(--ibm-light-blue);
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 1;
}

.wire-line.drag-over {
    background: var(--ibm-blue);
    height: 2px;
}

.gate-slot.drag-over {
    box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.3) !important;
    transform: translateY(-50%) scale(1.05) !important;
}

.circuit-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.circuit-footer label {
    font-weight: 600;
    font-size: 0.875rem;
}

.circuit-footer input {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 90px;
    font-size: 0.875rem;
    font-family: 'Poppins', sans-serif;
}

/* Buttons - IBM Style */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    /* Perfect radius */
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    /* Space between icon and text */
}

.btn-primary {
    background: var(--ibm-blue);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #E0E0E0;
    color: var(--dark);
}

.btn-secondary:hover {
    background: #C6C6C6;
}

/* Inputs & Form Elements */
input[type="text"],
input[type="number"],
select,
textarea {
    border-radius: 6px;
    /* Consistent radius */
    border: 1px solid var(--border);
    padding: 6px 12px;
    font-size: 0.875rem;
}

/* Results Panel */
.results-panel {
    min-height: 200px;
}

.placeholder {
    text-align: center;
    color: #8D8D8D;
    padding: 60px 20px;
    font-size: 0.875rem;
}

/* Editor Controls specific buttons */
.editor-controls .btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    height: 32px;
    /* Fixed compact height */
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#copy-qasm-btn {
    background: white;
    border: 1px solid #d1d5db;
    color: #374151;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#copy-qasm-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111827;
}

#apply-qasm-btn {
    background: var(--ibm-blue);
    color: white;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#apply-qasm-btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.result-bar {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
}

.result-label {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    min-width: 70px;
    font-size: 0.875rem;
}

.result-bar-container {
    flex: 1;
    background: var(--light);
    border-radius: 4px;
    height: 28px;
    position: relative;
    overflow: hidden;
}

.result-bar-fill {
    height: 100%;
    background: var(--ibm-blue);
    border-radius: 4px;
    transition: width 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
}

/* Examples Section Upgrade */
.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    grid-auto-rows: 1fr;
    gap: 20px;
    padding: 10px 4px;
}

.example-category-head {
    grid-column: 1 / -1;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #94a3b8;
    font-weight: 700;
    margin-top: 32px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.example-category-head::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #f1f5f9;
}

.example-category-head:first-child {
    margin-top: 0;
}

.example-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    height: 100%;
    min-height: 110px;
}

.example-btn:hover {
    transform: translateY(-4px);
    border-color: #3b82f6;
    box-shadow: 0 12px 20px -8px rgba(59, 130, 246, 0.12);
    background: #f8faff;
}

.example-icon-box {
    width: 44px;
    height: 44px;
    background: #eff6ff;
    color: #3b82f6;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.example-btn:hover .example-icon-box {
    background: #3b82f6;
    color: #ffffff;
    transform: rotate(10deg) scale(1.1);
}

.example-btn-text {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.example-btn-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
    transition: color 0.3s ease;
}

.example-btn:hover .example-btn-title {
    color: #1e40af;
}

.example-btn-desc {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

/* Arrow indicator on hover */
.example-btn-arrow {
    font-size: 1.2rem;
    color: #3b82f6;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
    margin-left: auto;
}

.example-btn:hover .example-btn-arrow {
    opacity: 1;
    transform: translateX(0);
}



/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 20px 0;
    text-align: center;
    color: #525252;
    font-size: 0.8125rem;
}

.footer p {
    margin: 4px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .circuit-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .circuit-footer {
        flex-direction: column;
        gap: 12px;
    }
}

/* Main Layout - Vertical Stack (Mobile First) */
.container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1400px;
    /* Increased for dashboard */
    margin: 0 auto;
}

/* Dashboard Grid Layout (Desktop) */
/* Dashboard Grid Layout (Desktop) - Viewport Fit */
@media (min-width: 1024px) {

    /* Main container adapts to content, but Lab Grid is sized to viewport */
    .container {
        display: block;
        max-width: 100%;
        padding: 0 16px;
        margin: 0;
    }

    /* The Lab Grid fits within one screen (approx 85vh) */
    .lab-grid {
        display: grid;
        grid-template-columns: 280px 1fr 1fr 340px;
        grid-template-rows: minmax(400px, 55vh) minmax(280px, 35vh);
        /* Increased chart row and added minmax for safety */
        gap: 16px;
        align-items: stretch;
        margin-bottom: 60px;
        height: auto;
    }

    /* Assign Areas */
    .palette-section {
        grid-area: 1 / 1 / 2 / 2;
    }

    .circuit-section {
        grid-area: 1 / 2 / 2 / 4;
    }

    .editor-section {
        grid-area: 1 / 4 / 2 / 5;
    }

    .probability-section {
        grid-area: 2 / 1 / 3 / 3;
    }

    .results-section {
        grid-area: 2 / 3 / 3 / 5;
    }

    /* General Section Styling for Grid Fit */
    section {
        width: 100%;
        margin-bottom: 0;
        height: 100%;
        overflow: hidden !important;
        /* Vital for containing inner scrolls */
        display: flex;
        flex-direction: column;
        padding: 16px;
        /* Tighter padding */
    }

    section h2 {
        font-size: 1rem;
        margin-bottom: 12px;
        flex-shrink: 0;
    }

    /* Reset styling for Example Section which is outside the main lab grid */
    #learn-quantum section,
    .examples-section {
        height: auto !important;
        overflow: visible !important;
        display: block;
    }

    #learn-quantum .examples-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        grid-auto-rows: 1fr;
        gap: 20px;
    }

    /* 1. Palette - Scrollable Grid */
    .gate-grid {
        overflow-y: auto;
        flex: 1;
        align-content: start;
        padding-right: 4px;
        /* Space for scrollbar */
    }

    /* 2. Circuit - Flexible Canvas */
    .circuit-section {
        display: flex;
        flex-direction: column;
    }

    .circuit-header {
        margin-bottom: 12px;
        padding-bottom: 12px;
        flex-shrink: 0;
    }

    #circuit-container {
        flex: 1;
        /* Take remaining height */
        max-height: none !important;
        min-height: 0;
        overflow: auto;
        border: 1px solid #e5e7eb;
        border-radius: 4px;
        background: #fafafa;
    }

    .circuit-canvas {
        min-height: 100% !important;
        height: auto !important;
        border: none;
        padding: 20px;
        overflow: visible !important;
        /* Fixed double scroll */
    }

    /* 3. Editor - Full Height */
    .editor-section {
        padding: 16px;
    }

    .editor-section>div:nth-child(2) {
        /* Textarea wrapper */
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    #qasm-editor {
        flex: 1;
        /* Fill vertical space */
        height: 100% !important;
        resize: none;
        /* Disable manual resize */
    }

    /* 4. Probability - Scrolled Content */
    .probability-section {
        min-height: 0 !important;
    }

    #probability-chart {
        flex: 1;
        min-height: 0 !important;
        margin-top: 0;
        padding: 0;
        /* Removed padding to give chart more space */
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    #probability-chart::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari */
    }

    /* 5. Results */
    .results-section {
        min-height: 0 !important;
    }

    #results-panel {
        flex: 1;
        overflow: hidden;
        min-height: 0;
        padding: 0;
        /* Removed padding */
        display: flex;
        flex-direction: column;
    }
}


/* Ensure correct order for mobile fallback */
.palette-section {
    order: 1;
}

.circuit-section {
    order: 2;
}

.probability-section {
    order: 3;
}

.results-section {
    order: 4;
}

.editor-section {
    order: 5;
}

.examples-section {
    order: 6;
}

.editor-section {
    order: 5;
}

.examples-section {
    order: 6;
}

/* Results and Probability Section Specifics */
.probability-section,
.results-section {
    min-height: 400px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    display: flex !important;
    flex-direction: column;
}

/* Probability Chart Styles (Horizontal / IBM Look) */
#probability-chart,
#results-panel {
    flex: 1;
    width: 100%;
    background: #ffffff;
    border-radius: 8px;
    padding: 0;
    /* Cleaned up to allow child containers to take full control */
    margin-top: 8px;
    border: 1px solid #e2e8f0;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

#probability-chart::-webkit-scrollbar,
#results-panel::-webkit-scrollbar {
    display: none;
}

/* Axis Labels (Top) */
/* Vertical Probability Chart Styles */
.chart-container-v {
    display: grid;
    grid-template-columns: 55px 1fr;
    grid-template-rows: 1fr;
    position: relative;
    padding: 30px 24px 20px 10px;
    /* Reduced from 60px */
    height: 100%;
    width: 100%;
    min-height: 280px;
    background: transparent;
    box-sizing: border-box;
    gap: 0;
    user-select: none;
    /* Prevent text selection during drag-to-zoom */
}

.chart-y-axis-v {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    height: calc(100% - 80px);
    /* 100% minus (30px top + 50px bottom space) */
    position: relative;
    padding-right: 12px;
    box-sizing: border-box;
    margin-top: 24px;
    /* 30px buffer minus half label offset (6px) */
    margin-bottom: -6px;
    z-index: 10;
}

.chart-y-axis-v div {
    height: 12px;
    /* Fixed height for flex centering */
    font-size: 0.65rem;
    color: #475569;
    /* Slightly darker for better contrast */
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
    line-height: 1;
}

/* Specific offsets for text centering if needed, though flex + height 12px handles it */
.chart-y-axis-v div:nth-child(1),
.chart-y-axis-v div:nth-child(2),
.chart-y-axis-v div:nth-child(3),
.chart-y-axis-v div:nth-child(4),
.chart-y-axis-v div:nth-child(5) {
    position: relative;
    top: auto;
    transform: none;
}

.chart-area-v {
    grid-column: 2;
    position: relative;
    height: 100%;
    border-left: 2px solid #e2e8f0;
    /* Subtle UI-matched Y-axis */
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: visible;
    /* Custom Scrollbar Styles at the very bottom */
    scrollbar-width: auto;
}

/* Specific override to remove scrolling in probabilities box */
#probability-chart .chart-area-v,
.nb-chart-container .chart-area-v {
    overflow-x: hidden !important;
}

#probability-chart .chart-bars-container-v,
.nb-chart-container .chart-bars-container-v {
    width: 100% !important;
    padding: 0 5px !important;
    gap: 10px !important;
}

#probability-chart .bar-wrapper-v,
.nb-chart-container .bar-wrapper-v {
    min-width: 0 !important;
    flex: 1;
}

#probability-chart .bar-track-v {
    width: 60%;
    min-width: 4px;
}


.chart-area-v::-webkit-scrollbar {
    height: 10px;
    /* Thicker, easier to see */
}

.chart-area-v::-webkit-scrollbar-track {
    background: #f8fafc;
    border-radius: 10px;
}

.chart-area-v::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
    border: 2px solid #f8fafc;
}

.chart-area-v::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* We need to make sure the absolute grid spans the same width as the flex bars */
.chart-grid-v {
    position: absolute;
    top: 30px;
    /* Reduced buffer from 50px */
    left: 0;
    width: 100%;
    min-width: 100%;
    height: calc(100% - 80px);
    /* 100% minus (30px top + 50px bottom) */
    border-bottom: 2px solid #e2e8f0;
    pointer-events: none;
    box-sizing: border-box;
    z-index: 1;
}

.grid-line-v {
    position: absolute;
    width: 100%;
    min-width: 100%;
    height: 1px;
    background: #e2e8f0;
    left: 0;
}

.grid-line-v:nth-child(1) {
    top: 0%;
}

.grid-line-v:nth-child(2) {
    top: 25%;
}

.grid-line-v:nth-child(3) {
    top: 50%;
}

.grid-line-v:nth-child(4) {
    top: 75%;
}

.grid-line-v:nth-child(5) {
    top: 100%;
}


.chart-bars-container-v {
    position: relative;
    top: 0;
    left: 0;
    width: max-content;
    min-width: 100%;
    height: 100%;
    /* Full height to contain labels */
    display: flex;
    justify-content: center;
    /* Center bars when possible */
    align-items: stretch;
    padding: 0 10px;
    /* Aligned padding */
    z-index: 5;
    gap: 30px;
    /* Balanced spacing */
    overflow: visible;
}

.bar-wrapper-v {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-start;
    flex: 0 0 auto;
    /* Allow items to determine size with gap */
    position: relative;
    box-sizing: border-box;
    min-width: 65px;
}

.bar-track-v {
    width: 24px;
    height: calc(100% - 80px);
    /* Matches new grid height */
    margin-top: 30px;
    /* Reduced push-down */
    background: rgba(15, 98, 254, 0.03);
    border-radius: 4px 4px 0 0;
    position: relative;
    display: flex;
    align-items: flex-end;
    margin-left: 0;
    margin-right: 0;
    padding: 0;
    box-sizing: border-box;
    z-index: 2;
    overflow: visible;
}

.bar-fill-v {
    width: 100%;
    background: #4F46E5;
    border-radius: 4px 4px 0 0;
    /* Restored rounding */
    transition: height 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
    position: relative;
    min-height: 0;
    box-sizing: border-box;
    /* border-right removed for solid look with spacing */
}

.bar-fill-v:hover {
    filter: brightness(1.1);
    cursor: pointer;
}

.bar-label-v {
    height: 35px;
    /* Set height for labels */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #475569;
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
    white-space: nowrap;
}

/* Scrollbar Cushion Element */
.bar-wrapper-v::after {
    content: '';
    display: block;
    height: 15px;
    /* Matches scrollbar area */
    width: 100%;
}

/* Nudge above vertical bars - appears on hover, light themed */
.bar-value-v {
    position: absolute;
    bottom: calc(100% + 5px);
    /* Positioned cleanly above the color bar */
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: transparent;
    /* Box removed to match UI */
    color: #1e293b;
    /* High-contrast dark text */
    padding: 0;
    font-size: 0.75rem;
    font-weight: 800;
    /* Extra bold for visibility without a box */
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    pointer-events: none;
    text-align: center;
    z-index: 2000;
    box-shadow: none;
}

/* Tooltip triangle pointer removed */


/* Tooltip follows the bar height: Show on track hover but position relative to fill */
.bar-track-v:hover .bar-value-v {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* --- Interactive Zoom & Selection Styles --- */

.chart-selection-box {
    position: absolute;
    top: 30px;
    /* Aligned with grid top */
    height: calc(100% - 80px);
    /* Aligned with grid height */
    background: rgba(79, 70, 229, 0.1);
    border: 1.5px dashed #4F46E5;
    pointer-events: none;
    z-index: 100;
    display: none;
    border-radius: 4px;
}

.reset-zoom-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #4F46E5;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.reset-zoom-btn:hover {
    background: #f8fafc;
    border-color: #4F46E5;
    transform: translateY(-1px);
}

.reset-zoom-btn:active {
    transform: translateY(0);
}

.reset-zoom-btn::before {
    content: '↺';
    font-size: 0.9rem;
}


/* Better positioning for the chart columns */
.bar-wrapper-v {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    flex: 0 0 auto;
    position: relative;
    box-sizing: border-box;
    min-width: 60px;
}

/* General Polish */
body {
    background-color: #f3f4f6;
}

section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    margin-bottom: 0;
    /* Let flex gap handle spacing */
    width: 100%;
}

/* Circuit Canvas visibility fix */
/* consolidated above */

/* Button & Input Polish */
.btn,
.gate-btn,
input,
select,
textarea {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active,
.gate-btn:active {
    transform: scale(0.98);
}

/* Force cache clear - Mon Feb  9 22:52:48 IST 2026 */

/* Expand Button */
.expand-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    transition: all 0.2s;
    padding: 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.expand-btn:hover {
    color: var(--dark);
    background-color: #f3f4f6;
    transform: scale(1.1);
}

/* Modal Overlay for Expanded View */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 15000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.expanded-content {
    background: white;
    width: 95%;
    height: 92%;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    position: relative;
    padding: 40px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.expanded-content h2 {
    margin-bottom: 24px;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--dark);
    letter-spacing: -0.02em;
}

/* Expanded Chart Enhancements */
.expanded-content .chart-container-v {
    height: 100% !important;
    flex: 1;
    min-height: 400px;
    padding-bottom: 70px;
    /* More room for x-axis labels */
    margin-top: 25px;
    width: 100% !important;
    max-width: none !important;
}

.expanded-content .chart-bars-container-v {
    max-width: none !important;
    padding: 20px 100px 0 100px;
    /* Massively increased breathing room */
}

/* --- Zoom Guide Preview --- */
.zoom-hint-banner {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    padding: 8px 20px;
    border-radius: 50px;
    border: 1.5px solid #4F46E5;
    color: #4F46E5;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.2);
    animation: fadeInOut 4s forwards;
    pointer-events: none;
}

.zoom-demo-pointer {
    position: absolute;
    width: 24px;
    height: 24px;
    background: rgba(79, 70, 229, 0.5);
    border: 2px solid white;
    border-radius: 50%;
    z-index: 2002;
    pointer-events: none;
    animation: demoDrag 3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    display: none;
    /* Controlled by JS */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.zoom-demo-box {
    position: absolute;
    top: 100px;
    height: calc(100% - 180px);
    background: rgba(79, 70, 229, 0.1);
    border: 2px dashed #4F46E5;
    z-index: 2001;
    pointer-events: none;
    animation: demoBoxGrow 3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}


@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    15% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    85% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

@keyframes demoDrag {
    0% {
        left: 35%;
        top: 60%;
        transform: scale(1);
        opacity: 0;
    }

    15% {
        opacity: 1;
        transform: scale(0.85);
        top: 55%;
    }

    60% {
        left: 60%;
        top: 55%;
        opacity: 1;
    }

    75% {
        opacity: 0;
        transform: scale(1);
    }

    100% {
        opacity: 0;
    }
}

@keyframes demoBoxGrow {

    0%,
    15% {
        left: 35%;
        width: 0;
        opacity: 0;
    }

    16% {
        opacity: 1;
    }

    60% {
        left: 35%;
        width: 25%;
        opacity: 1;
    }

    75% {
        opacity: 0;
    }

    100% {
        opacity: 0;
    }
}


.expanded-content .bar-track-v {
    width: 42px;
    /* Thicker bars in full screen */
    border-radius: 6px 6px 0 0;
}

.expanded-content .bar-fill-v {
    border-radius: 6px 6px 0 0;
}

.expanded-content .bar-label-v {
    font-size: 0.9rem;
    bottom: -40px;
    font-weight: 700;
}

.expanded-content .chart-y-axis-v {
    font-size: 0.85rem;
    width: 55px;
    padding-right: 15px;
}

/* Results Panel Expansion Fix */
.expanded-content #results-panel,
.expanded-content .nb-chart-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.expanded-content .results-chart-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

.expanded-content .results-chart-container .chart-container-v {
    flex: 1;
}

/* Close Button */
.close-modal-btn {
    position: absolute;
    top: 25px;
    right: 25px;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #64748b;
    z-index: 100;
}

.close-modal-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: rotate(90deg);
}

@keyframes scaleUp {
    from {
        transform: scale(0.96);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Astra Lab Tour Premium Styles */
.btn-help {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(79, 70, 229, 0.05);
    border: 1px solid rgba(79, 70, 229, 0.1);
    padding: 6px 14px;
    border-radius: 8px;
    color: #4F46E5;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-help:hover {
    background: #4F46E5;
    color: white;
    /* removed glow */
    transform: translateY(-1px);
}

.astra-tour-popover {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border-radius: 16px !important;
    padding: 24px !important;
    max-width: 320px !important;
}

.driver-popover-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 700 !important;
    font-size: 1.1rem !important;
    color: #111827 !important;
    margin-bottom: 8px !important;
}

.driver-popover-description {
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem !important;
    color: #4b5563 !important;
    line-height: 1.6 !important;
}

.driver-popover-arrow {
    border-color: rgba(255, 255, 255, 0.95) !important;
}

.driver-popover-navigation-btns button {
    font-family: 'Poppins', sans-serif !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    padding: 6px 16px !important;
    text-shadow: none !important;
    transition: all 0.2s !important;
}

.driver-popover-next-btn {
    background: #4F46E5 !important;
    color: white !important;
    border: none !important;
}

.driver-popover-prev-btn {
    background: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #e2e8f0 !important;
}

.driver-popover-close-btn {
    color: #94a3b8 !important;
}

.driver-popover-progress-text {
    font-size: 0.75rem !important;
    color: #94a3b8 !important;
    margin-top: 12px !important;
}


/* Notification System Enhancements */
.notification-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.notification-toast {
    min-width: 320px;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 14px;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s ease;
}

.notification-toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: #3b82f6;
}

.notification-toast.error::before {
    background: #ef4444;
}

.notification-toast.success::before {
    background: #10b981;
}

.notification-toast.warning::before {
    background: #f59e0b;
}

.notification-toast.hide {
    opacity: 0;
    transform: translateX(40px) scale(0.95);
}

.notification-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    transition: all 0.2s;
}

.notification-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #4b5563;
}

/* Ultra-Premium Modal System */
.astra-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.astra-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.astra-modal-window {
    background: #ffffff;
    width: 95%;
    max-width: 480px;
    border-radius: 28px;
    padding: 0;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(40px);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.astra-modal-overlay.active .astra-modal-window {
    transform: scale(1) translateY(0);
}

.astra-modal-header {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    padding: 40px 40px 20px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.astra-modal-icon {
    width: 72px;
    height: 72px;
    background: #ffffff;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.06);
    border: 1px solid #f1f5f9;
}

.astra-modal-icon i {
    width: 36px;
    height: 36px;
}

.astra-modal-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.02em;
}

.astra-modal-body {
    padding: 0 40px 40px 40px;
    font-size: 1.05rem;
    line-height: 1.6;
    color: #64748b;
    text-align: center;
}

.astra-modal-footer {
    padding: 0 40px 40px 40px;
    display: flex;
    gap: 16px;
}

.astra-btn {
    flex: 1;
    padding: 18px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.01em;
}

.modal-close-x {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #ffffff;
    border: 1.5px solid #f1f5f9;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 100;
}

.modal-close-x:hover {
    color: #ef4444;
    border-color: #fee2e2;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.1);
}

.astra-btn-primary {
    background: #0f172a;
    color: white;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
}

.astra-btn-primary:hover {
    background: #1e293b;
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(15, 23, 42, 0.3);
}

.astra-btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

.astra-btn-secondary:hover {
    background: #e2e8f0;
    color: #1e293b;
    transform: translateY(-2px);
}

/* Success/Error Colors */
.type-success .astra-modal-icon {
    background: #ecfdf5;
    border-color: #10b981;
    color: #10b981;
}

.type-error .astra-modal-icon {
    background: #fef2f2;
    border-color: #ef4444;
    color: #ef4444;
}

.type-warning .astra-modal-icon {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #f59e0b;
}

.type-info .astra-modal-icon {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #3b82f6;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* Drag and Drop Visual Feedback */
.gate-slot.moving {
    opacity: 0.5;
    cursor: grabbing !important;
    transform: scale(0.95);
    transition: all 0.2s ease;
}

/* Premium Logout Button CSS */
.premium-logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    border: 1.5px solid #fecaca;
    color: #ef4444;
    padding: 10px 20px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.05);
}

.premium-logout-btn:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.2);
}

.premium-logout-btn:active {
    transform: scale(0.96);
}

.premium-logout-btn i {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.premium-logout-btn:hover i {
    transform: translateX(2px);
}

.gate-slot[draggable="true"] {
    cursor: grab;
}

/* Integrated navigation button styling inherited from .btn-secondary */

/* Ensure circuit section can host the absolute button */
.circuit-section {
    position: relative !important;
}

/* ========================================================================= */
/* Astra UI Unified Modal & Notifications CSS (Premium)                      */
/* ========================================================================= */

.notification-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.notification-toast {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 320px;
    max-width: 420px;
    pointer-events: auto;
    animation: toast-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: top right;
}

.notification-toast.hide {
    animation: toast-out 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toast-in {
    0% { opacity: 0; transform: translateX(40px) scale(0.95); }
    100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
    0% { opacity: 1; transform: translateX(0) scale(1); }
    100% { opacity: 0; transform: translateX(40px) scale(0.95); }
}

.notification-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-icon.info { background: #eff6ff; color: #3b82f6; }
.notification-icon.success { background: #f0fdf4; color: #10b981; }
.notification-icon.error { background: #fef2f2; color: #ef4444; }
.notification-icon.warning { background: #fffbeb; color: #f59e0b; }

.notification-content {
    flex: 1;
    font-size: 0.9rem;
    color: #1e293b;
    font-weight: 500;
    line-height: 1.4;
    font-family: 'Outfit', 'Poppins', sans-serif;
}

.notification-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notification-close:hover { background: #f1f5f9; color: #0f172a; }

/* ── Modals ── */
.astra-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 20px;
}

.astra-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.astra-modal-overlay.fade-out {
    opacity: 0;
}

.astra-modal-window {
    background: #ffffff;
    border-radius: 24px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0,0,0,0.02);
    position: relative;
    transform: translateY(20px) scale(0.96);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.astra-modal-overlay.active .astra-modal-window {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.modal-close-x {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f8fafc;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}
.modal-close-x:hover { background: #f1f5f9; color: #0f172a; transform: rotate(90deg); }

.astra-modal-header {
    padding: 36px 32px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.astra-modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    box-shadow: 0 0 0 8px rgba(0,0,0,0.03);
    background: #f8fafc;
}
.astra-modal-icon i, .astra-modal-icon svg { width: 32px; height: 32px; }

.astra-modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
    font-family: 'Outfit', 'Poppins', sans-serif;
}

.astra-modal-body {
    padding: 0 32px 32px;
    text-align: center;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.6;
    font-family: 'Outfit', 'Poppins', sans-serif;
}
.astra-modal-body p { margin-bottom: 0; }

.astra-modal-footer {
    padding: 24px 32px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.astra-btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Outfit', 'Poppins', sans-serif;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1;
}

.astra-btn.astra-btn-secondary {
    background: #ffffff;
    color: #475569;
    border: 1px solid #cbd5e1;
}
.astra-btn.astra-btn-secondary:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.astra-btn.astra-btn-primary {
    background: var(--astra-primary, #4F46E5);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
.astra-btn.astra-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.3);
    filter: brightness(1.1);
}

.type-error .astra-btn-primary { background: #ef4444; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25); }
.type-error .astra-btn-primary:hover { box-shadow: 0 8px 16px rgba(239, 68, 68, 0.3); }

.type-success .astra-btn-primary { background: #10b981; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25); }
.type-success .astra-btn-primary:hover { box-shadow: 0 8px 16px rgba(16, 185, 129, 0.3); }

.type-warning .astra-btn-primary { background: #f59e0b; box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25); }
.type-warning .astra-btn-primary:hover { box-shadow: 0 8px 16px rgba(245, 158, 11, 0.3); }

.astra-modal-form-group { margin-bottom: 20px; text-align: left; } .astra-modal-label { display: block; font-size: 0.85rem; font-weight: 700; color: #1e293b; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.025em; } .astra-modal-body input, .astra-modal-body select, .astra-modal-body textarea { width: 100%; padding: 12px 16px; border: 1.5px solid #e2e8f0; border-radius: 12px; font-size: 0.95rem; font-family: inherit; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); background: #f8fafc; color: #0f172a; } .astra-modal-body input:focus, .astra-modal-body select:focus, .astra-modal-body textarea:focus { outline: none; border-color: var(--astra-primary, #4F46E5); background: #ffffff; box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1); transform: translateY(-1px); }
