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

:root {
    --white: #f0ede8;
    --bg: #060606;
    --dim: rgba(240, 237, 232, 0.28);
    --faint: rgba(240, 237, 232, 0.1);
}

body.light-mode {
    --white: #060606;
    --bg: #f8f9fa;
    --dim: rgba(6, 6, 6, 0.35);
    --faint: rgba(6, 6, 6, 0.15);
}

html,
body {
    width: 100%;
    height: 100%;
    background: var(--bg);
    overflow: hidden;
    cursor: none;
    transition: background 0.4s;
}

/* CONSTRAINED CANVAS */
#mainCanvas {
    position: fixed;
    top: 140px;
    bottom: 90px;
    left: 200px;
    right: 200px;
    width: calc(100% - 400px);
    height: calc(100% - 230px);
}

/* CUSTOM CURSOR */
#cursor {
    position: fixed;
    width: 6px;
    height: 6px;
    background: var(--white);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    transform: translate(-50%, -50%);
    transition: transform 0.08s, opacity 0.2s;
    /* mix-blend-mode: difference; */
}

#cursorRing {
    position: fixed;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(240, 237, 232, 0.3);
    border-radius: 50%;
    pointer-events: none;
    z-index: 999;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s, border-color 0.3s;
    /* mix-blend-mode: difference; */
}

body.light-mode #cursorRing {
    border: 1px solid rgba(6, 6, 6, 0.4);
}

/* TOP BAR */
#topBar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 36px 44px;
    pointer-events: none;
}

.wordmark {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: 13px;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--dim);
    pointer-events: all;
    cursor: none;
    transition: color 0.4s;
}

.wordmark:hover {
    color: var(--white);
}

.top-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: all;
}

.nav-ghost {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    font-weight: 300;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--dim);
    background: none;
    border: none;
    cursor: none;
    transition: color 0.3s;
    text-align: right;
}

.nav-ghost:hover {
    color: var(--white);
}

/* BOTTOM STATUS */
#bottomBar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 36px 44px;
    pointer-events: none;
}

.stat-cluster {
    display: flex;
    flex-direction: column;
    gap: 5px;
    pointer-events: all;
}

.stat-right {
    align-items: flex-end;
    text-align: right;
}

.stat-line {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    font-weight: 300;
    letter-spacing: 0.18em;
    color: var(--dim);
    text-transform: uppercase;
    transition: color 0.3s;
}

.stat-line.highlight {
    color: var(--white);
    opacity: 0.65;
}

.bottom-center {
    position: absolute;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: all;
}

.form-name {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 300;
    font-size: 30px;
    color: var(--dim);
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 8px;
    transition: color 0.4s;
    cursor: none;
}

.form-name:hover {
    color: var(--white);
    opacity: 0.7;
}

.form-dots {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.form-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--faint);
    cursor: none;
    transition: background 0.3s, transform 0.3s;
    pointer-events: all;
}

.form-dot.active {
    background: var(--white);
    opacity: 0.6;
    transform: scale(1.5);
}

.form-dot:hover {
    background: var(--white);
    opacity: 0.4;
}

/* FLOATING CONTROLS */
#controlsPanel {
    position: fixed;
    right: 44px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 20px;
    opacity: 0;
    transition: opacity 0.6s;
    pointer-events: none;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 6px;
}

#controlsPanel.visible {
    opacity: 1;
    pointer-events: all;
}

#controlsPanel::-webkit-scrollbar {
    width: 4px;
}

#controlsPanel::-webkit-scrollbar-thumb {
    background: var(--faint);
}

.float-control {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.float-separator {
    font-family: 'DM Mono', monospace;
    font-size: 8px;
    letter-spacing: 0.28em;
    color: var(--dim);
    text-transform: uppercase;
    border-top: 1px solid var(--faint);
    margin-top: 8px;
    padding-top: 12px;
    text-align: right;
}

.float-control.hidden-control {
    display: none;
}

.float-label {
    font-family: 'DM Mono', monospace;
    font-size: 8px;
    letter-spacing: 0.2em;
    color: var(--dim);
    text-transform: uppercase;
    text-align: right;
}

.float-slider-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.float-val {
    font-family: 'DM Mono', monospace;
    font-size: 8px;
    color: var(--white);
    opacity: 0.45;
    width: 40px;
    text-align: right;
}

.gif-control .float-val {
    width: 52px;
}

.gif-loop-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gif-loop-btn {
    font-family: 'DM Mono', monospace;
    font-size: 8px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--dim);
    background: none;
    border: none;
    cursor: none;
    transition: color 0.25s, opacity 0.25s;
    opacity: 0.85;
}

.gif-loop-btn:hover {
    color: var(--white);
}

.gif-loop-btn.active {
    color: var(--white);
    opacity: 1;
}

input[type="range"].ghost {
    appearance: none;
    -webkit-appearance: none;
    width: 80px;
    height: 1px;
    background: var(--faint);
    outline: none;
    cursor: none;
}

input[type="range"].ghost::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--white);
    opacity: 0.7;
    cursor: none;
    box-shadow: 0 0 8px rgba(240, 237, 232, 0.3);
}

body.light-mode input[type="range"].ghost::-webkit-slider-thumb {
    box-shadow: 0 0 8px rgba(6, 6, 6, 0.3);
}

