@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg:         #060a10;
  --bg-2:       rgba(8, 14, 26, 0.92);
  --bg-3:       rgba(15, 22, 38, 0.85);
  --border:     rgba(0, 255, 136, 0.2);
  --border-2:   rgba(0, 255, 136, 0.35);
  --text:       #e8f4f8;
  --text-dim:   #b8dce8;
  --text-muted: #7ab4c4;
  --accent:     #00ff88;
  --accent-dim: #00b060;
  --warn:       #f0a020;
  --danger:     #e05050;
  --canary:     #ffef00;
  --mono:       'IBM Plex Mono', monospace;
  --sans:       'IBM Plex Sans', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #app {
  min-height: 100%;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at center,
      rgba(255, 149, 0, 0.9) 0%,
      rgba(255, 149, 0, 0.55) 22%,
      rgba(255, 149, 0, 0.2) 38%,
      rgba(255, 149, 0, 0) 50%),
    url('/bg-circuit.jpg');
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  background-attachment: fixed, fixed;
}

/* Per-library background: whichever collage image matches the library
   being browsed sits on top of the usual circuit + orange-glow
   background, blended in via 'overlay' so it reads as one integrated
   scene rather than a flat image swap. Which image applies is set via
   the --library-bg-image custom property (in JS, per library name) —
   this one rule handles all of them rather than needing one CSS rule
   per library. Only active while browsing a matched section —
   everywhere else uses the normal background above. */
body.library-bg {
  background-image:
    var(--library-bg-image),
    radial-gradient(circle at center,
      rgba(255, 149, 0, 0.9) 0%,
      rgba(255, 149, 0, 0.55) 22%,
      rgba(255, 149, 0, 0.2) 38%,
      rgba(255, 149, 0, 0) 50%),
    url('/bg-circuit.jpg');
  background-size: cover, cover, cover;
  background-position: center, center, center;
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-attachment: fixed, fixed, fixed;
  background-blend-mode: overlay, normal, normal;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: var(--sans);
  cursor: pointer;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,255,136,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,255,136,0.4); }

/* ── Buttons ─────────────────────────────────── */
.btn {
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #04140a;
  font-weight: 500;
}
.btn-primary:hover { background: #33ffa0; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  border: 1px solid var(--border-2);
  color: var(--canary);
  background: transparent;
}
.btn-zip {
  /* Tighter vertical padding than the default .btn — the arrow icon is
     noticeably bigger now, and this keeps the row roughly the same
     height as before rather than growing to accommodate a taller icon. */
  padding-top: 4px;
  padding-bottom: 4px;
}
.btn-zip-arrow-icon {
  display: inline-flex;
  align-items: center;
  line-height: 0; /* prevents the SVG's own line box from adding extra height */
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 255, 136, 0.07);
}
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-danger {
  border: 1px solid var(--danger);
  color: var(--danger);
  background: transparent;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Login screen ────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  width: 420px;
  padding: 44px 40px;
  background: rgba(4, 10, 20, 0.92);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 6px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 0 40px rgba(0, 255, 136, 0.08), 0 20px 60px rgba(0, 0, 0, 0.6);
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 1px;
  white-space: nowrap;
  margin-bottom: 4px;
}
.logo-icon { width: 24px; height: 24px; flex-shrink: 0; }

.sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 36px;
}

.form { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.field input {
  font-family: var(--mono);
  background: rgba(0, 20, 40, 0.6);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 4px;
  outline: none;
  font-size: 14px;
}
.field input:focus { border-color: var(--accent); }

.error {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--danger);
  padding: 8px 10px;
  background: rgba(224, 80, 80, 0.1);
  border: 1px solid rgba(224, 80, 80, 0.3);
  border-radius: 3px;
}

.submit {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── Main app shell ───────────────────────────── */
.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 24px;
  height: 52px;
  background: rgba(4, 10, 20, 0.92);
  border-bottom: 1px solid rgba(0, 255, 136, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 1px 20px rgba(0, 0, 0, 0.4);
}
.nav .left { display: flex; align-items: center; gap: 10px; }
.nav .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--canary);
  justify-self: center;
}
.nav .brand img { width: 20px; height: 20px; }
.nav .right { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.nav .session-note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.page {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 36px 24px;
  box-sizing: border-box;
}

.page-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  color: var(--canary);
  margin: 0;
  text-shadow: 0 0 18px rgba(255, 239, 0, 0.25);
}
.page-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ── Files tab top row: usage monitor (1/3) + upload panel (2/3) ── */
.files-top-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 28px;
}
@media (max-width: 760px) {
  .files-top-grid { grid-template-columns: 1fr; }
}
.files-top-col-usage,
.files-top-col-upload {
  min-width: 0;
}

