/* ═══════════════════════════════════════════════════════════════
   PointVis — Premium Dark UI
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Libre+Baskerville:ital@0;1&display=swap');

:root {
    /* ── Brand Palette ── */
    --bg:            #060810;
    --surface-0:     rgba(8, 12, 24, 0.95);
    --surface-1:     rgba(14, 20, 38, 0.9);
    --surface-2:     rgba(20, 28, 52, 0.7);
    --border-dim:    rgba(255,255,255,0.07);
    --border-bright: rgba(255,255,255,0.14);
    --border-accent: rgba(99,179,237,0.35);

    /* ── Text ── */
    --text-1: #f0f4ff;
    --text-2: #8b9dc3;
    --text-3: #4a5a82;

    /* ── Accent / Sky blue ── */
    --accent:       #3b9eff;
    --accent-glow:  rgba(59,158,255,0.28);
    --accent-soft:  rgba(59,158,255,0.12);
    --accent-mid:   rgba(59,158,255,0.22);

    /* ── Violet accent (secondary) ── */
    --violet:       #8b5cf6;
    --violet-soft:  rgba(139,92,246,0.15);

    /* ── Danger ── */
    --danger:       #f43f5e;
    --danger-soft:  rgba(244,63,94,0.12);
    --danger-border:rgba(244,63,94,0.28);

    /* ── Success ── */
    --success:      #10b981;

    /* ── Canvas ink ── */
    --grid-minor: rgba(139,157,195,0.09);
    --grid-major: rgba(139,157,195,0.19);
    --axis-line:  rgba(139,157,195,0.55);

    /* ── Typography ── */
    --font-ui:   'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-math: 'Libre Baskerville', serif;

    /* ── Shadows ── */
    --shadow-panel:
        0 0 0 1px rgba(255,255,255,0.06),
        0 4px 6px rgba(0,0,0,0.3),
        0 16px 48px rgba(0,0,0,0.7),
        0 48px 100px rgba(0,0,0,0.5);

    --shadow-panel-hover:
        0 0 0 1px rgba(99,179,237,0.18),
        0 4px 6px rgba(0,0,0,0.35),
        0 20px 60px rgba(0,0,0,0.75),
        0 0 60px rgba(59,158,255,0.06);

    --shadow-dragging:
        0 0 0 1.5px var(--accent),
        0 0 0 3px rgba(59,158,255,0.15),
        0 24px 80px rgba(0,0,0,0.85),
        0 0 80px rgba(59,158,255,0.12);

    --shadow-btn:
        0 1px 3px rgba(0,0,0,0.4),
        0 0 0 1px rgba(255,255,255,0.06) inset;
}

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

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text-1);
    min-height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Subtle animated background noise ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(59,158,255,0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 110%, rgba(139,92,246,0.05) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ── Layout ── */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* ════════════════════════════════════════════════════════════════
   PREMIUM FLOATING PANEL
   ════════════════════════════════════════════════════════════════ */
.sidebar {
    position: fixed;
    top: 16px;
    right: 16px;
    left: unset;
    width: 310px;
    /* Content grew with the CP sections; cap the default so the panel still
       reads as a floating window rather than a full-height column. The body
       scrolls, and dragging the S/SE handles overrides this. */
    height: min(600px, calc(100vh - 32px));
    max-height: calc(100vh - 32px);
    min-width: 240px;
    min-height: 52px;

    /* Multi-layer glassmorphism */
    background: var(--surface-0);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);

    /* Gradient border via background + padding trick */
    border: none;
    border-radius: 20px;
    outline: 1px solid var(--border-dim);

    /* Layered shadow for depth */
    box-shadow: var(--shadow-panel);

    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;

    /* Smooth corner-snap + bubble morph */
    transition:
        top    0.32s cubic-bezier(0.34,1.56,0.64,1),
        left   0.32s cubic-bezier(0.34,1.56,0.64,1),
        right  0.32s cubic-bezier(0.34,1.56,0.64,1),
        bottom 0.32s cubic-bezier(0.34,1.56,0.64,1),
        width        0.42s cubic-bezier(0.34,1.4,0.64,1),
        height       0.42s cubic-bezier(0.34,1.4,0.64,1),
        border-radius 0.42s cubic-bezier(0.34,1.4,0.64,1),
        box-shadow   0.25s ease,
        outline-color 0.25s ease;
}

