:root {
  --bg-0: #0c0f13;
  --bg-1: #151a22;
  --bg-2: #1c2330;
  --accent: #4de1b7;
  --accent-2: #7aa3ff;
  --text-0: #eef2f8;
  --text-1: #b9c3d6;
  --muted: #6f7b93;
  --card: rgba(21, 26, 34, 0.8);
  --border: rgba(122, 163, 255, 0.16);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Sora", "Avenir Next", "Helvetica Neue", sans-serif;
  color: var(--text-0);
  background: radial-gradient(1000px 800px at 80% -10%, rgba(122, 163, 255, 0.25), transparent 60%),
    radial-gradient(900px 700px at -20% 20%, rgba(77, 225, 183, 0.2), transparent 50%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
  min-height: 100vh;
}

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.login-panel {
  width: min(92vw, 420px);
  padding: 28px 26px 30px;
  border-radius: 18px;
  background: rgba(10, 14, 20, 0.95);
  border: 1px solid rgba(122, 163, 255, 0.2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-brand .brand-title {
  font-size: 24px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--text-1);
}

.login-label input {
  background: rgba(12, 15, 19, 0.7);
  border: 1px solid rgba(122, 163, 255, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text-0);
  font-size: 14px;
}

.login-error {
  font-size: 12px;
  color: #ff8f8f;
}

.login-submit {
  margin-top: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(122, 163, 255, 0.3);
  background: rgba(122, 163, 255, 0.2);
  color: var(--text-0);
  cursor: pointer;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  backdrop-filter: blur(8px);
}

.sidebar {
  padding: 28px 24px;
  background: linear-gradient(180deg, rgba(15, 19, 26, 0.98), rgba(12, 15, 19, 0.9));
  border-right: 1px solid rgba(122, 163, 255, 0.1);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.brand {
  margin-bottom: 24px;
}

.user-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(122, 163, 255, 0.15);
  background: rgba(12, 15, 19, 0.6);
  margin-bottom: 18px;
}

.user-name {
  font-size: 12px;
  color: var(--text-1);
}

.ghost-button {
  border: 1px solid rgba(122, 163, 255, 0.25);
  background: transparent;
  color: var(--text-0);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  cursor: pointer;
}

.upload {
  margin-bottom: 18px;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(122, 163, 255, 0.25);
  background: rgba(122, 163, 255, 0.12);
  color: var(--text-0);
  cursor: pointer;
  font-size: 12px;
}

.upload-button input {
  display: none;
}

.upload-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.upload-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.uploader {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
}

.uploader.hidden {
  display: none;
}

.uploader-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 10, 14, 0.78);
  backdrop-filter: blur(6px);
}

.uploader-content {
  position: relative;
  z-index: 1;
  width: min(90vw, 900px);
  height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  background: rgba(10, 14, 20, 0.96);
  border: 1px solid rgba(122, 163, 255, 0.2);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.uploader-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(122, 163, 255, 0.12);
}

.uploader-title {
  font-size: 18px;
  font-weight: 600;
}

.uploader-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.uploader-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(12, 15, 19, 0.7);
  color: var(--text-0);
  cursor: pointer;
}

.uploader-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.uploader-drop {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px dashed rgba(122, 163, 255, 0.4);
  color: var(--text-0);
  cursor: pointer;
  background: rgba(122, 163, 255, 0.12);
  transition: border-color 160ms ease, background 160ms ease;
}

.uploader-drop.dragover {
  border-color: var(--accent);
  background: rgba(77, 225, 183, 0.18);
}

.uploader-drop input {
  display: none;
}

.uploader-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid rgba(122, 163, 255, 0.12);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  background: rgba(12, 15, 19, 0.6);
  border: 1px solid rgba(122, 163, 255, 0.08);
}

.upload-row input {
  background: rgba(12, 15, 19, 0.6);
  border: 1px solid rgba(122, 163, 255, 0.2);
  border-radius: 8px;
  color: var(--text-0);
  padding: 6px 8px;
  font-size: 12px;
}

.upload-row .filename {
  font-size: 12px;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-row .status {
  font-size: 12px;
  color: var(--muted);
}

.uploader-actions {
  padding: 14px 20px;
  border-top: 1px solid rgba(122, 163, 255, 0.12);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.uploader-buttons {
  display: flex;
  gap: 10px;
}

.uploader-btn {
  background: rgba(122, 163, 255, 0.2);
  color: var(--text-0);
  border: 1px solid rgba(122, 163, 255, 0.3);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}

.uploader-btn.ghost {
  background: transparent;
}
.brand-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.scan-status {
  margin-top: 10px;
}

.scan-status.hidden {
  display: none;
}

.scan-text {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.scan-bar {
  margin-top: 6px;
  width: 160px;
  height: 4px;
  border-radius: 999px;
  background: rgba(122, 163, 255, 0.15);
  overflow: hidden;
}

.scan-bar-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, rgba(122, 163, 255, 0.2), rgba(77, 225, 183, 0.8));
  animation: none;
}

.scan-bar-fill.indeterminate {
  animation: scan-bar-move 1.2s ease-in-out infinite;
}

@keyframes scan-bar-move {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(200%);
  }
}

