/* --- FAB add button --- */
.bottom-center-wrap {
    position: absolute;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}
.bottom-center-wrap > * { pointer-events: auto; }

.add-fab-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.add-fab-wrap.hidden { display: none; }

/* Props panel */
.props-panel {
    display: none;
    flex-direction: column;
    gap: 8px;
    background: rgba(20, 20, 22, 0.70);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 18px;
    padding: 14px;
    width: 200px;
    box-shadow: 0 4px 32px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
    animation: popup-in 0.18s cubic-bezier(.34,1.56,.64,1);
}
.props-panel.visible { display: flex; }

.add-fab {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.9);
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.12);
    transition: transform 0.18s, background 0.18s;
    padding: 0;
    margin: 0;
}
.add-fab-icon { width: 24px; height: 24px; display: block; pointer-events: none; opacity: 0.88; transition: opacity 0.18s; }
.add-fab:hover .add-fab-icon { opacity: 1; }
.add-fab:hover  { background: rgba(255,255,255,0.18); transform: scale(1.08); }
.add-fab:active { transform: scale(0.93); }
.add-fab.open   { transform: rotate(45deg) scale(1.08); background: rgba(255,255,255,0.15); }

.add-popup {
    width: 200px;
    display: none;
    flex-direction: column;
    gap: 8px;
    background: rgba(20, 20, 22, 0.70);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 4px 32px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
    animation: popup-in 0.18s cubic-bezier(.34,1.56,.64,1);
}
.add-popup.visible { display: flex; }
@keyframes popup-in {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    background: #0e0e0e;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
    color: rgba(255,255,255,0.88);
    user-select: none;
}

/* ─── Panel containers ─── */
.panel {
    position: absolute;
    top: 20px;
    z-index: 100;
    pointer-events: none;
}
.panel > * { pointer-events: auto; }
.panel-left  { left: 20px; }
.panel-right { right: 20px; }
.panel-vcenter { top: 50%; transform: translateY(-50%); }