/* Top shimmer line */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 12px; right: 12px;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.18) 30%,
        rgba(255,255,255,0.28) 50%,
        rgba(255,255,255,0.18) 70%,
        transparent 100%);
    border-radius: 0 0 2px 2px;
    pointer-events: none;
    z-index: 1;
}

.sidebar:hover {
    outline-color: var(--border-bright);
    box-shadow: var(--shadow-panel-hover);
}

.sidebar.dragging {
    box-shadow: var(--shadow-dragging);
    outline-color: var(--accent);
    opacity: 0.96;
    transition: none;
    cursor: grabbing !important;
}

.sidebar.snap-preview {
    outline-color: var(--accent);
    box-shadow: var(--shadow-dragging);
}

/* ── Scrollable body ── */
.sidebar-body {
    overflow-y: auto;
    flex: 1;
    padding: 0 16px 20px;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-body::-webkit-scrollbar { width: 3px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 99px;
}

/* ════════════════════════════════════════════════════════════════
   PREMIUM DRAG HANDLE
   ════════════════════════════════════════════════════════════════ */
.sidebar-drag-handle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 12px 14px;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-dim);
    border-radius: 20px 20px 0 0;
    background: linear-gradient(180deg,
        rgba(255,255,255,0.045) 0%,
        rgba(255,255,255,0.015) 100%);
    position: relative;
    z-index: 2;
    transition: background 0.2s;
}

.sidebar-drag-handle:hover {
    background: linear-gradient(180deg,
        rgba(255,255,255,0.065) 0%,
        rgba(255,255,255,0.025) 100%);
}

.sidebar-drag-handle:active { cursor: grabbing; }

/* ── 2×3 dot grip ── */
.drag-handle-dots {
    display: grid;
    grid-template-columns: repeat(2, 4px);
    grid-template-rows:    repeat(3, 4px);
    gap: 3px;
    opacity: 0.22;
    flex-shrink: 0;
    transition: opacity 0.25s;
}
.sidebar-drag-handle:hover .drag-handle-dots { opacity: 0.55; }

.drag-handle-dots span {
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--text-1);
    display: block;
}

/* ── Title in drag handle ── */
.drag-handle-title {
    flex: 1;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: linear-gradient(90deg, #c7d9f5 0%, #8bb8ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Corner badge pill ── */
.corner-badge {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-dim);
    padding: 2px 6px;
    border-radius: 99px;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
}

.sidebar:hover .corner-badge {
    color: var(--text-2);
    border-color: var(--border-bright);
}

/* ── macOS-style window controls ── */
.sidebar-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-ctrl-btn {
    width: 15px; height: 15px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.18s, transform 0.18s;
    flex-shrink: 0;
    padding: 0;
    position: relative;
}

.sidebar-ctrl-btn svg {
    pointer-events: none;
    display: block;
    opacity: 0;
    transition: opacity 0.15s;
    position: absolute;
    color: rgba(0,0,0,0.65);
}

.sidebar-ctrl-btn:hover svg { opacity: 1; }

.sidebar-ctrl-btn.corner-btn {
    background: radial-gradient(circle at 35% 35%, #5bb5ff, #1a7acc);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.25) inset, 0 1px 4px rgba(26,122,204,0.5);
}
.sidebar-ctrl-btn.corner-btn:hover {
    filter: brightness(1.2);
    transform: scale(1.15);
}

.sidebar-ctrl-btn.collapse-btn {
    background: radial-gradient(circle at 35% 35%, #ffd057, #e8a000);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.25) inset, 0 1px 4px rgba(232,160,0,0.4);
}
.sidebar-ctrl-btn.collapse-btn:hover {
    filter: brightness(1.15);
    transform: scale(1.15);
}

/* ════════════════════════════════════════════════════════════════
   RESIZE HANDLES
   ════════════════════════════════════════════════════════════════ */
.sidebar-resizer-e,
.sidebar-resizer-s,
.sidebar-resizer-se {
    position: absolute;
    z-index: 110;
    transition: background 0.2s;
}

.sidebar-resizer-e  { top: 48px; right: 0; width: 5px; height: calc(100% - 48px); cursor: ew-resize; }
.sidebar-resizer-s  { bottom: 0; left: 12px; right: 12px; height: 5px; cursor: ns-resize; }
.sidebar-resizer-se { bottom: 0; right: 0; width: 16px; height: 16px; cursor: nwse-resize; }

.sidebar-resizer-e:hover, .sidebar-resizer-e.active,
.sidebar-resizer-s:hover, .sidebar-resizer-s.active {
    background: var(--accent-mid);
    border-radius: 4px;
}

/* SE corner grip dots */
.sidebar-resizer-se::after {
    content: '';
    position: absolute;
    bottom: 4px; right: 4px;
    width: 7px; height: 7px;
    background:
        radial-gradient(circle, rgba(255,255,255,0.4) 1px, transparent 1px) 0 0,
        radial-gradient(circle, rgba(255,255,255,0.25) 1px, transparent 1px) 3.5px 0,
        radial-gradient(circle, rgba(255,255,255,0.25) 1px, transparent 1px) 0 3.5px,
        radial-gradient(circle, rgba(255,255,255,0.15) 1px, transparent 1px) 3.5px 3.5px;
    background-size: 3.5px 3.5px;
}

.sidebar-resizer-se:hover .sidebar-resizer-se::after { opacity: 0.8; }

/* ════════════════════════════════════════════════════════════════
   SIDEBAR CONTENT
   ════════════════════════════════════════════════════════════════ */

/* ── Header ── */
.sidebar-header { padding-top: 18px; margin-bottom: 18px; }

.sidebar-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 5px;
    background: linear-gradient(135deg, #e8f0ff 0%, #a5b4fc 55%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-header p {
    color: var(--text-2);
    font-size: 0.78rem;
    line-height: 1.55;
    margin-bottom: 14px;
    font-weight: 400;
}

/* ── Section label ── */
.section-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-dim);
    border-radius: 1px;
}

/* ── Mode toggle ── */
.mode-toggle {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--border-dim);
    border-radius: 12px;
    padding: 3px;
    gap: 2px;
}