/* ── Usage monitor ─────────────────────────────── */
.usage-box {
  background: rgba(4, 10, 20, 0.92);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 8px;
  padding: 16px 20px;
  height: 100%;
  box-sizing: border-box;
}
.usage-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.usage-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.usage-pct {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}
.usage-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
}
.usage-fill {
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  border-radius: 5px;
  transition: width 0.3s ease;
}
.usage-fill-warn {
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
}
.usage-fill-danger {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}
.usage-detail {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.usage-error {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Dropzone ─────────────────────────────────── */
.dropzone {
  background: rgba(4, 10, 20, 0.85);
  border: 2px dashed rgba(0, 255, 136, 0.3);
  border-radius: 8px;
  padding: 48px 24px;
  text-align: center;
  margin-bottom: 0;
  transition: all 0.15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(0, 255, 136, 0.05);
}
.dropzone-icon { font-size: 32px; margin-bottom: 10px; }
.dropzone-text {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.dropzone-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}
.dropzone input[type="file"] { display: none; }

.upload-panel {
  background: rgba(4, 10, 20, 0.95);
  border: 1px solid rgba(0, 255, 136, 0.4);
  border-radius: 8px;
  padding: 22px 26px;
  margin-top: 16px;
  box-shadow: 0 0 30px rgba(0, 255, 136, 0.12);
}

.upload-panel-title {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--canary);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  text-shadow: 0 0 14px rgba(255, 239, 0, 0.3);
}

.upload-panel-size {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.upload-panel-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
}

.upload-panel-fill {
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  border-radius: 5px;
  transition: width 0.15s ease;
}

.upload-panel-pct {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

.upload-panel-error {
  border-color: rgba(224, 80, 80, 0.5);
  box-shadow: 0 0 30px rgba(224, 80, 80, 0.15);
}
.upload-panel-error .upload-panel-title { color: var(--danger); text-shadow: 0 0 14px rgba(224, 80, 80, 0.3); }
.upload-panel-error .upload-panel-size { color: var(--danger); }

.upload-panel-success {
  border-color: rgba(0, 255, 136, 0.5);
}
.upload-panel-success .upload-panel-title { color: var(--accent); text-shadow: 0 0 14px rgba(0, 255, 136, 0.4); }

/* ── View toggle (detailed vs list) ──────────────────────────── */
.list-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-bottom: 14px;
  padding: 10px 16px;
  background: rgba(8, 16, 28, 0.55);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 6px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.list-header:empty { display: none; }
.view-toggle {
  display: inline-flex;
  border: 1px solid rgba(0, 255, 136, 0.25);
  border-radius: 5px;
  overflow: hidden;
}
.view-toggle-btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 7px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.view-toggle-btn + .view-toggle-btn { border-left: 1px solid rgba(0, 255, 136, 0.25); }
.view-toggle-btn:hover { color: var(--text-dim); }
.view-toggle-btn.active { background: rgba(0, 255, 136, 0.12); color: var(--accent); }

/* ── Media tab ────────────────────────────────── */
.queue-panel-wrap:empty { display: none; }
.scroll-top-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 900;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--accent);
  color: #04140a;
  border: none;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 255, 136, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.scroll-top-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 26px rgba(0, 255, 136, 0.5);
}
.scroll-top-btn-arrow {
  font-size: 15px;
  line-height: 1;
}

