/* =====================
   GLOBAL / RESET
   ===================== */

:root {
    --accent: #c8ff00;
    --bg: #0d0d0d;
    --surface: #1a1a1a;
    --surface2: #242424;
    --border: #333;
    --text: #e8e8e8;
    --text-muted: #888;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* =====================
   LOGIN OVERLAY
   ===================== */

#login-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: var(--surface);
    padding: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    text-align: center;
    width: 320px;
}

.login-box h2 {
    color: var(--text);
    margin-bottom: 24px;
    font-size: 1.2rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-box input {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: #000;
    border: 1px solid #444;
    border-radius: 6px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.login-box input:focus {
    border-color: var(--accent);
}

.login-box button[type="submit"] {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 10px 20px;
    width: 100%;
    font-weight: bold;
    font-size: 0.95rem;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 4px;
    transition: opacity 0.2s;
}

.login-box button[type="submit"]:hover {
    opacity: 0.85;
}

#login-error {
    color: #ff5555;
    font-size: 0.85rem;
    margin-top: 4px;
}

/* =====================
   HEADER
   ===================== */

header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 14px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: relative;
}

.header-side { display: flex; align-items: center; min-height: 40px; }
.header-left { justify-content: flex-start; }
.header-right { justify-content: flex-end; }
.header-brand { pointer-events: none; }

.logo-area h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.logo-area p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

#back-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: border-color 0.2s, color 0.2s;
}

#back-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* =====================
   MAIN / APP
   ===================== */

#app {
    padding: 32px;
}

/* =====================
   DASHBOARD GRID
   ===================== */

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.gallery-card {
    background-color: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    height: 320px;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: transform 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
}

.gallery-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
}

/* Mosaic fills available space, rows/cols set by JS */
.card-mosaic {
    flex: 1;
    min-height: 0;      /* critical — lets flex child shrink below content size */
    display: grid;
    gap: 2px;
    padding: 2px;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 8px,
        rgba(255,255,255,0.02) 8px,
        rgba(255,255,255,0.02) 16px
    );
}

.mosaic-cell {
    min-width: 0;       /* prevent cells overflowing grid */
    min-height: 0;
    background-size: cover;
    background-position: center;
    background-color: var(--surface2);
    border-radius: 2px;
}

.card-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    flex-shrink: 0;
}

.card-name {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
}

.card-count {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
}



/* =====================
   GALLERY VIEW
   ===================== */

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

#count-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: border-color 0.2s, color 0.2s;
}

.secondary-btn:hover,
.secondary-btn.active {
    border-color: #ff5555;
    color: #ff5555;
}

.hidden-input {
    display: none;
}

.upload-btn {
    background: var(--accent);
    color: #000;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.upload-btn:hover {
    opacity: 0.85;
}

/* =====================
   IMAGE GRID
   ===================== */

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.image-grid p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.image-grid p.error {
    color: #ff5555;
}

.img-wrapper {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface2);
    aspect-ratio: 1;
    border: 1px solid var(--border);
}

.img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s;
}

.img-wrapper:hover img {
    opacity: 0.85;
}

.delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255, 50, 50, 0.85);
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.delete-btn:hover {
    background: #ff2222;
}

/* =====================
   3D MODEL THUMBNAIL
   ===================== */

.mosaic-cell-3d {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    border: 1px solid #3a3a6a;
}

.model-icon {
    font-size: 1.4rem;
    color: #7a7aff;
    line-height: 1;
}

.model-wrapper {
    background: #1a1a2e;
    border-color: #3a3a6a;
}

.model-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    padding: 12px;
    transition: background 0.2s;
}

.model-thumb:hover {
    background: rgba(122, 122, 255, 0.1);
}

.model-thumb-icon {
    font-size: 2.5rem;
    color: #7a7aff;
    line-height: 1;
}

.model-thumb-label {
    font-size: 0.7rem;
    color: #aaa;
    text-align: center;
    word-break: break-all;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-thumb-hint {
    font-size: 0.65rem;
    color: #7a7aff;
    opacity: 0.7;
}

/* =====================
   3D LIGHTBOX
   ===================== */

#lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.lightbox-box {
    width: 100%;
    max-width: 1100px;
    height: 80vh;
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.lightbox-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e8e8e8;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.lightbox-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.lightbox-close:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.lightbox-iframe {
    flex: 1;
    width: 100%;
    border: none;
    display: block;
}

/* 3D tile with preview image — show hint on hover */
.model-thumb.has-preview {
    position: relative;
}

.model-thumb.has-preview::after {
    content: '▶ View 3D';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    color: #7a7aff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    opacity: 0;
    transition: opacity 0.2s;
}

.model-thumb.has-preview:hover::after {
    opacity: 1;
}

/* =====================
   VIDEO / AUDIO TILES
   ===================== */

.mosaic-cell-media {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    border: 1px solid #444;
}

.mosaic-cell-audio {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2a;
    border: 1px solid #3a3a5a;
}

.media-icon {
    font-size: 1.2rem;
    color: #aaa;
}

.media-wrapper,
.audio-wrapper {
    background: #1a1a1a;
    border-color: #444;
}

.media-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    padding: 12px;
    transition: background 0.2s;
}

.media-thumb:hover {
    background: rgba(255,255,255,0.06);
}

.media-thumb-icon {
    font-size: 2.2rem;
    color: #ccc;
    line-height: 1;
}

.media-thumb-label {
    font-size: 0.7rem;
    color: #aaa;
    text-align: center;
    word-break: break-all;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audio-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
}

