@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --bg: #030405;
    --panel-bg: rgba(9, 13, 18, 0.82);
    --panel-border: rgba(120, 220, 232, 0.28);
    --panel-border-strong: rgba(120, 220, 232, 0.55);
    --accent: #6fe8ec;
    --accent-dim: #2c5f63;
    --accent-soft: rgba(111, 232, 236, 0.12);
    --text: #dff4f5;
    --text-dim: #7c9598;
    --danger: #ff8a65;
    --radius: 10px;
    --font: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--bg);
    font-family: var(--font);
    touch-action: none; /* let OrbitControls own pinch/pan instead of the browser */
    -webkit-tap-highlight-color: transparent;
}

canvas {
    display: block;
    touch-action: none;
}

.no-select {
    user-select: none;
    -webkit-user-select: none;
}

/* ---------- Floating panels ---------- */

.float_window {
    display: none;
    color: var(--text);
    background: var(--panel-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--panel-border);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.4),
        0 12px 32px rgba(0, 0, 0, 0.55),
        0 0 24px rgba(111, 232, 236, 0.06);
    position: fixed;
    left: 200px;
    top: 200px;
    width: 230px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    padding: 0;
    border-radius: var(--radius);
    text-align: left;
    font-size: 12px;
    line-height: 1.4;
    cursor: default;
    z-index: 20;
    animation: panel-in 0.18s ease-out;
}

@keyframes panel-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header bar shared by both panels */
.panel_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--panel-border);
    cursor: move;
    touch-action: none;
    background: linear-gradient(180deg, rgba(111, 232, 236, 0.06), transparent);
}

.panel_header .title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status_dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px 1px var(--accent);
    flex: none;
    animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

.panel_body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ---------- Field groups ---------- */

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

.field label {
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.field_row {
    display: grid;
    grid-template-columns: 46px 1fr;
    align-items: center;
    gap: 8px;
}

.field_row label {
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.divider {
    height: 1px;
    background: var(--panel-border);
    margin: 2px 0;
    border: none;
}

.slider_row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.slider_value {
    font-size: 10px;
    color: var(--accent);
    min-width: 16px;
    text-align: right;
}

/* ---------- Inputs ---------- */

.float_window input[type="text"] {
    width: 100%;
    margin: 0;
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    padding: 4px 6px;
    font-family: var(--font);
    font-size: 11px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.float_window input[type="text"]:hover {
    border-color: var(--panel-border-strong);
}

.float_window input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.float_window select {
    width: 100%;
    color: var(--text);
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    padding: 5px 22px 5px 7px;
    font-family: var(--font);
    font-size: 11px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M0 0 L5 6 L10 0 Z' fill='%236fe8ec'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 9px 6px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.float_window select:hover,
.float_window select:focus {
    border-color: var(--accent);
    outline: none;
}

.float_window select option {
    background: #0a0e13;
    color: var(--text);
}

/* Checkbox */
.float_window input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--panel-border-strong);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.03);
    display: inline-block;
    vertical-align: middle;
    position: relative;
    cursor: pointer;
    margin: 0 6px 0 0;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.float_window input[type="checkbox"]:checked {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.float_window input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 0px;
    width: 4px;
    height: 8px;
    border: solid var(--accent);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox_row {
    display: flex;
    align-items: center;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
}

/* Range slider */
.float_window input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 3px;
    background: var(--panel-border);
    border-radius: 2px;
    outline: none;
}

.float_window input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px 1px rgba(111, 232, 236, 0.6);
    cursor: pointer;
    border: none;
    margin-top: -0.5px;
}

.float_window input[type="range"]::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px 1px rgba(111, 232, 236, 0.6);
    cursor: pointer;
    border: none;
}

/* ---------- Buttons ---------- */

.float_window button {
    font-family: var(--font);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border-strong);
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.float_window button:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.float_window button:active {
    transform: translateY(1px);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.actions_row {
    display: flex;
    gap: 6px;
}

.actions_row button {
    flex: 1;
}

.reset_btn {
    color: var(--danger) !important;
}

.reset_btn:hover {
    border-color: var(--danger) !important;
    background: rgba(255, 138, 101, 0.1) !important;
    color: var(--danger) !important;
}

/* Close (object panel) */
.icon_btn {
    flex: none;
    width: 20px;
    height: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    border-radius: 5px;
}

/* ---------- Object inspector specifics ---------- */

#draggable .panel_body {
    gap: 8px;
}

#draggable2 {
    display: block;
    top: 14px;
    left: 14px;
    width: 220px;
    height: auto;
    text-align: left;
}

/* ---------- Mobile / touch ---------- */

@media (max-width: 600px), (pointer: coarse) {
    .float_window input[type="text"],
    .float_window select {
        font-size: 16px; /* stops iOS Safari zooming the page in on focus */
        padding: 7px 8px;
    }

    .float_window select {
        padding-right: 26px;
    }

    .float_window button,
    .icon_btn {
        min-height: 36px;
    }

    .icon_btn {
        width: 28px;
    }

    .float_window input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    .float_window input[type="checkbox"]:checked::after {
        left: 4px;
        top: 1px;
        width: 5px;
        height: 10px;
    }

    #draggable {
        left: min(200px, calc(100vw - 244px));
        top: min(200px, calc(100vh - 300px));
    }

    #draggable2 {
        width: min(220px, calc(100vw - 28px));
    }
}