.mode-btn {
    background: transparent;
    border: none;
    padding: 7px 4px;
    color: var(--text-2);
    border-radius: 9px;
    font-size: 0.73rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.mode-btn:hover {
    color: var(--text-1);
    background: rgba(255,255,255,0.07);
}

.mode-btn.active {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    color: #fff;
    box-shadow:
        0 2px 8px rgba(37,99,235,0.45),
        0 0 0 1px rgba(255,255,255,0.12) inset;
}

/* ── Line type ── */
.line-type-container {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-dim);
    padding: 7px 10px;
    border-radius: 10px;
    animation: fadeIn 0.2s ease;
}
.line-type-container.hidden { display: none; }

.line-type-container label {
    font-size: 0.72rem;
    color: var(--text-2);
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.line-type-select {
    flex: 1;
    background: rgba(255,255,255,0.04);
    color: var(--text-1);
    border: 1px solid var(--border-dim);
    padding: 4px 8px;
    border-radius: 7px;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}
.line-type-select:hover { border-color: var(--border-bright); }
.line-type-select option { background: #0d1424; color: var(--text-1); }

/* ── Best-fit toggle ── */
.best-fit-container {
    margin-top: 8px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-dim);
    padding: 8px 10px;
    border-radius: 10px;
    animation: fadeIn 0.2s ease;
}

.best-fit-container label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-1);
    cursor: pointer;
    font-weight: 500;
}

.best-fit-container input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px; height: 14px;
    cursor: pointer;
    border-radius: 4px;
}

/* ── Status hint ── */
.status-hint {
    margin-top: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(59,158,255,0.08), rgba(139,92,246,0.06));
    border: 1px solid var(--border-accent);
    border-radius: 10px;
    font-size: 0.73rem;
    color: #93c5fd;
    text-align: center;
    animation: fadeIn 0.22s ease;
    line-height: 1.45;
    font-weight: 500;
}
.status-hint.hidden { display: none; }

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

/* ── Manual input section ── */
.manual-input-section {
    margin: 14px 0;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-dim);
}

.manual-input-section label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.manual-input-section label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-dim);
}

.manual-input-row { display: flex; gap: 6px; }

