:root {
  --bg: #1b1523;
  --surface: #241b2e;
  --surface-2: #2e2239;
  --line: #3a2c48;
  --text: #f3ecff;
  --text-dim: #b6a6c9;
  --gold: #f2b134;
  --gold-dim: #c9932a;
  --plum: #8a5fb0;
  --danger: #e0567c;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(138, 95, 176, 0.18), transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(242, 177, 52, 0.10), transparent 40%);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.5;
}

h1, h2 {
  font-family: 'Space Grotesk', sans-serif;
  margin: 0;
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 64px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

main.content {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0; /* evita que el video empuje el layout */
}

/* ---------- Header ---------- */
.top {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 32px;
  text-align: center;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.brand h1 {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tag {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin: 10px 0 0;
}

/* Ecualizador: elemento distintivo del sitio */
.bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 26px;
}
.bars i {
  display: block;
  width: 4px;
  background: linear-gradient(180deg, var(--gold), var(--plum));
  border-radius: 2px;
  animation: bounce 1.1s ease-in-out infinite;
}
.bars i:nth-child(1) { height: 40%; animation-delay: 0s; }
.bars i:nth-child(2) { height: 100%; animation-delay: 0.15s; }
.bars i:nth-child(3) { height: 65%; animation-delay: 0.3s; }
.bars i:nth-child(4) { height: 85%; animation-delay: 0.45s; }

@keyframes bounce {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .bars i { animation: none; transform: scaleY(0.75); }
}

/* ---------- Flash messages ---------- */
.flash {
  max-width: 960px;
  margin: 0 auto 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.92rem;
}
.flash-ok { background: rgba(60, 190, 130, 0.15); color: #7fe0ae; border: 1px solid rgba(60,190,130,0.3); margin-left: 24px; margin-right: 24px;}
.flash-error { background: rgba(224, 86, 124, 0.15); color: #f3a3ba; border: 1px solid rgba(224,86,124,0.3); margin-left: 24px; margin-right: 24px;}

/* ---------- Sidebar / árbol de carpetas ---------- */
.sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-head {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.tree-wrap {
  max-height: 50vh;
  overflow-y: auto;
}

.tree {
  list-style: none;
  margin: 0;
  padding-left: 14px;
}
.tree:first-of-type { padding-left: 0; }

.tree a {
  display: block;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 6px 8px;
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree a:hover { background: var(--surface-2); color: var(--text); }
.tree a.active {
  background: rgba(242, 177, 52, 0.15);
  color: var(--gold);
  font-weight: 600;
}

.new-folder {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 0.85rem;
}
.new-folder summary {
  cursor: pointer;
  color: var(--text-dim);
}
.new-folder summary:hover { color: var(--gold); }
.new-folder form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.new-folder input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.85rem;
}
.btn-small { padding: 7px 14px; font-size: 0.82rem; align-self: flex-start; }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--gold); }

/* ---------- Visor ---------- */
.viewer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.viewer-empty {
  text-align: center;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.viewer-video-wrap {
  width: 100%;
  position: relative;
}
.viewer-video-wrap video {
  width: 100%;
  max-height: 70vh;
  border-radius: 10px;
  background: #000;
  display: block;
}
.maximize-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.2);
}

.viewer-audio {
  width: 100%;
  max-width: 480px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.viewer-filename {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  color: var(--text-dim);
  word-break: break-all;
  margin: 0;
}
.viewer-audio audio { width: 100%; }
.bars.big { height: 46px; }
.bars.big i { width: 7px; }

/* ---------- Panels ---------- */
.panel h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--gold);
  background: rgba(242, 177, 52, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
}

.empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}

/* ---------- Upload form ---------- */
.upload-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.upload-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: end;
  margin-top: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.field input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
}
.field input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #241608;
}
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--line);
}
.btn-ghost:hover { color: var(--danger); border-color: var(--danger); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* ---------- Grid & cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease;
}
.card:hover { border-color: var(--gold-dim); }
.card-active {
  border-color: var(--gold);
  background: rgba(242, 177, 52, 0.06);
}

.card-play {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: var(--text);
}

.play-icon {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 2px;
}

.filename {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 0;
}

.delete-box {
  display: none;
  gap: 8px;
  margin-top: 4px;
}
.delete-box.open { display: flex; }
.delete-box input[type="password"] {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.85rem;
}

/* ---------- Footer ---------- */
footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 24px;
}
footer code {
  font-family: 'JetBrains Mono', monospace;
  color: var(--gold);
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .tree-wrap {
    max-height: 220px;
  }
}

@media (max-width: 640px) {
  .upload-form {
    grid-template-columns: 1fr;
  }
  .brand h1 { font-size: 1.6rem; }
}
