:root {
  --bg: #050505;
  --panel: #111;
  --panel-2: #181818;
  --text: #f7f7f7;
  --muted: #a6a6a6;
  --line: #2a2a2a;
  --soft: #e8e8e8;
  --danger: #f2b8b8;
  --radius: 8px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button,
.button-link {
  min-height: 44px;
  border: 1px solid var(--soft);
  border-radius: var(--radius);
  background: var(--text);
  color: #050505;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.button-link:hover {
  background: #dcdcdc;
}

.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.ghost:hover {
  background: #1f1f1f;
}

.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-shell {
  width: min(100%, 420px);
}

.auth-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 17, 17, 0.96);
}

.auth-panel {
  padding: 34px;
}

.auth-panel.wide {
  width: min(100%, 500px);
}

.overline {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(32px, 5vw, 52px);
}

h2 {
  font-size: 24px;
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #080808;
  color: var(--text);
  padding: 0 13px;
  outline: none;
}

input:focus,
select:focus {
  border-color: #fff;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.topbar,
.viewer-top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 clamp(16px, 4vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 5, 5, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  font-size: 15px;
  font-weight: 900;
}

nav,
.viewer-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 36px) 56px;
}

.upload-panel {
  grid-row: span 2;
}

.panel {
  padding: 22px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.section-head.compact {
  align-items: center;
  margin-bottom: 16px;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 210px;
  border: 1px dashed #555;
  border-radius: var(--radius);
  background: #0b0b0b;
  padding: 28px;
  text-align: center;
  cursor: pointer;
}

.dropzone.is-dragging {
  border-color: #fff;
  background: #151515;
}

.dropzone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone strong,
.dropzone span {
  display: block;
}

.dropzone strong {
  font-size: 20px;
  margin-bottom: 8px;
}

.dropzone span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.queue {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.queue-row,
.media-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 8px;
}

.queue-thumb,
.media-thumb {
  width: 64px;
  height: 42px;
  object-fit: cover;
  border-radius: 5px;
  background: #000;
  border: 1px solid #2c2c2c;
}

.row-title {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.progress {
  width: 100%;
  height: 5px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #333;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: #fff;
}

.media-list {
  display: grid;
  gap: 10px;
}

.media-row {
  cursor: grab;
}

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

.icon-btn {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.viewer-page {
  overflow: hidden;
}

.viewer-top {
  position: fixed;
  left: 0;
  right: 0;
}

.viewer-scene {
  position: fixed !important;
  inset: 0 !important;
  display: block !important;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  z-index: 1;
}

.viewer-scene canvas.a-canvas {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
}

.desktop-controls,
.thumb-strip {
  position: fixed;
  z-index: 25;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(5, 5, 5, 0.76);
  backdrop-filter: blur(14px);
}

.desktop-controls {
  bottom: 92px;
  padding: 8px;
}

.desktop-controls span {
  min-width: 62px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.thumb-strip {
  bottom: 18px;
  max-width: min(94vw, 840px);
  overflow-x: auto;
  padding: 7px;
}

.thumb-strip button {
  flex: 0 0 auto;
  width: 58px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  overflow: hidden;
  border-color: transparent;
  background: #151515;
}

.thumb-strip button.is-active {
  border-color: #fff;
}

.thumb-strip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.loading,
.empty-state {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(5, 5, 5, 0.9);
  padding: 22px;
  text-align: center;
}

.empty-state {
  width: min(92vw, 460px);
}

.empty-state p {
  color: var(--muted);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .viewer-top {
    min-height: 56px;
  }

  .desktop-controls {
    bottom: 78px;
    width: min(94vw, 460px);
    justify-content: center;
  }

  .desktop-controls button {
    min-width: 0;
    padding: 0 10px;
  }
}