.manual-input {
    flex: 1;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-dim);
    color: var(--text-1);
    padding: 8px 12px;
    border-radius: 10px;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    outline: none;
    transition: all 0.2s ease;
}
.manual-input:focus {
    border-color: var(--accent);
    background: rgba(59,158,255,0.05);
    box-shadow: 0 0 0 3px rgba(59,158,255,0.12);
}
.manual-input::placeholder { color: var(--text-3); }

.manual-add-btn {
    width: 34px;
    background: linear-gradient(135deg, #2563eb, #3b9eff);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.15rem;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(37,99,235,0.4), 0 0 0 1px rgba(255,255,255,0.1) inset;
    flex-shrink: 0;
}
.manual-add-btn:hover {
    background: linear-gradient(135deg, #3b7cff, #60b0ff);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(37,99,235,0.5);
}
.manual-add-btn:active { transform: translateY(0); }

/* ── Points section ── */
.points-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.points-section h2 {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.points-section h2::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-dim);
}

/* ── Points list ── */
.points-list {
    list-style: none;
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 2px;
    margin-bottom: 14px;
    max-height: 190px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.points-list::-webkit-scrollbar { width: 3px; }
.points-list::-webkit-scrollbar-track { background: transparent; }
.points-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }

.points-list li {
    background: rgba(255,255,255,0.025);
    border-radius: 10px;
    padding: 9px 12px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.points-list li:hover,
.points-list li.hover-highlight {
    background: rgba(255,255,255,0.055);
    border-color: var(--border-dim);
    transform: translateX(3px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.points-list li.hover-highlight {
    background: rgba(59,158,255,0.1);
    border-color: var(--border-accent);
    box-shadow: 0 0 0 1px rgba(59,158,255,0.1) inset;
}

.points-list .point-label {
    font-family: var(--font-math);
    font-style: italic;
    color: #93c5fd;
    font-size: 0.95rem;
    min-width: 28px;
}

.points-list .point-coords {
    font-family: var(--font-mono);
    color: var(--text-2);
    background: rgba(0,0,0,0.3);
    padding: 3px 7px;
    border-radius: 6px;
    font-size: 0.72rem;
    margin-left: auto;
    margin-right: 8px;
    letter-spacing: -0.01em;
}

.point-color-picker {
    -webkit-appearance: none;
    appearance: none;
    width: 20px; height: 20px;
    border: 1.5px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: border-color 0.2s, transform 0.2s;
}
.point-color-picker:hover { border-color: rgba(255,255,255,0.45); transform: scale(1.1); }
.point-color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.point-color-picker::-webkit-color-swatch { border: none; border-radius: 50%; }
.point-color-picker::-moz-color-swatch { border: none; border-radius: 50%; }

/* ── Delete button ── */
.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    padding: 3px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
    opacity: 0;
}
.points-list li:hover .delete-btn { opacity: 1; }
.delete-btn:hover {
    background: var(--danger-soft);
    color: var(--danger);
    transform: scale(1.1);
}

/* ── Empty state ── */
.empty-state {
    color: var(--text-3);
    font-style: italic;
    text-align: center;
    padding: 22px 0 !important;
    background: transparent !important;
    font-size: 0.8rem;
}
.empty-state:hover { transform: none !important; border-color: transparent !important; }

/* ════════════════════════════════════════════════════════════════
   PREMIUM BUTTONS
   ════════════════════════════════════════════════════════════════ */
.actions { margin-top: 16px; }

.action-btn, .danger, .secondary {
    width: 100%;
    padding: 9px 14px;
    border-radius: 10px;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-ui);
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid var(--danger-border);
    box-shadow: var(--shadow-btn);
}
.danger:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    box-shadow: 0 4px 20px rgba(244,63,94,0.4), 0 0 0 1px rgba(255,255,255,0.1) inset;
    transform: translateY(-1px);
}
.danger:active { transform: none; }

.secondary {
    background: var(--accent-soft);
    color: #93c5fd;
    border: 1px solid rgba(99,179,237,0.22);
    box-shadow: var(--shadow-btn);
}
.secondary:hover {
    background: var(--accent-mid);
    color: #e0f2fe;
    border-color: var(--border-accent);
    box-shadow: 0 4px 16px rgba(59,158,255,0.2);
    transform: translateY(-1px);
}
.secondary:active { transform: none; }

.export-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

/* ════════════════════════════════════════════════════════════════
   CREDITS — Premium footer card
   ════════════════════════════════════════════════════════════════ */
.credits-section {
    margin-top: 16px;
    padding: 10px 14px;
    background: linear-gradient(135deg,
        rgba(59,158,255,0.05) 0%,
        rgba(139,92,246,0.04) 100%);
    border: 1px solid var(--border-dim);
    border-radius: 12px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

/* Subtle shimmer */
.credits-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent, rgba(255,255,255,0.12) 40%, rgba(255,255,255,0.2) 50%,
        rgba(255,255,255,0.12) 60%, transparent);
}