/* ─── Glass card ─── */
.card {
    background: rgba(20, 20, 22, 0.70);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 18px;
    padding: 14px;
    width: 214px;
    box-shadow: 0 4px 32px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ─── Status pill ─── */
.status-pill {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.28);
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    transition: color 0.2s;
}
.status-pill.active  { color: #00e5ff; }
.status-pill.drawing { color: #c39bd3; }

/* ─── Separator ─── */
.sep {
    height: 1px;
    background: rgba(255,255,255,0.07);
}

/* ─── Icon button row ─── */
.icon-row {
    display: flex;
    gap: 6px;
}

/* ─── Icon buttons ─── */
.icon-btn {
    flex: 1;
    height: 43px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    color: rgba(255,255,255,0.75);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.14s, transform 0.1s, border-color 0.14s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    width: auto;
    font-weight: normal;
    line-height: 1;
}
.icon-btn:hover  { background: rgba(255,255,255,0.13); transform: scale(1.05); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn img { width: 22px; height: 22px; display: block; pointer-events: none; opacity: 0.82; }
.icon-btn:hover img { opacity: 1; }
.icon-btn.icon-flip { background: rgba(241,196,15,0.13); color: #f1c40f; border-color: rgba(241,196,15,0.18); }
.icon-btn.icon-copy { background: rgba(46,204,113,0.13); color: #2ecc71; border-color: rgba(46,204,113,0.18); }
.icon-btn.icon-cut  { background: rgba(255,80,80,0.1); color: rgba(255,100,100,0.8); border-color: rgba(255,80,80,0.2); }
.icon-btn.icon-cut.cutting { background: rgba(255,50,50,0.25); color: #ff4444; border-color: rgba(255,50,50,0.5); animation: pulse-cut 1.1s infinite alternate; }
@keyframes pulse-cut { from { box-shadow: 0 0 0 0 rgba(255,50,50,0.5); } to { box-shadow: 0 0 0 5px rgba(255,50,50,0); } }

.icon-btn.icon-danger:hover { background: rgba(231,76,60,0.3); color: #ff6b6b; border-color: rgba(231,76,60,0.35); }
.icon-btn#draw-btn  { background: rgba(142,68,173,0.18); color: #c39bd3; border-color: rgba(142,68,173,0.28); }
.icon-btn#draw-btn.drawing { background: rgba(142,68,173,0.42); color: #e8daef; border-color: rgba(180,100,220,0.5); animation: pulse-draw 1.2s infinite alternate; }
@keyframes pulse-draw { from { box-shadow: 0 0 0 0 rgba(142,68,173,0.5); } to { box-shadow: 0 0 0 5px rgba(142,68,173,0); } }

/* ─── Shape grid (4 equal cols) ─── */
.shape-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

/* ─── Color swatches ─── */
.swatch-row {
    display: flex;
    gap: 8px;
}
.swatch-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.swatch-label {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    color: rgba(255,255,255,0.28);
    text-transform: uppercase;
}
input[type="color"] {
    width: 100%;
    height: 28px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    cursor: pointer;
    background: none;
    padding: 2px;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; border-radius: 6px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

/* ─── Panel title (objects list) ─── */
.panel-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.25);
    padding-bottom: 7px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

/* ─── Object list ─── */
.obj-list-scroll {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 190px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}
.obj-list-scroll::-webkit-scrollbar { width: 3px; }
.obj-list-scroll::-webkit-scrollbar-track { background: transparent; }
.obj-list-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
.obj-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    border-radius: 10px;
    cursor: pointer;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    transition: background 0.12s, border-color 0.12s;
    font-size: 1rem;
    color: rgba(255,255,255,0.65);
}
.obj-row:hover  { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.12); }
.obj-row.selected  { background: rgba(0,229,255,0.09); border-color: rgba(0,229,255,0.32); color: #00e5ff; }
.obj-row.drag-over { border-color: rgba(241,196,15,0.5); background: rgba(241,196,15,0.07); }
.obj-row[draggable] { cursor: grab; }
.obj-handle { color: rgba(255,255,255,0.18); font-size: 1rem; cursor: grab; flex-shrink: 0; }
.obj-thumb { flex-shrink: 0; display: block; border-radius: 4px; overflow: hidden; opacity: 0.85; }
.obj-row.selected .obj-thumb polygon { stroke: rgba(0,229,255,0.55); }
.obj-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-delete {
    background: none; border: none;
    color: rgba(255,255,255,0.18);
    cursor: pointer; font-size: 1rem; padding: 0 2px;
    width: auto; margin: 0; line-height: 1; transition: opacity 0.12s;
    display: flex; align-items: center;
}
.obj-delete img { width: 14px; height: 14px; opacity: 0.3; pointer-events: none; transition: opacity 0.12s; }
.obj-delete:hover img { opacity: 0.85; background: none; }

/* ─── Side action button (save etc.) ─── */
.side-btn {
    width: 62px;
    height: 62px;
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.18s, background 0.18s;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.12);
    padding: 0;
    margin: 0;
}
.side-btn:hover  { background: rgba(255,255,255,0.18); transform: scale(1.08); }
.side-btn:active { transform: scale(0.93); }
.side-btn img { width: 24px; height: 24px; opacity: 0.82; pointer-events: none; display: block; }
.side-btn:hover img { opacity: 1; }

/* ─── Texture file button ─── */
.tex-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.10);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s, transform 0.1s;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    position: relative;
}
.tex-btn:hover { background-color: rgba(255,255,255,0.14); transform: scale(1.05); }
.tex-btn.has-tex { font-size: 0; border-color: rgba(0,229,255,0.45); }
.tex-btn input[type="file"] { display: none; }

/* ─── Combined color+texture slot ─── */
.ct-row {
    display: flex;
    gap: 8px;
}
.ct-slot {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.ct-box {
    position: relative;
    width: 100%;
    height: 52px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}
.ct-box input[type="color"] {
    position: absolute;
    inset: 0;
    width: 101%;
    height: 101%;
    border: none;
    padding: 0;
    border-radius: 0;
    cursor: pointer;
}
.ct-box input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; border-radius: 0; }
.ct-box input[type="color"]::-webkit-color-swatch { border: none; border-radius: 0; }
.ct-tex-thumb {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    display: none;
    pointer-events: none;
}
.ct-tex-thumb.active { display: block; }
.ct-add-tex {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border: 0px solid;
    border-radius: 50%;
    background: rgba(0,0,0,0.48);
    backdrop-filter: blur(4px);
    color: rgba(255,255,255,0.85);
    font-size: 1rem;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
}
.ct-add-tex:hover { background: rgba(255,255,255,0.28); }
.ct-add-tex.hidden { display: none; }
.ct-add-tex input[type="file"] { display: none; }
.ct-clear-tex {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.48);
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 1rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.12s;
}
.ct-clear-tex.active { display: flex; }
.ct-clear-tex:hover { background: rgba(231,76,60,0.75); color: #fff; }

/* ─── Material Picker Popup ─── */
#material-picker-popup {
    position: fixed;
    z-index: 9999;
    background: rgba(24,24,34,0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    padding: 12px 12px 10px;
    width: 230px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    display: none;
    flex-direction: column;
    gap: 0;
}
#material-picker-popup.visible { display: flex; }
.mp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.mp-title { color: rgba(255,255,255,0.6); font-size: 1rem; text-transform: uppercase; letter-spacing: 0.07em; }
.mp-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    transition: color 0.1s, background 0.1s;
}
.mp-close:hover { color: #fff; background: rgba(255,255,255,0.1); }
.mp-body { display: flex; flex-direction: column; gap: 6px; }
.mp-section-label {
    color: rgba(255,255,255,0.35);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 4px;
}
.mp-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 28px;
}
.mp-swatch {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.08);
    transition: border-color 0.12s, transform 0.12s;
}
.mp-swatch:hover { border-color: rgba(255,255,255,0.55); transform: scale(1.12); }
.mp-textures-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.mp-tex-item {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.08);
    background-size: cover;
    background-position: center;
    background-color: rgba(255,255,255,0.07);
    transition: border-color 0.12s, transform 0.12s;
}
.mp-tex-item:hover { border-color: rgba(255,255,255,0.55); transform: scale(1.08); }
.mp-load-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 7px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.55);
    font-size: 1rem;
    cursor: pointer;
    border: 1px dashed rgba(255,255,255,0.18);
    transition: background 0.12s, color 0.12s;
    margin-top: 6px;
}
.mp-load-btn:hover { background: rgba(255,255,255,0.13); color: rgba(255,255,255,0.85); }
.mp-load-btn input[type="file"] { display: none; }
.mp-empty { color: rgba(255,255,255,0.25); font-size: 1rem; font-style: italic; }