.queue-panel {
  background: rgba(4, 10, 20, 0.95);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: 0 0 24px rgba(0, 255, 136, 0.1);
}
.queue-panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.queue-panel-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.queue-panel-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.queue-panel-note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 8px;
  line-height: 1.5;
}
.queue-item {
  padding: 10px 0;
  border-top: 1px solid rgba(0, 255, 136, 0.08);
}
.queue-item:first-of-type { border-top: none; }
.queue-item-label {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-item-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.queue-item-fill {
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  border-radius: 3px;
  transition: width 0.2s ease;
}
.queue-item-fill-indeterminate {
  background: repeating-linear-gradient(
    45deg, var(--accent), var(--accent) 10px, rgba(0,255,136,0.3) 10px, rgba(0,255,136,0.3) 20px
  );
  animation: queueStripe 1s linear infinite;
}
@keyframes queueStripe { from { background-position: 0 0; } to { background-position: 28px 0; } }
.queue-item-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.queue-item-pct {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}
.queue-item-done { color: var(--accent); }
.queue-item-error { color: var(--danger); }
.queue-item-actions { display: flex; gap: 10px; flex-shrink: 0; }

.info-btn {
  background: rgba(0, 255, 136, 0.18);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
  animation: infoPulse 2.5s ease-in-out infinite;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.info-btn:hover {
  background: var(--accent);
  color: #001a0d;
  box-shadow: 0 0 18px rgba(0, 255, 136, 0.65);
  transform: scale(1.15);
  animation-play-state: paused;
}
@keyframes infoPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(0, 255, 136, 0.25); }
  50% { box-shadow: 0 0 15px rgba(0, 255, 136, 0.6); }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 6, 14, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-box {
  position: relative;
  background: rgba(6, 14, 26, 0.98);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 10px;
  box-shadow: 0 0 40px rgba(0, 255, 136, 0.15);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.media-detail-body {
  display: flex;
  gap: 20px;
}
.media-detail-poster {
  width: 140px;
  min-width: 140px;
  border-radius: 6px;
  border: 1px solid rgba(0, 255, 136, 0.15);
  object-fit: cover;
}
.media-detail-info { flex: 1; min-width: 0; }
.media-detail-title {
  font-family: var(--mono);
  font-size: 17px;
  color: var(--text);
  margin: 0 0 8px 0;
  padding-right: 20px;
}
.media-detail-meta {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.media-detail-inherited-note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 10px;
}
.media-detail-summary {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 0 0 14px 0;
}
.media-detail-summary-empty { color: var(--text-muted); font-style: italic; }
.media-detail-links { display: flex; gap: 10px; }

.media-player-modal { max-width: 800px; }
.media-player-duration { margin-top: -6px; margin-bottom: 6px; }
.media-player-wrap {
  margin-top: 14px;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
}
.media-player-video {
  width: 100%;
  max-height: 70vh;
  display: block;
}
.media-player-audio {
  width: 100%;
  display: block;
}
.stream-error-note {
  margin-top: 14px;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  background: rgba(224, 80, 80, 0.08);
  border: 1px solid rgba(224, 80, 80, 0.3);
  border-radius: 6px;
}
.media-player-controls { display: flex; gap: 10px; margin-top: 14px; }

.playlist-picker-body { margin-top: 14px; }
.playlist-picker-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.playlist-picker-item { justify-content: flex-start; text-align: left; }
.playlist-picker-status { font-size: 12.5px; color: var(--text-dim); min-height: 1.2em; margin-bottom: 8px; }
.playlist-picker-create { display: flex; gap: 10px; }

@media (max-width: 480px) {
  .media-detail-body { flex-direction: column; }
  .media-detail-poster { width: 100%; max-width: 200px; }
}


.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  font-family: var(--mono);
  font-size: 12.5px;
}
.breadcrumb-item {
  background: none;
  border: none;
  color: #ffffff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
  cursor: pointer;
  padding: 2px 4px;
}
.breadcrumb-item:hover { color: var(--text-dim); text-decoration: underline; }
.breadcrumb-item.current { color: var(--accent); cursor: default; }
.breadcrumb-item.current:hover { text-decoration: none; }
.breadcrumb-sep { color: #ffffff; text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5); }

.media-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: rgba(4, 10, 20, 0.92);
  border: 1px solid rgba(0, 255, 136, 0.15);
  border-radius: 6px;
  overflow: hidden;
}
.media-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(0, 255, 136, 0.06);
  font-family: var(--mono);
  font-size: 13px;
}
.media-row:last-child { border-bottom: none; }
.media-row-container { cursor: pointer; }
.media-row-container:hover { background: rgba(0, 255, 136, 0.04); }
.media-row-icon { font-size: 16px; flex-shrink: 0; width: 22px; text-align: center; }
.media-row-title {
  flex: 1;
  min-width: 0;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-row-meta {
  color: var(--text-muted);
  font-size: 11.5px;
  flex-shrink: 0;
}

.library-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
}
.library-rearrange-row { cursor: default; }
.library-rearrange-row.library-hidden {
  opacity: 0.45;
}
.library-hidden-tag {
  font-size: 9.5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid rgba(240, 160, 32, 0.4);
  color: var(--warn);
  background: rgba(240, 160, 32, 0.08);
  flex-shrink: 0;
}
.library-rearrange-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.library-rearrange-controls .link-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.folder-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  background: rgba(0, 255, 136, 0.03);
  border-bottom: 1px solid rgba(0, 255, 136, 0.1);
  font-family: var(--mono);
}
.folder-group-header:hover { background: rgba(0, 255, 136, 0.06); }
.folder-group-header-plain { cursor: default; background: rgba(255, 255, 255, 0.02); }
.folder-group-header-plain:hover { background: rgba(255, 255, 255, 0.02); }
.folder-group-icon { font-size: 14px; flex-shrink: 0; }
.folder-group-title {
  flex: 1;
  color: var(--canary);
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-group-count {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}
/* Indentation for nested folder groups is now set inline per-depth in JS
   (see INDENT_PX in renderMediaTab), since nesting can go arbitrarily
   deep — a single fixed value here wouldn't work for that. */

.folder-bulk-actions {
  display: flex;
  gap: 14px;
}

.folder-oversized-flag {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--warn);
  flex-shrink: 0;
}
.folder-oversized-row {
  padding: 10px 16px 14px 16px;
  background: rgba(240, 160, 32, 0.04);
  border-bottom: 1px solid rgba(0, 255, 136, 0.06);
}
.folder-oversized-note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}
.folder-oversized-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── File list ────────────────────────────────── */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-list-slim {
  gap: 0;
  background: rgba(4, 10, 20, 0.92);
  border: 1px solid rgba(0, 255, 136, 0.15);
  border-radius: 6px;
  overflow: hidden;
}