.credits-text {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.credits-label {
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.credits-name {
    font-family: var(--font-math);
    font-size: 0.82rem;
    font-weight: 600;
    background: linear-gradient(90deg, var(--accent) 0%, var(--violet) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.02em;
}

.social-links {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.social-links a {
    color: var(--text-3);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 7px;
    transition: all 0.2s ease;
}
.social-links a svg { width: 13px; height: 13px; }
.social-links a:hover {
    color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-2px);
}

/* ════════════════════════════════════════════════════════════════
   OLD TOGGLE BTN — hidden
   ════════════════════════════════════════════════════════════════ */
.toggle-btn { display: none; }

/* ════════════════════════════════════════════════════════════════
   CANVAS AREA
   ════════════════════════════════════════════════════════════════ */
.graph-container {
    flex-grow: 1;
    position: relative;
    background:
        radial-gradient(ellipse 70% 60% at 50% 40%, #0f1b35 0%, #060810 100%);
    display: flex;
    justify-content: center;
    align-items: center;
}

.canvas-wrapper {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

#graph-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* ════════════════════════════════════════════════════════════════
   TOOLTIP
   ════════════════════════════════════════════════════════════════ */
.tooltip {
    position: absolute;
    background: rgba(8, 12, 24, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-bright);
    padding: 5px 12px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    pointer-events: none;
    transform: translate(-50%, -155%);
    transition: opacity 0.12s;
    box-shadow:
        0 4px 20px rgba(0,0,0,0.5),
        0 0 0 1px rgba(255,255,255,0.05) inset;
    color: var(--text-1);
    white-space: nowrap;
}
/* ════════════════════════════════════════════════════════════════
   WATER DROP BUBBLE MODE — collapsed to a floating orb
   ════════════════════════════════════════════════════════════════ */

/* The icon shown inside the bubble */
.bubble-icon {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    z-index: 5;
    pointer-events: none;
    flex-direction: column;
}

.bubble-icon span {
    font-size: 0.58rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    background: linear-gradient(140deg,
        rgba(220,245,255,0.98) 0%,
        rgba(130,200,255,0.95) 55%,
        rgba(80,160,240,0.9) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 8px rgba(59,158,255,0.95));
    position: relative;
    z-index: 2;
}

/* ── The water-drop panel itself ── */
.sidebar.bubble-mode {
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    min-width: unset !important;
    min-height: unset !important;
    cursor: pointer;
    overflow: hidden;

    /* Layered water-glass gradients */
    background:
        /* Caustic highlight — top-left bright spot */
        radial-gradient(ellipse 58% 42% at 28% 26%,
            rgba(235,248,255,0.55) 0%,
            rgba(180,225,255,0.14) 52%,
            transparent 100%),
        /* Subtle bottom-right secondary highlight */
        radial-gradient(ellipse 38% 30% at 72% 76%,
            rgba(110,185,255,0.2) 0%,
            transparent 68%),
        /* Core deep glass */
        radial-gradient(circle at 48% 58%,
            rgba(16,32,80,0.82) 0%,
            rgba(6,12,40,0.92) 100%);

    backdrop-filter: blur(30px) saturate(220%) brightness(1.1);
    -webkit-backdrop-filter: blur(30px) saturate(220%) brightness(1.1);

    outline: 1px solid rgba(180,220,255,0.2);
    outline-offset: 0;

    box-shadow:
        /* Inner bright rim */
        0 0 0 1.5px rgba(255,255,255,0.22) inset,
        /* Inner secondary blue ring */
        0 0 0 0.5px rgba(120,190,255,0.4) inset,
        /* Depth */
        0 8px 28px rgba(0,0,0,0.65),
        0 3px 10px rgba(0,0,0,0.45),
        /* Ambient glow */
        0 0 30px rgba(59,158,255,0.32),
        0 0 65px rgba(59,158,255,0.14);

    animation: bubble-breathe 3.8s ease-in-out infinite;

    /* Override transition for bubble morphing */
    transition:
        width        0.44s cubic-bezier(0.34,1.4,0.64,1),
        height       0.44s cubic-bezier(0.34,1.4,0.64,1),
        border-radius 0.44s cubic-bezier(0.34,1.4,0.64,1),
        top    0.32s cubic-bezier(0.34,1.56,0.64,1),
        left   0.32s cubic-bezier(0.34,1.56,0.64,1),
        right  0.32s cubic-bezier(0.34,1.56,0.64,1),
        bottom 0.32s cubic-bezier(0.34,1.56,0.64,1),
        transform 0.22s ease,
        outline-color 0.2s !important;
}

/* Hover: swell + intensify glow */
.sidebar.bubble-mode:hover {
    transform: scale(1.1);
    animation-play-state: paused;
    box-shadow:
        0 0 0 1.5px rgba(255,255,255,0.32) inset,
        0 0 0 1px rgba(140,210,255,0.55) inset,
        0 12px 48px rgba(0,0,0,0.6),
        0 0 55px rgba(59,158,255,0.55),
        0 0 100px rgba(59,158,255,0.22);
    outline-color: rgba(59,158,255,0.45);
}

/* Click press: quick squish */
.sidebar.bubble-mode:active {
    transform: scale(0.93);
    transition: transform 0.1s ease !important;
}

/* Repurpose ::before as the caustic highlight dot
   (overrides the shimmer line from normal mode) */
.sidebar.bubble-mode::before {
    top:    9px !important;
    left:   12px !important;
    right:  unset !important;
    width:  20px !important;
    height: 12px !important;
    border-radius: 50% !important;
    background: radial-gradient(ellipse,
        rgba(255,255,255,0.78) 0%,
        rgba(255,255,255,0.18) 70%,
        transparent 100%) !important;
    filter: blur(4.5px);
    transform: rotate(-32deg) !important;
    z-index: 4;
    opacity: 1;
}

/* Show bubble icon */
.sidebar.bubble-mode .bubble-icon { display: flex; }

/* Hide panel internals */
.sidebar.bubble-mode .sidebar-drag-handle,
.sidebar.bubble-mode .sidebar-body,
.sidebar.bubble-mode .sidebar-resizer-e,
.sidebar.bubble-mode .sidebar-resizer-s,
.sidebar.bubble-mode .sidebar-resizer-se {
    display: none !important;
}

/* ── Idle breathe animation ── */
@keyframes bubble-breathe {
    0%, 100% {
        box-shadow:
            0 0 0 1.5px rgba(255,255,255,0.22) inset,
            0 0 0 0.5px rgba(120,190,255,0.4) inset,
            0 8px 28px rgba(0,0,0,0.65),
            0 3px 10px rgba(0,0,0,0.45),
            0 0 30px rgba(59,158,255,0.28),
            0 0 65px rgba(59,158,255,0.12);
        transform: translateY(0);
    }
    50% {
        box-shadow:
            0 0 0 1.5px rgba(255,255,255,0.28) inset,
            0 0 0 1px rgba(140,205,255,0.48) inset,
            0 14px 44px rgba(0,0,0,0.58),
            0 4px 14px rgba(0,0,0,0.38),
            0 0 55px rgba(59,158,255,0.45),
            0 0 100px rgba(59,158,255,0.18);
        transform: translateY(-4px);
    }
}

/* ── Ripple on click ── */
@keyframes bubble-ripple-out {
    0%   { box-shadow: 0 0 0 0   rgba(59,158,255,0.55), 0 8px 28px rgba(0,0,0,0.65); }
    100% { box-shadow: 0 0 0 24px rgba(59,158,255,0),   0 8px 28px rgba(0,0,0,0.65); }
}

.sidebar.bubble-ripple {
    animation: bubble-ripple-out 0.55s ease-out forwards !important;
}

/* ════════════════════════════════════════════════════════════════
   CP TOOLING — added sections, canvas furniture and overlays.
   Written against the tokens above so it inherits the panel's
   glass + sky-blue language.
   ════════════════════════════════════════════════════════════════ */

.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.panel-section { margin-top: 16px; }

.micro-hint {
    font-size: 0.62rem;
    line-height: 1.55;
    color: var(--text-3);
    margin-top: 6px;
}
.micro-hint code {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--border-dim);
    border-radius: 4px;
    padding: 1px 4px;
    color: var(--text-2);
}

/* ── Paste area ── */
.code-area {
    width: 100%;
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--border-dim);
    border-radius: 10px;
    color: var(--text-1);
    padding: 9px 11px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.65;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.code-area::placeholder { color: var(--text-3); }
.code-area:focus {
    border-color: var(--border-accent);
    background: rgba(0,0,0,0.5);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Buttons ── */
.primary {
    width: 100%;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(180deg, #4aa6ff 0%, var(--accent) 100%);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow), 0 0 0 1px rgba(255,255,255,0.12) inset;
    transition: all 0.2s ease;
}
.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.primary:active { transform: none; }

.btn-row { display: flex; gap: 6px; margin-top: 8px; }
.btn-row > :first-child { flex: 1.4; }
.btn-row > :last-child { flex: 1; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.chip-row { display: flex; gap: 6px; margin-bottom: 8px; }
.chip {
    flex: 1;
    padding: 5px 8px;
    border-radius: 7px;
    border: 1px solid var(--border-dim);
    background: rgba(255,255,255,0.03);
    color: var(--text-2);
    font-family: var(--font-ui);
    font-size: 0.66rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}
.chip:hover {
    background: var(--accent-soft);
    color: #93c5fd;
    border-color: var(--border-accent);
}

/* ── Toggle switch ── */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
    user-select: none;
}
.toggle-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: relative;
    flex-shrink: 0;
    width: 30px; height: 17px;
    border-radius: 99px;
    background: rgba(0,0,0,0.45);
    border: 1px solid var(--border-dim);
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.toggle-thumb {
    position: absolute;
    top: 2px; left: 2px;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: var(--text-3);
    transition: transform 0.2s cubic-bezier(0.34,1.4,0.64,1), background 0.2s;
}
.toggle-row input:checked + .toggle-track {
    background: linear-gradient(180deg, #4aa6ff 0%, var(--accent) 100%);
    border-color: transparent;
    box-shadow: 0 0 12px var(--accent-glow);
}
.toggle-row input:checked + .toggle-track .toggle-thumb {
    transform: translateX(13px);
    background: #fff;
}
.toggle-row input:focus-visible + .toggle-track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.toggle-text { font-size: 0.74rem; line-height: 1.35; color: var(--text-1); }
.toggle-text em {
    display: block;
    font-style: normal;
    font-size: 0.6rem;
    color: var(--text-3);
    margin-top: 1px;
}

/* ── Segmented control ── */
.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}
.field-name { font-size: 0.7rem; color: var(--text-2); }
.segmented {
    display: flex;
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--border-dim);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}
.segmented button {
    padding: 4px 9px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-3);
    font-family: var(--font-ui);
    font-size: 0.66rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}
.segmented button:hover { color: var(--text-1); }
.segmented button.active {
    background: var(--accent-mid);
    color: #dbeafe;
    box-shadow: 0 0 0 1px rgba(99,179,237,0.2) inset;
}

/* ── Stats readout ── */
.stats {
    margin-top: 10px;
    background: rgba(0,0,0,0.28);
    border: 1px solid var(--border-dim);
    border-radius: 10px;
    padding: 8px 10px;
}
.stat-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 0;
    font-size: 0.68rem;
}
.stat-group {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 6px 0 3px;
    margin-top: 4px;
    border-top: 1px solid var(--border-dim);
}
.stats > .stat-group:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.stat-key { color: var(--text-2); white-space: nowrap; }
.stat-val {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--text-1);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-val.accent { color: var(--accent); }
.stat-val.hull   { color: var(--violet); }
.stat-val.near   { color: var(--success); }
.stat-val.fit    { color: var(--danger); }
.stats-empty { font-size: 0.68rem; color: var(--text-3); text-align: center; padding: 3px 0; }

/* ── Points list additions ── */
.count-pill {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--text-3);
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-dim);
    border-radius: 99px;
    padding: 2px 7px;
    margin-left: 6px;
    letter-spacing: 0;
    text-transform: none;
}
.point-index {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-3);
    min-width: 20px;
    flex-shrink: 0;
}
.focus-btn {
    background: transparent;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    padding: 3px;
    border-radius: 5px;
    display: flex;
    opacity: 0;
    transition: all 0.18s;
}
.points-list li:hover .focus-btn { opacity: 1; }
.focus-btn:hover { background: var(--accent-soft); color: var(--accent); }
.list-overflow {
    font-size: 0.62rem;
    color: var(--text-3);
    text-align: center;
    margin-top: 4px;
}
.list-overflow.hidden { display: none; }