/* ─── Logo ─── */
.logo-top {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    pointer-events: none;
    user-select: none;
}
.logo-text {
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 900;
    font-size: 2rem;
    color: #ffffff;
    letter-spacing: -0.01em;
    line-height: 1;
}
.logo-dot {
    color: #3b9eff;
}

/* ─── Dev credit ─── */
.dev-credit {
    position: fixed;
    bottom: 14px;
    right: 18px;
    z-index: 100;
    color: rgba(255,255,255,0.22);
    font-size: 1rem;
    line-height: 1;
    pointer-events: none;
    user-select: none;
    letter-spacing: 0.02em;
}
.dev-credit a {
    color: rgba(255,255,255,0.3);
    text-decoration: none;
    pointer-events: all;
    transition: color 0.15s;
}
.dev-credit a:hover { color: rgba(255,255,255,0.6); }

/* ─── Tips block ─── */
.tips-block {
    position: fixed;
    bottom: 18px;
    left: 18px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    pointer-events: none;
    user-select: none;
}
.tip-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.tip-key {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 5px;
    color: rgba(255,255,255,0.45);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 2px 5px;
    line-height: 1.4;
    white-space: nowrap;
}
.tip-desc {
    color: rgba(255,255,255,0.22);
    font-size: 1rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* ─── New file button ─── */
.new-file-btn {
    margin-top: 8px;
    width: 100%;
    padding: 8px 0;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    color: rgba(255,255,255,0.3);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.14s, color 0.14s, border-color 0.14s;
    letter-spacing: 0.02em;
}
.new-file-btn:hover {
    background: rgba(231,76,60,0.12);
    border-color: rgba(231,76,60,0.25);
    color: rgba(255,120,100,0.85);
}

/* ─── New file confirm modal ─── */
.nf-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s;
}
.nf-overlay.visible {
    opacity: 1;
    pointer-events: all;
}
.nf-modal {
    background: rgba(22,22,28,0.98);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 28px 28px 22px;
    width: 300px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: popup-in 0.18s cubic-bezier(.34,1.56,.64,1);
}
.nf-title {
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    letter-spacing: 0.01em;
}
.nf-desc {
    font-size: 1rem;
    color: rgba(255,255,255,0.4);
    line-height: 1.5;
}
.nf-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}
.nf-btn {
    flex: 1;
    padding: 10px 0;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.14s, color 0.14s;
}
.nf-btn-cancel {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.55);
}
.nf-btn-cancel:hover { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.9); }
.nf-btn-confirm {
    background: rgba(231,76,60,0.18);
    color: rgba(255,120,100,0.9);
    border-color: rgba(231,76,60,0.3);
}
.nf-btn-confirm:hover { background: rgba(231,76,60,0.35); color: #fff; border-color: rgba(231,76,60,0.55); }