/* TRIGGER ZONE */
#controlsTrigger {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    z-index: 99;
}

/* LEFT SIDE - SHAPES */
#shapePanel {
    position: fixed;
    left: 44px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 14px;
    opacity: 0;
    transition: opacity 0.6s;
    pointer-events: none;
}

#shapePanel.visible {
    opacity: 1;
    pointer-events: all;
}

.shape-choice {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 0.12em;
    color: var(--dim);
    background: none;
    border: none;
    cursor: none;
    text-align: left;
    transition: color 0.3s;
}

.shape-choice:hover {
    color: var(--white);
    opacity: 0.7;
}

.shape-choice.active {
    color: var(--white);
    font-style: normal;
}

#shapeTrigger {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 80px;
    z-index: 99;
}

/* FLASH & LOADERS */
#flash {
    position: fixed;
    inset: 0;
    background: #f0ede8;
    opacity: 0;
    z-index: 200;
    pointer-events: none;
}

#progressLine {
    position: fixed;
    bottom: 0;
    left: 0;
    height: 1px;
    background: var(--white);
    opacity: 0.25;
    width: 0%;
    z-index: 200;
    transition: width 0.4s linear, opacity 0.3s;
}

#toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translate(-50%, 20px);
    opacity: 0;
    pointer-events: none;
    z-index: 260;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--white);
    background: rgba(6, 6, 6, 0.84);
    border: 1px solid var(--faint);
    padding: 10px 14px;
    transition: opacity 0.22s, transform 0.22s;
    white-space: nowrap;
}

body.light-mode #toast {
    background: rgba(248, 249, 250, 0.94);
}

#toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

#toast.error {
    border-color: rgba(255, 99, 99, 0.45);
}

body.modal-open #shapePanel,
body.modal-open #controlsPanel {
    opacity: 0 !important;
    pointer-events: none !important;
}

.modal-shell {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    z-index: 240;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-shell.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
}

body.light-mode .modal-backdrop {
    background: rgba(0, 0, 0, 0.22);
}

.modal-card {
    position: relative;
    width: min(720px, calc(100vw - 40px));
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    border: 1px solid var(--faint);
    background: rgba(10, 10, 10, 0.96);
    color: var(--white);
    padding: 20px 22px 18px;
}

body.light-mode .modal-card {
    background: rgba(252, 252, 252, 0.98);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-head h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 28px;
    letter-spacing: 0.04em;
    color: var(--white);
}

.modal-close {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--dim);
    background: none;
    border: none;
    cursor: none;
    transition: color 0.2s;
}

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

.modal-copy {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    line-height: 1.65;
    color: var(--dim);
    margin-bottom: 14px;
}

.modal-grid {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.modal-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
}

.modal-kbd {
    min-width: 64px;
    text-align: center;
    border: 1px solid var(--faint);
    padding: 5px 6px;
    color: var(--white);
    letter-spacing: 0.2em;
}

.modal-links {
    display: grid;
    gap: 9px;
    margin-bottom: 16px;
}

.modal-link {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--dim);
    text-decoration: none;
    transition: color 0.2s;
}

.modal-link:hover {
    color: var(--white);
}

.modal-link.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-btn {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--dim);
    border: 1px solid var(--faint);
    background: transparent;
    padding: 8px 10px;
    cursor: none;
    transition: color 0.2s, border-color 0.2s;
}

.modal-btn:hover {
    color: var(--white);
    border-color: var(--dim);
}

.modal-btn.primary {
    color: var(--white);
    border-color: var(--dim);
}

.modal-btn.disabled {
    opacity: 0.4;
    pointer-events: none;
}

@media (max-width: 1100px) {
    #mainCanvas {
        top: 122px;
        bottom: 114px;
        left: 120px;
        right: 120px;
        width: calc(100% - 240px);
        height: calc(100% - 236px);
    }

    #shapePanel {
        left: 18px;
    }

    #controlsPanel {
        right: 18px;
        max-width: calc(100vw - 36px);
    }
}

@media (max-width: 820px) {
    #topBar,
    #bottomBar {
        padding: 18px 16px;
    }

    #mainCanvas {
        top: 106px;
        bottom: 112px;
        left: 16px;
        right: 16px;
        width: calc(100% - 32px);
        height: calc(100% - 218px);
    }

    .wordmark {
        font-size: 10px;
        letter-spacing: 0.22em;
    }

    .nav-ghost,
    .stat-line {
        font-size: 8px;
    }

    .form-name {
        font-size: 20px;
    }

    .bottom-center {
        bottom: 18px;
    }

    .stat-right .stat-line:nth-child(2) {
        display: none;
    }

    #shapePanel {
        left: 10px;
        gap: 10px;
    }

    .shape-choice {
        font-size: 12px;
    }

    #controlsPanel {
        right: 10px;
        gap: 14px;
        max-height: calc(100vh - 40px);
    }
}

@media (hover: none), (pointer: coarse) {
    html,
    body {
        cursor: auto;
    }

    #cursor,
    #cursorRing {
        display: none;
    }

    .nav-ghost,
    .shape-choice,
    .form-dot,
    input[type="range"].ghost,
    .gif-loop-btn,
    .modal-close,
    .modal-btn {
        cursor: pointer;
    }
}

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