:root {
  --bg: #000000;
  --panel: #000000;
  --text: #ffffff;
  --muted: #b3b3b3;
  --accent: #38bdf8;
  --danger: #ff4d4d;
  --border: #111111;

  /* viewport-aware (JS sets these) */
  --app-vh: 100vh;
  --topbar-h: 44px;
  --footer-h: 20px;
  --scale: 1; /* spacing scale only (0.87–1.00 via app.js) */

  /* readable font sizes (fixed; no scaling) */
  --btn-fs: 12.5px;
  --text-fs: 13.5px;
  --th-fs: 12.5px;
  --title-fs: 16px;
  --editor-fs: 13px;

  /* compact paddings (these DO scale) */
  --pad-xxs: 2px;
  --pad-xs: 4px;
  --pad-s: 6px;
  --radius: 6px;
  --row-pad-y: 4px;
  --row-pad-x: 6px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  height: 100%;
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #222 var(--bg); }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: var(--bg); }
*::-webkit-scrollbar-thumb { background: #222; border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: #2a2a2a; }

/* Top bar with brand (logo + title) */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--pad-s) * var(--scale)) calc(var(--pad-s) * var(--scale));
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0; font-size: var(--title-fs); letter-spacing: .2px; }
.breadcrumbs { color: var(--muted); font-size: 12.5px; }

/* Main layout auto-sizes to viewport */
.layout {
  display: grid;
  grid-template-columns: 1.12fr 1fr;
  gap: calc(var(--pad-s) * var(--scale));
  padding: calc(var(--pad-s) * var(--scale));
  height: calc(var(--app-vh) - (var(--topbar-h) + var(--footer-h) + calc(var(--pad-s) * 2)));
}

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
  min-height: 0;
}

/* Panel header */
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--pad-xs) * var(--scale)) calc(var(--pad-s) * var(--scale));
  border-bottom: 1px solid var(--border);
  gap: calc(var(--pad-xs) * var(--scale)); background: var(--panel);
}
.panel-header h2 { margin: 0; font-size: 13px; color: var(--muted); }

/* Controls */
.path-controls { display: flex; gap: calc(var(--pad-xs) * var(--scale)); flex-wrap: wrap; align-items: center; }
.path-controls input {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: calc(var(--pad-xs) * var(--scale)) calc(var(--pad-s) * var(--scale));
  width: 240px; font-size: var(--text-fs);
}
.path-controls input:focus { outline: 1px solid var(--accent); }

.actions { display: flex; gap: calc(var(--pad-xs) * var(--scale)); align-items: center; }

button, .upload {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: calc(var(--pad-xs) * var(--scale)) calc(var(--pad-s) * var(--scale));
  cursor: pointer; font-size: var(--btn-fs); line-height: 1.05;
}
button:hover, .upload:hover { border-color: var(--accent); }
button:focus, .upload:focus { outline: 1px solid var(--accent); }
button.danger { border-color: #331a1a; color: #ffc7c7; }
button.danger:hover { background: #1a0d0d; border-color: var(--danger); }
.upload input { display: none; }

/* Dropzone */
.dropzone {
  margin: calc(var(--pad-xs) * var(--scale));
  padding: calc(var(--pad-s) * var(--scale));
  border: 2px dashed var(--border);
  text-align: center; color: var(--muted);
  border-radius: var(--radius); background: var(--panel);
  font-size: 12.5px;
}
.dropzone.hover { border-color: var(--accent); color: var(--text); }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-fs); }
.table th, .table td {
  border-bottom: 1px solid var(--border);
  padding: calc(var(--row-pad-y) * var(--scale)) calc(var(--row-pad-x) * var(--scale));
}
.table th { color: var(--muted); font-weight: 600; background: var(--panel); font-size: var(--th-fs); }
.table tr:hover td { background: #050505; }
.table td.right { text-align: right; }
.table td.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table a { color: var(--text); text-decoration: none; }
.table a:hover, .table a:focus { color: var(--accent); outline: none; }

/* Preview */
.preview {
  padding: calc(var(--pad-s) * var(--scale));
  overflow: auto; min-height: 0; height: 100%; background: var(--panel);
}
.preview .empty { color: var(--muted); padding: calc(var(--pad-s) * var(--scale)); }

/* Media/editor heights respect viewport (no page scroll) */
.media {
  max-width: 100%;
  max-height: calc(var(--app-vh) - (var(--topbar-h) + var(--footer-h) + 200px));
  display: block; margin: 0 auto;
  border-radius: var(--radius); border: 1px solid var(--border); background: #000;
}

#editor {
  width: 100%;
  height: calc(100% - 2px);
  min-height: calc(var(--app-vh) - (var(--topbar-h) + var(--footer-h) + 260px));
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: calc(var(--pad-s) * var(--scale));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--editor-fs); line-height: 1.3;
}
#editor:focus { outline: 1px solid var(--accent); }