/* ════════════════════════════════════════════════════════════════
   CANVAS FURNITURE — floating glass, matching the panel
   ════════════════════════════════════════════════════════════════ */

.hud-card, .zoom-cluster, .status-pill {
    position: fixed;
    z-index: 90;
    background: var(--surface-0);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    outline: 1px solid var(--border-dim);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3), 0 16px 40px rgba(0,0,0,0.55);
}

.hud-card {
    top: 16px; left: 16px;
    min-width: 190px; max-width: 250px;
    padding: 10px 12px;
    border-radius: 14px;
    animation: hud-in 0.2s cubic-bezier(0.34,1.4,0.64,1);
}
.hud-card.hidden { display: none; }
.hud-card h3 {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 6px;
}
@keyframes hud-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.zoom-cluster {
    right: 16px; bottom: 60px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
}
.zoom-cluster button {
    width: 28px; height: 28px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.18s;
}
.zoom-cluster button svg { width: 15px; height: 15px; }
.zoom-cluster button:hover { background: var(--accent-soft); color: var(--accent); }

.status-pill {
    left: 16px; bottom: 16px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 12px;
    border-radius: 99px;
    font-size: 0.66rem;
    color: var(--text-2);
}
.pill-sep {
    width: 1px;
    height: 11px;
    background: var(--border-dim);
}
.status-pill button {
    background: transparent;
    border: none;
    color: var(--text-3);
    font-family: var(--font-ui);
    font-size: 0.66rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    transition: color 0.18s;
}
.status-pill button:hover { color: var(--accent); }

