:root {
  color-scheme: dark;
  --bg: #050807;
  --surface: #0b100d;
  --surface-hover: #121a15;
  --border: #1b2820;
  --text: #eafff1;
  --text-dim: #7c9c8c;
  --accent: #39ff88;
  --accent-dim: #1f8f52;
  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  font-family: var(--font-body);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* faint ambient grid + glow backdrop, very subtle */
body {
  background-image:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(57, 255, 136, 0.10), transparent 60%),
    linear-gradient(rgba(57, 255, 136, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57, 255, 136, 0.035) 1px, transparent 1px);
  background-size: auto, 42px 42px, 42px 42px;
  background-position: center, center, center;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(5, 8, 7, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.topbar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-right: 8px;
  color: var(--accent);
  font-size: 15px;
  text-shadow: 0 0 14px rgba(57, 255, 136, 0.35);
}
.topbar .brand .sub { color: var(--text-dim); font-weight: 500; margin-left: 6px; }

.breadcrumbs {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 14px;
}

.breadcrumbs button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  font-family: var(--font-body);
  transition: color 0.15s ease;
}

.breadcrumbs button:hover,
.breadcrumbs button.current {
  color: var(--accent);
}

.breadcrumbs .sep { opacity: 0.35; }

.btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 16px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-body);
  transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(57, 255, 136, 0.15), 0 0 16px rgba(57, 255, 136, 0.12);
}
.btn:active { transform: scale(0.97); }

main {
  flex: 1;
  padding: 28px 24px 48px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  animation: fade-up 0.35s ease both;
}

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

.section-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 14px;
}

.cw-grid { margin-bottom: 36px; }

.cw-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
}
.cw-progress-fill {
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(57, 255, 136, 0.6);
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.tile:hover,
.tile:focus-visible {
  background: var(--surface-hover);
  transform: translateY(-3px);
  border-color: var(--accent-dim);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(57, 255, 136, 0.1);
}
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tile .thumb {
  position: relative;
  aspect-ratio: 2 / 3;
  background: #070a08 center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  color: var(--accent-dim);
}

.tile .label {
  padding: 10px 10px 12px;
  font-size: 13px;
  line-height: 1.3;
  color: var(--text);
  word-break: break-word;
  font-family: var(--font-body);
}

.tile.folder .thumb { font-size: 32px; }

.empty, .loading, .error {
  color: var(--text-dim);
  padding: 60px 0;
  text-align: center;
}

.error { color: #ff8585; }

/* ---------- Login ---------- */
.login-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  position: relative;
}

.brand-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: fade-up 0.5s ease both;
}

.brand-mark .wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-shadow: 0 0 22px rgba(57, 255, 136, 0.45), 0 0 60px rgba(57, 255, 136, 0.15);
  animation: glow-pulse 3.2s ease-in-out infinite;
}

.brand-mark .wordmark span { color: var(--text); text-shadow: none; }

.brand-mark .rule {
  width: 64px;
  height: 2px;
  margin-top: 6px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 200% 100%;
  animation: rule-sweep 3.2s ease-in-out infinite;
}

.brand-mark .tagline {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 8px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fade-up 0.6s ease both;
  animation-delay: 0.08s;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-card input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: 7px;
  font-size: 14px;
  font-family: var(--font-body);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(57, 255, 136, 0.12);
}

.login-card .btn {
  background: var(--accent);
  border: none;
  color: #04170c;
  font-weight: 600;
  text-align: center;
  padding: 11px 16px;
  border-radius: 7px;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.login-card .btn:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 24px rgba(57, 255, 136, 0.35);
}
.login-card .btn:active { transform: scale(0.98); }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes glow-pulse {
  0%, 100% { text-shadow: 0 0 22px rgba(57, 255, 136, 0.45), 0 0 60px rgba(57, 255, 136, 0.15); }
  50% { text-shadow: 0 0 30px rgba(57, 255, 136, 0.65), 0 0 90px rgba(57, 255, 136, 0.25); }
}

@keyframes rule-sweep {
  0%, 100% { background-position: 0% 50%; opacity: 0.6; }
  50% { background-position: 100% 50%; opacity: 1; }
}

/* ---------- Player ---------- */
.player-wrap {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  z-index: 100;
  animation: fade-up 0.2s ease both;
}