/* Footer */
.footer {
  padding: calc(var(--pad-xs) * var(--scale)) calc(var(--pad-s) * var(--scale));
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12.5px; background: var(--panel);
}

/* DnD highlight */
tr.dz-target td { background: #0a0a0a !important; outline: 1px dashed #333; }

/* ===== Brand (spinning cube logo) ===== */
.brand { display: flex; align-items: center; gap: 8px; }
.logo-cube {
  --size: 22px;               /* logo size */
  width: var(--size);
  height: var(--size);
  perspective: 700px;         /* depth for 3D */
  display: inline-block;
}
.logo-cube .cube {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  animation: cube-spin 6s linear infinite; /* rotation speed */
}
@keyframes cube-spin {
  0%   { transform: rotateX(32deg) rotateY(45deg) rotateZ(0deg); }
  100% { transform: rotateX(32deg) rotateY(405deg) rotateZ(0deg); }
}

/* --- ORIGINAL SILVER MATERIAL (keeps strong 3D shading) --- */
.logo-cube .face {
  position: absolute;
  width: 100%; height: 100%;
  border-radius: 4px;
  background: linear-gradient(135deg, #f2f2f2 0%, #dcdcdc 35%, #c7c7c7 60%, #f7f7f7 100%);
  box-shadow:
    inset 0 0 0.6px rgba(255,255,255,0.6),
    inset 8px 8px 16px rgba(0,0,0,0.25),
    0 0 0.3px rgba(255,255,255,0.25);
}
/* bevel + subtle reflections */
.logo-cube .face::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 4px;
  background:
    radial-gradient(90% 90% at 10% 10%, rgba(0,0,0,0.20), transparent 55%),
    radial-gradient(90% 90% at 90% 90%, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}

/* 3D placement of faces */
.logo-cube .f-front  { transform: translateZ(calc(var(--size) / 2)); }
.logo-cube .f-back   { transform: rotateY(180deg) translateZ(calc(var(--size) / 2)); }
.logo-cube .f-right  { transform: rotateY(90deg)  translateZ(calc(var(--size) / 2)); }
.logo-cube .f-left   { transform: rotateY(-90deg) translateZ(calc(var(--size) / 2)); }
.logo-cube .f-top    { transform: rotateX(90deg)  translateZ(calc(var(--size) / 2)); }
.logo-cube .f-bottom { transform: rotateX(-90deg) translateZ(calc(var(--size) / 2)); }

/* floating shadow for depth */
.logo-cube::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -6px; transform: translateX(-50%);
  width: 70%; height: 6px;
  background: radial-gradient(50% 100% at 50% 0%, rgba(0,0,0,0.35), transparent 70%);
  filter: blur(2px);
  pointer-events: none;
}

/* optional: subtle glint */
.logo-cube .cube::before {
  content: "";
  position: absolute; inset: -20%;
  background:
    linear-gradient(120deg, transparent 35%, rgba(255,255,255,0.07) 45%, rgba(255,255,255,0.18) 50%, rgba(255,255,255,0.07) 55%, transparent 65%);
  transform: translateZ(0);
  pointer-events: none;
  mix-blend-mode: screen;
  animation: cube-glint 3.5s linear infinite;
}
@keyframes cube-glint {
  0%   { transform: translate(-20%, -20%) rotate(0deg); }
  100% { transform: translate(20%, 20%) rotate(0deg); }
}

/* reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .logo-cube .cube { animation: none; transform: rotateX(32deg) rotateY(45deg); }
  .logo-cube .cube::before { animation: none; opacity: 0.5; }
}

/* Upload tray */
.upload-tray {
  position: fixed;
  left: calc(var(--pad-s) * var(--scale));
  right: calc(var(--pad-s) * var(--scale));
  bottom: calc(var(--pad-s) * var(--scale));
  background: #000; border: 1px solid var(--border); border-radius: 8px;
}
.upload-tray.hidden { display: none; }
.upload-tray-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--pad-xs) * var(--scale)) calc(var(--pad-s) * var(--scale));
  border-bottom: 1px solid var(--border);
}
.upload-tray-title { font-size: 12.5px; color: var(--muted); }
.upload-tray-actions { display: flex; gap: calc(var(--pad-xs) * var(--scale)); }
.upload-list { max-height: 30vh; overflow: auto; padding: calc(var(--pad-xs) * var(--scale)) calc(var(--pad-s) * var(--scale)); }