/* ════════════════════════════════════════════════════════════════
   TOASTS
   ════════════════════════════════════════════════════════════════ */
.toasts {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 99px;
    background: var(--surface-1);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    outline: 1px solid var(--border-bright);
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    font-size: 0.72rem;
    color: var(--text-1);
    animation: toast-in 0.22s cubic-bezier(0.34,1.4,0.64,1);
}
.toast.out { animation: toast-out 0.18s ease forwards; }
.toast svg { width: 14px; height: 14px; flex-shrink: 0; }
.toast.ok svg    { color: var(--success); }
.toast.error svg { color: var(--danger); }
.toast.info svg  { color: var(--accent); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.96); } }

/* ════════════════════════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════════════════════════ */
.modal-root {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: grid;
    place-items: center;
    padding: 20px;
}
.modal-root.hidden { display: none; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 5, 12, 0.62);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.modal {
    position: relative;
    width: 100%;
    max-width: 370px;
    background: var(--surface-0);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    outline: 1px solid var(--border-bright);
    border-radius: 18px;
    box-shadow: var(--shadow-panel);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: modal-in 0.22s cubic-bezier(0.34,1.4,0.64,1);
}
.modal-wide { max-width: 640px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal h2 { font-size: 0.95rem; font-weight: 700; color: var(--text-1); }
.modal-desc { font-size: 0.72rem; line-height: 1.5; color: var(--text-2); }
.modal-desc.hidden { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button { width: auto; padding: 8px 16px; }

.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 18px;
}
.shortcut-col h3 {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-dim);
}
.shortcut-col dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 10px;
    align-items: center;
}
.shortcut-col dt { display: flex; gap: 3px; }
.shortcut-col dd { font-size: 0.7rem; color: var(--text-2); }
kbd {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 600;
    line-height: 1;
    padding: 4px 5px;
    min-width: 19px;
    text-align: center;
    border-radius: 5px;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--border-dim);
    border-bottom-width: 2px;
    color: var(--text-2);
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .sidebar { width: calc(100vw - 24px) !important; }
    .hud-card { max-width: 160px; font-size: 0.62rem; }
    .status-pill { font-size: 0.6rem; gap: 7px; padding: 5px 10px; }
    .zoom-cluster { bottom: 56px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