.tree {
  font-size: 13px;
  color: var(--text-1);
  height: calc(100% - 96px);
  overflow-y: auto;
  padding-right: 6px;
}

.tree button {
  all: unset;
  cursor: pointer;
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  width: 100%;
  transition: background 160ms ease, color 160ms ease;
}

.tree .label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tree .caret {
  width: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: transform 160ms ease;
}

.tree-item.open > button .caret {
  transform: rotate(90deg);
}

.tree-item .node {
  display: none;
}

.tree-item.open > .node {
  display: block;
}

.tree button:hover {
  background: rgba(122, 163, 255, 0.15);
  color: var(--text-0);
}

.tree button.active {
  background: rgba(77, 225, 183, 0.2);
  color: var(--text-0);
}

.tree .node {
  margin-left: 12px;
  border-left: 1px dashed rgba(122, 163, 255, 0.12);
  padding-left: 10px;
}

.main {
  padding: 28px 32px 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.auth-warning {
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  background: rgba(255, 143, 143, 0.12);
  border: 1px solid rgba(255, 143, 143, 0.35);
  color: #ffd2d2;
  font-size: 12px;
}


.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

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

.toolbar-actions .meta {
  white-space: nowrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-1);
  background: rgba(122, 163, 255, 0.12);
  border: 1px solid rgba(122, 163, 255, 0.2);
  padding: 6px 10px;
  border-radius: 999px;
}

.toggle input {
  accent-color: var(--accent);
}

.current {
  font-size: 16px;
  font-weight: 600;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

@keyframes preview-spin {
  to {
    transform: rotate(360deg);
  }
}

.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
  min-height: 0;
}

.group-header {
  flex: 0 0 100%;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 6px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.grid-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 40px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(12, 15, 20, 0.55);
  backdrop-filter: blur(4px);
  z-index: 30;
  color: var(--text-0);
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(122, 163, 255, 0.35);
  border-top-color: rgba(122, 163, 255, 0.95);
  animation: preview-spin 0.7s linear infinite;
}

.loading-spinner.small {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.loading-text {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.page-loading {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(12, 15, 20, 0.85);
  border: 1px solid rgba(122, 163, 255, 0.2);
  border-radius: 999px;
  padding: 8px 12px;
  z-index: 20;
}

.page-loading.hidden {
  display: none;
}

.load-more {
  display: flex;
  justify-content: center;
  margin-top: 18px;
  gap: 12px;
  align-items: center;
}

.load-more.hidden {
  display: none;
}

.load-more button {
  background: rgba(122, 163, 255, 0.2);
  color: var(--text-0);
  border: 1px solid rgba(122, 163, 255, 0.3);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.load-more button:hover {
  background: rgba(77, 225, 183, 0.25);
  transform: translateY(-2px);
}

.load-status {
  color: var(--muted);
  font-size: 12px;
  display: none;
}

.load-more.loading .load-status {
  display: inline;
}

.load-more.loading button {
  opacity: 0.4;
  pointer-events: none;
}


.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.hidden {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 10, 14, 0.78);
  backdrop-filter: blur(6px);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  width: min(99.2vw, 2200px);
  height: min(99.2vh, 1200px);
  display: flex;
  flex-direction: column;
  background: rgba(10, 14, 20, 0.95);
  border: 1px solid rgba(122, 163, 255, 0.2);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.lightbox-media {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  background: radial-gradient(circle at 20% 20%, rgba(77, 225, 183, 0.08), transparent 50%),
    radial-gradient(circle at 80% 10%, rgba(122, 163, 255, 0.12), transparent 55%),
    #0b0f15;
}

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


.lightbox-caption {
  padding: 14px 18px;
  font-size: 13px;
  color: var(--text-1);
  border-top: 1px solid rgba(122, 163, 255, 0.12);
  background: rgba(12, 15, 19, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.lightbox-download {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(12, 15, 19, 0.7);
  color: var(--text-0);
  cursor: pointer;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(12, 15, 19, 0.6);
  color: var(--text-0);
  cursor: pointer;
  font-size: 22px;
}

.lightbox-nav.prev {
  left: 12px;
}

.lightbox-nav.next {
  right: 12px;
}

.lightbox-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.lightbox-open {
  overflow: hidden;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  transition: transform 160ms ease, border 160ms ease;
}

.media-button {
  all: unset;
  cursor: pointer;
  display: block;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(77, 225, 183, 0.35);
}

.thumb,
.video-preview {
  display: block;
  height: var(--thumb-height, 220px);
  width: auto;
  background: linear-gradient(135deg, rgba(122, 163, 255, 0.12), rgba(77, 225, 183, 0.12));
  object-fit: cover;
}

.video-preview {
  background: #0e1219;
  cursor: pointer;
}

.card-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  font-size: 12px;
  color: var(--text-0);
  background: rgba(12, 15, 19, 0.7);
  padding: 6px 8px;
  border-radius: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fade-in {
  animation: fadeIn 360ms ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
  }
}