.audio-thumb-icon {
    font-size: 2rem;
    color: #7a7aff;
}

.audio-thumb-label {
    font-size: 0.7rem;
    color: #aaa;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audio-player {
    width: 100%;
    margin-top: 4px;
    accent-color: var(--accent);
}

/* Video lightbox */
.lightbox-video-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    padding: 0;
}

.lightbox-video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* =====================
   YOUTUBE TILES
   ===================== */

.yt-play-icon {
    font-size: 1.4rem;
    color: #ff4444;
    text-shadow: 0 0 8px rgba(0,0,0,0.8);
}

.yt-wrapper {
    background: #000;
    border-color: #333;
    aspect-ratio: 16/9 !important; /* override square */
}

.yt-embed-wrap {
    width: 100%;
    height: 100%;
    position: relative;
}

.yt-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* YouTube button */
.youtube-btn {
    background: #ff0000;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: opacity 0.2s;
}

.youtube-btn:hover {
    opacity: 0.85;
}

/* ── SPLAT TILES ── */
.mosaic-cell-splat{display:flex;align-items:center;justify-content:center;background:#0a1a1a;border:1px solid #1a4a4a}
.splat-icon{font-size:1.4rem;color:#4affda;text-shadow:0 0 8px rgba(74,255,218,0.6)}
.splat-wrapper{background:#0a1a1a;border-color:#1a4a4a}
.splat-thumb{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;cursor:pointer;padding:12px;transition:background 0.2s}
.splat-thumb:hover{background:rgba(74,255,218,0.08)}
.splat-thumb-icon{font-size:2.5rem;color:#4affda;text-shadow:0 0 12px rgba(74,255,218,0.6);line-height:1}
.splat-thumb-label{font-size:0.7rem;color:#aaa;text-align:center;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.splat-thumb.has-preview{position:relative}
.splat-thumb.has-preview::after{content:'✦ Explore';position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.55);color:#4affda;font-size:0.75rem;font-weight:600;letter-spacing:0.08em;opacity:0;transition:opacity 0.2s}
.splat-thumb.has-preview:hover::after{opacity:1}

/* ── TEXT / SUBTITLE TILES ── */
.mosaic-cell-text{display:flex;flex-direction:column;align-items:center;justify-content:center;background:#0a0a1a;border:1px solid #2a2a5a;position:relative;overflow:hidden}
.text-icon{font-size:10px;font-weight:600;color:#7a7aff;letter-spacing:0.1em;text-transform:uppercase}
.text-wrapper{background:#0a0a1a;border-color:#2a2a5a}
.text-thumb{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;cursor:pointer;padding:12px;transition:background 0.2s}
.text-thumb:hover{background:rgba(122,122,255,0.1)}
.text-thumb-icon{font-size:1.2rem;font-weight:700;color:#7a7aff;letter-spacing:0.15em}
.text-thumb-label{font-size:0.65rem;color:#aaa;text-align:center;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* Editor link button */
.scene-editor-link {
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.04em;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.scene-editor-link:hover {
    background: var(--accent);
    color: #000;
}

/* ── MOVE ASSET ── */
.lb-move-btn{
  padding:5px 12px;border-radius:5px;
  border:0.5px solid rgba(200,169,110,0.4);
  background:transparent;color:#c8a96e;
  font-family:monospace;font-size:11px;cursor:pointer;
  transition:all 0.15s;margin-left:auto;margin-right:8px;
}
.lb-move-btn:hover{background:rgba(200,169,110,0.15)}
.lb-board-btn{
  padding:6px 12px;border-radius:5px;
  border:0.5px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.04);
  color:#e8e4dc;font-family:monospace;font-size:11px;
  cursor:pointer;transition:all 0.15s;
}
.lb-board-btn:hover{border-color:#c8a96e;color:#c8a96e;background:rgba(200,169,110,0.08)}

/* ── PRO FORMAT TILES ── */
.format-badge{
  position:absolute;top:4px;right:4px;
  background:rgba(200,169,110,0.85);color:#000;
  font-size:7px;font-weight:700;letter-spacing:0.08em;
  padding:2px 4px;border-radius:3px;pointer-events:none;
}
.pro-img-wrapper{background:#0d0d1a;border-color:#2a2a4a}
.pro-img-tile{
  width:100%;height:100%;
  display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  gap:4px;padding:8px;cursor:pointer;
}
.pro-img-icon{font-size:22px;color:#c8a96e;line-height:1}
.pro-img-format{
  font-size:9px;font-weight:700;color:#c8a96e;
  letter-spacing:0.15em;text-transform:uppercase;
}
.pro-img-name{
  font-size:7px;color:rgba(232,228,220,0.4);
  text-align:center;max-width:100%;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}

/* ── LUT TILES ── */
.lut-wrapper{background:#0d1a0d;border-color:#2a4a2a}
.lut-no-preview{
  width:100%;height:100%;
  display:flex;flex-direction:column;
  align-items:center;justify-content:center;gap:4px;
}
.lut-icon{font-size:24px;color:#6af7a0;line-height:1}
.lut-format{font-size:9px;font-weight:700;color:#6af7a0;letter-spacing:0.15em}
.lut-badge{
  position:absolute;bottom:0;left:0;right:0;
  background:rgba(0,80,0,0.8);color:#6af7a0;
  font-size:8px;font-weight:700;letter-spacing:0.1em;
  padding:2px 4px;text-align:center;
}