.upload-row { padding: calc(var(--pad-xs) * var(--scale)) 0; border-bottom: 1px dashed #0f0f0f; }
.upload-row:last-child { border-bottom: none; }
.upload-meta { display: flex; align-items: baseline; justify-content: space-between; gap: calc(var(--pad-xs) * var(--scale)); }
.upload-name { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-status { font-size: 12.5px; color: var(--muted); }
.upload-bar-wrap { height: 4px; background: #0a0a0a; border: 1px solid var(--border); border-radius: 999px; margin-top: 3px; }
.upload-bar { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width 0.15s linear; }
.upload-actions { margin-top: 3px; text-align: right; }
.upload-row.done .upload-bar { background: #22c55e; width: 100% !important; }
.upload-row.done .upload-status { color: #22c55e; }
.upload-row.error .upload-bar { background: var(--danger); }
.upload-row.error .upload-status { color: var(--danger); }
.upload-row.canceled .upload-bar { background: #333; }
.upload-row.canceled .upload-status { color: var(--muted); }

/* Narrow screens */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .media { max-height: calc(var(--app-vh) - (var(--topbar-h) + var(--footer-h) + 260px)); }
}

/* === Gold tint without flattening (keeps silver shading) === */
/* Add this at the end so it overrides material via filters only */
.logo-cube .cube {
  filter: sepia(1) saturate(2.2) hue-rotate(-10deg) brightness(1.05) contrast(1.06);
}
/* Optional per-face depth nudges (can delete if you want uniform tint) */
.logo-cube .f-top    { filter: sepia(1) saturate(2.2) hue-rotate(-10deg) brightness(1.12) contrast(1.06); }
.logo-cube .f-right  { filter: sepia(1) saturate(2.2) hue-rotate(-10deg) brightness(0.92) contrast(1.06); }
.logo-cube .f-left   { filter: sepia(1) saturate(2.2) hue-rotate(-10deg) brightness(0.85) contrast(1.06); }
.logo-cube .f-bottom { filter: sepia(1) saturate(2.2) hue-rotate(-10deg) brightness(0.75) contrast(1.06); }
.logo-cube .f-back   { filter: sepia(1) saturate(2.2) hue-rotate(-10deg) brightness(0.70) contrast(1.06); }

/* If you prefer no extra glint tinting, you can leave ::before as-is; it's subtle already */