.player-wrap video {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #000;
}

.player-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: linear-gradient(rgba(0,0,0,0.75), transparent);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  font-family: var(--font-body);
  transition: opacity 0.25s ease;
}

.player-topbar .btn { font-size: 13px; }
.player-title { font-size: 14px; color: var(--text-dim); }

.player-fatal-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.player-fatal-error-msg { color: var(--text); font-size: 14px; max-width: 280px; }

.player-wrap:has(.player-upnext) .center-play { display: none; }

.player-upnext {
  position: absolute;
  right: 24px;
  bottom: 110px;
  z-index: 7;
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  max-width: 340px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: fade-up 0.25s ease both;
}

.upnext-thumb {
  flex-shrink: 0;
  width: 84px;
  aspect-ratio: 2 / 3;
  border-radius: 7px;
  background: #070a08 center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--accent-dim);
}

.upnext-info { min-width: 0; }
.upnext-label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.upnext-title {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.upnext-actions { display: flex; gap: 8px; }
.upnext-actions .btn { font-size: 12px; padding: 6px 10px; }
.upnext-play {
  background: var(--accent);
  border: none;
  color: #04170c;
  font-weight: 600;
  white-space: nowrap;
}
.upnext-play:hover { filter: brightness(1.08); color: #04170c; box-shadow: 0 0 18px rgba(57, 255, 136, 0.35); }

@media (max-width: 560px) {
  .player-upnext { right: 12px; left: 12px; bottom: 96px; max-width: none; }
}

.player-wrap.controls-hidden .player-topbar,
.player-wrap.controls-hidden .controls-bar {
  opacity: 0;
  pointer-events: none;
}
.player-wrap.controls-hidden { cursor: none; }

/* center big play button */
.center-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(10, 16, 13, 0.6);
  border: 1px solid rgba(57, 255, 136, 0.35);
  color: var(--accent);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  backdrop-filter: blur(4px);
  transition: transform 0.15s ease, background 0.15s ease;
}
.center-play:hover { transform: translate(-50%, -50%) scale(1.06); background: rgba(10, 16, 13, 0.8); }
.center-play .icon svg { width: 30px; height: 30px; }
.player-wrap.paused .center-play { display: flex; }

/* buffering spinner */
.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(57, 255, 136, 0.2);
  border-top-color: var(--accent);
  display: none;
  z-index: 3;
  animation: spin 0.8s linear infinite;
}
.player-wrap.buffering .spinner { display: block; }
.player-wrap.buffering .center-play { display: none; }

@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* control bar */
.controls-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 10px 18px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85) 60%);
  transition: opacity 0.25s ease;
  font-family: var(--font-body);
}

.progress {
  position: relative;
  height: 14px;
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 6px;
}
.progress::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
}
.progress-buffered,
.progress-played {
  position: absolute;
  left: 0;
  height: 4px;
  border-radius: 2px;
  pointer-events: none;
}
.progress-buffered { background: rgba(255,255,255,0.3); width: 0%; }
.progress-played { background: var(--accent); width: 0%; box-shadow: 0 0 8px rgba(57,255,136,0.5); }
.progress-handle {
  position: absolute;
  left: 0%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(57,255,136,0.6);
  pointer-events: none;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.controls-group {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { color: var(--accent); background: rgba(57, 255, 136, 0.08); }

.time-text {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.volume-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.volume-slider {
  width: 70px;
  accent-color: var(--accent);
}
@media (max-width: 560px) {
  .volume-slider { width: 44px; }
}

.menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 5;
  animation: fade-up 0.12s ease both;
}
.menu-item {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
}
.menu-item:hover { background: rgba(57, 255, 136, 0.1); color: var(--accent); }
.menu-item.active { color: var(--accent); font-weight: 600; }

.icon svg { display: block; }

@media (max-width: 560px) {
  .controls-bar { padding: 8px 10px 10px; }
  .controls-row { gap: 4px; }
  .controls-group { gap: 0; }
  .icon-btn { width: 30px; height: 30px; }
  .time-text { font-size: 11px; margin-left: 2px; }
  .player-topbar { padding: 10px 12px; }
  .center-play { width: 56px; height: 56px; }
}

@media (max-width: 400px) {
  .time-text { display: none; }
}