.file-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid rgba(0, 255, 136, 0.06);
  font-family: var(--mono);
  font-size: 12.5px;
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: rgba(0, 255, 136, 0.03); }
.file-row-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.file-row-sep { color: var(--text-muted); flex-shrink: 0; }
.file-row-meta { color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }

.file-card {
  background: rgba(4, 10, 20, 0.92);
  border: 1px solid rgba(0, 255, 136, 0.15);
  border-radius: 6px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-card-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.file-icon {
  font-size: 22px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.file-info { flex: 1; min-width: 0; }
.file-name {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-badge {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid rgba(0, 255, 136, 0.3);
  color: var(--accent);
  background: rgba(0, 255, 136, 0.07);
  flex-shrink: 0;
}

.file-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Per-file notes ───────────────────────────────────────────────── */
.file-note {
  padding-top: 10px;
  border-top: 1px solid rgba(0, 255, 136, 0.08);
}
.file-note-text {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 4px;
}
.file-note-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.file-note-edit-btn {
  font-size: 11px;
}
.file-note-input {
  width: 100%;
  font-family: var(--sans);
  font-size: 13px;
  color: #ffffff;
  background: rgba(0, 20, 40, 0.6);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 8px 10px;
  outline: none;
  resize: vertical;
  min-height: 60px;
}
.file-note-input:focus { border-color: var(--accent); }
.file-note-input::placeholder { color: var(--text-muted); }
.file-note-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.empty-state {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
}

.loading {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  padding: 40px 0;
  text-align: center;
}

/* ── Tabs ─────────────────────────────────────── */
.tabs {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 22px;
  padding: 6px 10px 0 10px;
  background: rgba(8, 16, 28, 0.55);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-bottom: 1px solid rgba(0, 255, 136, 0.15);
  border-radius: 8px 8px 0 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.tab {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--canary); border-bottom-color: var(--canary); }

/* ── Link-style button (forgot password, back to login) ─────────── */
.link-btn {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  text-align: center;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.success-msg {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  padding: 8px 10px;
  background: rgba(0, 255, 136, 0.08);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 3px;
}

/* ── Recently Viewed panel (Media tab) ───────────────────────────── */
.recently-viewed-wrap:empty { display: none; }
/* Breaks out of .page's centered max-width/padding to span the full
   viewport, while every other element in the tab stays put. */
.recently-viewed-wrap {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  box-sizing: border-box;
  padding: 0 24px;
}
.recently-viewed-panel {
  margin-bottom: 18px;
  padding: 14px 16px;
  background: rgba(8, 16, 28, 0.55);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.recently-viewed-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.recently-viewed-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.recently-viewed-card {
  flex-shrink: 0;
  width: 110px;
  cursor: pointer;
}
.recently-viewed-thumb {
  position: relative;
  width: 110px;
  height: 165px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 20, 40, 0.6);
  border: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
}
.recently-viewed-card:hover .recently-viewed-thumb { border-color: var(--accent); }
.recently-viewed-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recently-viewed-thumb-empty { font-size: 28px; color: var(--text-muted); }
.recently-viewed-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 20px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.recently-viewed-card:hover .recently-viewed-remove { opacity: 1; }
.recently-viewed-remove:hover { background: rgba(224, 80, 80, 0.85); }
.recently-viewed-label {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Search bar (History tab) ────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.search-bar input {
  flex: 1;
  font-family: var(--mono);
  background: rgba(0, 20, 40, 0.6);
  border: 1px solid var(--border-2);
  color: #ffffff;
  padding: 9px 12px;
  border-radius: 4px;
  outline: none;
  font-size: 13px;
}

.search-bar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0 12px;
  font-size: 15px;
  background: rgba(0, 20, 40, 0.6);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  line-height: 1;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar input:focus { border-color: var(--accent); }

.search-clear-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  flex-shrink: 0;
  background: rgba(0, 20, 40, 0.6);
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.search-clear-btn:hover { color: var(--danger); border-color: var(--danger); }

.media-row-library {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid rgba(0, 255, 136, 0.25);
  background: rgba(0, 255, 136, 0.06);
  color: var(--accent);
}

/* ── Manage history (admin) ──────────────────────────────────────── */
.manage-history-wrap { margin-bottom: 18px; }
.manage-history-panel {
  margin-top: 10px;
  background: rgba(4, 10, 20, 0.92);
  border: 1px solid rgba(224, 80, 80, 0.25);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.manage-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.manage-history-row:last-child { border-bottom: none; padding-bottom: 0; }
.manage-history-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  min-width: 170px;
}
.manage-history-sublabel {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}
.manage-history-select {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0, 20, 40, 0.6);
  border: 1px solid var(--border-2);
  color: #ffffff;
  padding: 7px 10px;
  border-radius: 4px;
}
.manage-history-date {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0, 20, 40, 0.6);
  border: 1px solid var(--border-2);
  color: #ffffff;
  padding: 6px 8px;
  border-radius: 4px;
}

/* ── Data table (History + Admin) ────────────────────────────────── */
.table-wrap {
  background: rgba(4, 10, 20, 0.92);
  border: 1px solid rgba(0, 255, 136, 0.15);
  border-radius: 6px;
  overflow-x: auto;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 10.5px;
  font-weight: 500;
  border-bottom: 1px solid rgba(0, 255, 136, 0.15);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { color: var(--text-dim); }
.data-table th.sorted { color: var(--canary); }
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0, 255, 136, 0.06);
  color: var(--text-dim);
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(0, 255, 136, 0.03); }

.action-badge {
  font-size: 9px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid rgba(0, 255, 136, 0.3);
  color: var(--accent);
  background: rgba(0, 255, 136, 0.07);
}
.action-badge.action-delete { border-color: rgba(224, 80, 80, 0.4); color: var(--danger); background: rgba(224, 80, 80, 0.08); }
.action-badge.action-login_failed { border-color: rgba(240, 160, 32, 0.4); color: var(--warn); background: rgba(240, 160, 32, 0.08); }

.badge-admin {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid rgba(255, 239, 0, 0.35);
  color: var(--canary);
  background: rgba(255, 239, 0, 0.08);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 10px 16px;
  width: fit-content;
  background: rgba(8, 16, 28, 0.55);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 6px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--mono);
  font-size: 12px;
  color: #ffffff;
}
.pagination .btn-ghost {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
}
.pagination .btn-ghost:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.pagination .btn-ghost:disabled {
  color: var(--text-muted);
  border-color: rgba(255, 255, 255, 0.15);
}

.admin-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.inline-form {
  background: rgba(4, 10, 20, 0.92);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 6px;
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.inline-form .field { min-width: 220px; }
