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

:root {
  --bg: #0e1117;
  --panel: #161b22;
  --panel-2: #1f2630;
  --panel-3: #2a313c;
  --border: #2a313c;
  --border-strong: #3a414c;
  --text: #e6edf3;
  --muted: #8b949e;
  --muted-2: #6e7681;
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-soft: rgba(249, 115, 22, 0.12);
  --danger: #ef4444;
  --success: #10b981;
  --sidebar-w: 260px;
  --player-h: 80px;
  --topbar-h: 56px;
  --toolbar-h: 48px;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

/* ---- Icons ---- */
.icon {
  display: inline-block;
  vertical-align: -0.18em;
  flex-shrink: 0;
}
[data-icon] { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Buttons ---- */
button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.12s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
}
button:hover { background: var(--panel-3); border-color: var(--border-strong); }
button:active { transform: translateY(1px); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--danger); }
button.danger:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); }
button.icon-only { padding: 8px; width: 36px; height: 36px; }
button.icon-only.icon-btn { width: auto; height: auto; padding: 5px 9px; }
button.with-icon { padding: 8px 14px; }
button.icon-btn {
  padding: 5px 9px;
  font-size: 13px;
  background: transparent;
  border-color: transparent;
}
button.icon-btn:hover { background: var(--panel-3); border-color: var(--border); }
button.link {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 0 4px;
  font-weight: 600;
  font-size: 12px;
}
button.link:hover { background: transparent; text-decoration: underline; }

input[type="search"],
input[type="text"],
select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
input[type="search"]:focus,
input[type="text"]:focus,
select:focus { outline: none; border-color: var(--accent); }
input[type="search"] { width: 200px; }

/* ---- Layout ---- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

.hamburger {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  width: 40px; height: 40px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 30;
  padding: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 22px 14px 100px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.brand { margin-bottom: 28px; padding: 0 8px; }
.brand-logo {
  width: 44px; height: 44px;
  border-radius: 10px;
  margin-bottom: 10px;
  object-fit: contain;
  background: var(--bg);
  display: block;
  box-shadow: 0 4px 12px rgba(249,115,22,0.18);
}
.brand-mark {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), #c2410c);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 12px rgba(249,115,22,0.25);
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }

.nav-section { margin-bottom: 24px; }
.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
  padding: 0 8px;
  font-weight: 600;
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.12s;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 10px rgba(249,115,22,0.3);
}
.nav-item.active .format { color: rgba(255,255,255,0.9); }
.nav-item-row { display: flex; align-items: center; gap: 8px; }

/* Sidebar skeleton placeholders shown for ~200-500ms during first paint
   while the station list is still being fetched. Better than empty
   space - tells the user "something's coming, hang on". */
.nav-skeleton {
  pointer-events: none;
  cursor: default;
  background: transparent !important;
}
.skel {
  display: inline-block;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.10) 50%,
    rgba(255,255,255,0.04) 100%
  );
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: 3px;
}
.skel-icon { width: 16px; height: 16px; border-radius: 4px; }
.skel-text { display: inline-block; height: 12px; width: 90px; }
.skel-sub  { display: block; height: 9px; width: 60px; margin-top: 4px; }
@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.nav-item .format {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  margin-left: 24px;
  font-weight: 500;
}
.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  color: var(--muted-2);
  padding: 12px 8px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-footer-meta { color: var(--muted-2); }
.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  font-weight: 500;
}
.logout-btn:hover {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 25;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.show { display: block; }

/* ---- Main ---- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; position: relative; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
  min-height: var(--topbar-h);
}
.breadcrumbs {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.breadcrumbs::-webkit-scrollbar { display: none; }
.crumb {
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.crumb:hover { color: var(--text); background: var(--panel-2); }
.crumb.current { color: var(--text); font-weight: 600; pointer-events: none; }
.crumb-home { color: var(--muted); }
.crumb-sep { color: var(--muted); opacity: 0.5; }

.actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  min-height: var(--toolbar-h);
  flex-wrap: wrap;
}
.filter-chips { display: flex; gap: 6px; }
.chip {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.sort-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.sort-controls select { padding: 6px 10px; font-size: 12.5px; }

/* ---- Selection bar ---- */
.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.selection-count { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.selection-actions { display: flex; gap: 6px; }

/* ---- Listing ---- */
.dropzone {
  flex: 1;
  padding: 14px 20px 24px;
  overflow-y: auto;
  position: relative;
  scroll-behavior: smooth;
}
body.player-open .dropzone { padding-bottom: calc(var(--player-h) + 30px); }
.dropzone.dragover {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
}
/* When in a structural folder where uploads are blocked, kill the
   dragover highlight so the user doesn't think drops will land. */
.dropzone.upload-blocked.dragover {
  background: rgba(239, 68, 68, 0.05);
  outline-color: #f87171;
}

/* Upload-blocked banner shown at the top of structural folders */
.upload-blocked-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-left-width: 3px;
  border-radius: 8px;
  margin-bottom: 14px;
}
.ubb-icon { color: #f87171; flex-shrink: 0; }
.ubb-title {
  font-weight: 700;
  font-size: 14px;
  color: #f87171;
  margin-bottom: 4px;
}
.ubb-sub {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
}
.ubb-sub code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--accent);
}
/* Active drop target on a folder row while dragging files over it */
.folder.folder-drop-target {
  background: var(--accent-soft) !important;
  border-color: var(--accent) !important;
  /* Slight scale-up so the user knows the drop will land here, not on
     the surrounding listing. The translateX hover effect is overridden. */
  transform: scale(1.01) !important;
  box-shadow: 0 0 0 2px var(--accent);
}
/* Children should ignore drag events so dragleave on a child doesn't
   cancel the highlight on the parent folder row. */
.folder.folder-drop-target * { pointer-events: none; }

.folder-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 12px;
  font-size: 12px;
  color: var(--muted);
}
.select-all {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  user-select: none;
}
.select-all input { width: 16px; height: 16px; cursor: pointer; }

/* ---- Folders ----
   Match the file-list row format so folders + files render as ONE
   continuous stream. The .folders container sits directly above .files
   with no gap between them so it reads as a single browser. */
.folders {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}
.folder {
  /* Same grid columns as .files.list .file:
     32px (checkbox slot - empty for folders)
     24px (icon)
     1fr  (name)
     60px (file: duration / folder: empty)
     80px (file: size / folder: count badge)
     120px (file: date / folder: empty)
     auto (actions) */
  display: grid;
  grid-template-columns: 32px 24px 1fr 60px 80px 120px auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
  text-decoration: none;
  color: inherit;
}
.folder:hover {
  background: var(--panel-2);
  border-color: var(--accent);
  transform: translateX(2px);
}
.folder-icon {
  grid-column: 2;
  display: inline-flex;
  color: var(--accent);
  flex-shrink: 0;
}
.folder-name {
  grid-column: 3;
  font-weight: 500;
  font-size: 13px;
  min-width: 0;
  /* Single-line truncation - same as file rows. Hover shows full name
     via the title= attribute on the row. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-count {
  /* Goes in the "size" column slot (5th). Right-aligned tabular numbers
     match how file sizes look. */
  grid-column: 5;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.folder-count::after {
  content: ' items';
  color: var(--muted);
  font-size: 11px;
  margin-left: 2px;
}
.folder .folder-actions {
  /* Last column - actions */
  grid-column: 7;
  display: flex;
  gap: 4px;
  padding: 0;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
}
.folder:hover .folder-actions,
.folder:focus-within .folder-actions { opacity: 1; }

/* ---- Files ---- */
.files.list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.files.list .file {
  display: grid;
  grid-template-columns: 32px 24px 1fr 60px 80px 120px auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: background 0.12s;
}
.files.list .file:hover { background: var(--panel-2); }
.files.list .file.playing { border-color: var(--accent); background: var(--accent-soft); }
.files.list .file-meta-mobile { display: none; }

.files.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.files.grid .file {
  display: flex;
  flex-direction: column;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  gap: 8px;
  position: relative;
}
.files.grid .file:hover { background: var(--panel-2); }
.files.grid .file.playing { border-color: var(--accent); }
.files.grid .file-check { position: absolute; top: 8px; left: 8px; }
.files.grid .file-icon { font-size: 32px; align-self: flex-start; }
.files.grid .file-icon .icon { width: 32px; height: 32px; }
.files.grid .file-name { font-weight: 500; word-break: break-all; }
.files.grid .file-size,
.files.grid .file-date,
.files.grid .file-duration { display: none; }
.files.grid .file-meta-mobile {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.files.grid .file-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  justify-content: flex-start;
}

.file-check {
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-check input { width: 16px; height: 16px; cursor: pointer; }
.file-icon {
  display: inline-flex;
  color: var(--muted);
}
.file.playing .file-icon { color: var(--accent); }
.file-name { font-weight: 500; word-break: break-all; }
.file-size, .file-date, .file-duration {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.file-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ---- Empty / loading ---- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}
.empty-icon {
  display: inline-flex;
  opacity: 0.2;
  margin-bottom: 16px;
  color: var(--muted);
}
.empty-title { font-weight: 600; color: var(--text); margin-bottom: 4px; font-size: 15px; }
.empty-sub { font-size: 13px; }
.loading {
  text-align: center;
  color: var(--muted);
  padding: 30px;
  font-size: 13px;
}

/* ---- Loading overlay (full dropzone) ---- */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(14, 17, 23, 0.55);
  backdrop-filter: blur(2px);
  z-index: 5;
  pointer-events: none;
}
body.is-loading .loading-overlay {
  display: flex;
  pointer-events: auto;        /* block clicks on the (stale) listing below */
  animation: loading-fade-in 0.18s ease-out;
}
body.is-loading .folders,
body.is-loading .files,
body.is-loading .stats-banner,
body.is-loading .folder-actions {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.15s;
}
@keyframes loading-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 32px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--panel-2);
  border-top-color: var(--accent);
  animation: loading-spin 0.85s linear infinite;
}
.loading-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
@keyframes loading-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .loading-spinner { animation: none; border-top-color: var(--text); }
}

.hidden { display: none !important; }

.result-count { font-size: 12px; color: var(--muted); }

/* ---- Notification stack (toasts) ---- */
.notify-stack {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 99999;
  pointer-events: none;
  max-width: min(420px, 92vw);
}
body.player-open .notify-stack { bottom: calc(var(--player-h) + 16px); }

.notify-stack-modal {
  /* When inside a <dialog>, override fixed positioning so it sits inside the modal viewport */
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 1;
}

.notify {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 12px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 10px;
  padding: 12px 14px 14px;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  animation: notify-in 0.18s ease-out;
  user-select: text;
}
@keyframes notify-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.notify.dismissing {
  animation: notify-out 0.18s ease-in forwards;
}
@keyframes notify-out {
  from { opacity: 1; transform: translateX(0); max-height: 200px; }
  to   { opacity: 0; transform: translateX(20px); max-height: 0; padding-top: 0; padding-bottom: 0; margin-top: 0; }
}

.notify-info    { border-left-color: #38bdf8; }
.notify-success { border-left-color: var(--success); }
.notify-warn    { border-left-color: #fbbf24; }
.notify-error   { border-left-color: var(--danger); }

.notify-icon {
  display: inline-flex;
  align-items: flex-start;
  padding-top: 1px;
}
.notify-info    .notify-icon { color: #38bdf8; }
.notify-success .notify-icon { color: var(--success); }
.notify-warn    .notify-icon { color: #fbbf24; }
.notify-error   .notify-icon { color: var(--danger); }

.notify-body { min-width: 0; }
.notify-msg {
  font-weight: 500;
  word-wrap: break-word;
  white-space: pre-wrap;
  line-height: 1.45;
  color: var(--text);
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
.notify-msg:focus { outline: none; }

.notify-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.notify-tag {
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--panel-2);
  font-variant-numeric: tabular-nums;
}
.notify-info    .notify-tag { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.notify-success .notify-tag { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.notify-warn    .notify-tag { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.notify-error   .notify-tag { background: rgba(239, 68, 68, 0.18); color: var(--danger); }
.notify-time { color: var(--muted-2); }

.notify-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.notify-actions .icon-btn {
  padding: 4px 6px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.notify-actions .icon-btn:hover {
  background: var(--panel-2);
  color: var(--text);
}
.notify-actions .icon-btn.copied { color: var(--success); }

.notify-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  width: 100%;
  background: var(--accent);
  transform-origin: left center;
  opacity: 0.6;
}
.notify-info    .notify-progress { background: #38bdf8; }
.notify-success .notify-progress { background: var(--success); }
.notify-warn    .notify-progress { background: #fbbf24; }
.notify-error   .notify-progress { background: var(--danger); }

@media (max-width: 700px) {
  .notify-stack {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
  body.player-open .notify-stack { bottom: calc(var(--player-h) + 12px); }
}

/* ---- Player ---- */
.player {
  position: fixed;
  bottom: 0; left: var(--sidebar-w); right: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 10;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
  min-height: var(--player-h);
}
.player-info { min-width: 200px; max-width: 320px; flex-shrink: 0; }
.player-title {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-sub {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.player audio { flex: 1; height: 36px; min-width: 0; }
.player-controls { display: flex; gap: 4px; align-items: center; }
.player-controls button { padding: 8px; }
.player-controls .toggle.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- Modals ---- */
dialog.modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 520px;
  width: 92%;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
dialog.modal::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
dialog.modal h3 { margin-bottom: 16px; font-size: 17px; }
dialog.modal label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 12.5px;
  color: var(--muted);
}
dialog.modal label input { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.folder-picker {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 16px;
  max-height: 320px;
  display: flex;
  flex-direction: column;
}
.folder-picker-path {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.picker-crumb {
  cursor: pointer;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.picker-crumb:hover { color: var(--accent); text-decoration: underline; }
.folder-picker-list {
  overflow-y: auto;
  flex: 1;
  padding: 6px;
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.picker-item:hover { background: var(--panel-2); }
.picker-item .icon { color: var(--accent); }

/* ---- Scrollbars ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--panel-3); }

/* ---- Mobile / responsive ---- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .hamburger { display: flex; }
  .topbar { padding-left: 64px; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 26;
    box-shadow: 0 0 40px rgba(0,0,0,0.6);
  }
  .sidebar.open { transform: translateX(0); }
  .player { left: 0; }
  input[type="search"] { width: 130px; }
}

@media (max-width: 700px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 16px 10px 64px;
  }
  .breadcrumbs { order: 1; flex-basis: 100%; padding-top: 4px; }
  .actions { order: 0; margin-left: auto; }
  .toolbar { padding: 8px 16px; gap: 8px; }
  .sort-controls label { display: none; }
  .files.list .file {
    grid-template-columns: 28px 24px 1fr auto;
    gap: 10px;
  }
  .files.list .file-size,
  .files.list .file-date,
  .files.list .file-duration { display: none; }
  .files.list .file-meta-mobile {
    display: block;
    grid-column: 3;
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
  }
  .files.list .file-name { grid-column: 3; align-self: end; }
  /* Folders use the same row template as files - simplify to match */
  .folder {
    grid-template-columns: 28px 24px 1fr auto auto;
    gap: 10px;
  }
  .folder-icon  { grid-column: 2; }
  .folder-name  { grid-column: 3; }
  .folder-count { grid-column: 4; font-size: 11px; }
  .folder-count::after { content: ''; }   /* drop "items" label, save space */
  .folder .folder-actions {
    grid-column: 5;
    /* Always-on actions on touch - no hover state on phones */
    opacity: 1;
  }
  .player {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }
  .player-info { width: 100%; max-width: none; min-width: 0; }
  .player audio { width: 100%; flex-basis: 100%; }
  .upload-status { left: 16px; right: 16px; bottom: 90px; }
  .selection-bar { padding: 10px 16px; }
  .dropzone { padding: 12px 16px 24px; }
}

@media (max-width: 500px) {
  .filter-chips .chip { padding: 6px 10px; font-size: 12px; }
  /* Folders are already a vertical list at this size; the row simplifies
     to icon + name + actions, count badge tucks under the name. */
  .folder {
    grid-template-columns: 24px 1fr auto;
    padding: 8px 10px;
  }
  .folder-icon  { grid-column: 1; }
  .folder-name  { grid-column: 2; }
  .folder-count {
    grid-column: 2;
    grid-row: 2;
    text-align: left;
    font-size: 10.5px;
    margin-top: 1px;
  }
  .folder .folder-actions { grid-column: 3; grid-row: 1 / 3; }
}

/* ---- Home / dashboard view ---- */
.home-view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 4px 60px;
  color: var(--text);
}

.home-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 28px 28px;
  background: linear-gradient(135deg, var(--panel) 0%, rgba(249, 115, 22, 0.08) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 22px;
}
.home-hero-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 6px;
}
.home-hero h1 {
  font-size: 26px;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.home-hero-sub {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 720px;
}
.home-hero-logo {
  width: 80px;
  height: 80px;
  border-radius: 14px;
  flex-shrink: 0;
  object-fit: contain;
  background: var(--bg);
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.25);
}

/* Stat cards grid */
.home-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}
.home-stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.12s;
}
.home-stat:hover { border-color: var(--border-strong); }
.home-stat-icon {
  color: var(--accent);
  display: inline-flex;
  margin-bottom: 4px;
}
.home-stat-value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.home-stat-label {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.home-stat[data-card="review"].alert {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.06);
}
.home-stat[data-card="review"].alert .home-stat-icon {
  color: #fbbf24;
}

/* Sections */
.home-section { margin-bottom: 32px; }

/* "Mount the bucket on your PC" collapsible section on the home page.
   Reuses the .mt-* styles for the inner walkthrough; this just styles
   the <details>/<summary> chrome that wraps it. */
.home-mount-section { margin-bottom: 32px; }
.home-mount-details {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.home-mount-details summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.12s, border-color 0.12s;
}
.home-mount-details summary::-webkit-details-marker { display: none; }
.home-mount-details summary::marker { display: none; content: ''; }
.home-mount-details summary:hover {
  background: var(--panel-2, var(--bg));
}
.home-mount-icon {
  color: var(--accent);
  flex-shrink: 0;
  display: inline-flex;
}
.home-mount-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.home-mount-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.home-mount-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.home-mount-chevron {
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.18s ease, color 0.12s;
  display: inline-flex;
}
.home-mount-details[open] .home-mount-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}
.home-mount-content {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
}
@media (max-width: 600px) {
  .home-mount-details summary { padding: 12px 14px; gap: 10px; }
  .home-mount-content { padding: 14px; }
}
.home-section h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}
.home-section h2 .icon { color: var(--accent); }
.home-section-lead {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 14px;
}

/* Quickstart action cards */
.home-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.home-action {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: all 0.12s;
  /* Without overflow, long sub text inflates the second column past 1fr.
     Combined with min-width:0 on the text wrapper, this keeps the card
     locked to its grid track so cards don't overlap their neighbours. */
  overflow: hidden;
}
.home-action > div {
  /* Default min-width of grid items is auto = content min-width. That lets
     long-word descriptions blow past the 1fr track. Forcing 0 keeps the
     1fr track honest and the card snaps to its parent grid cell. */
  min-width: 0;
}
.home-action-sub {
  /* Long unbreakable strings (URLs, slugs) shouldn't push the card width.
     overflow-wrap handles the runaway-token case word-wrap doesn't. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.home-action:hover {
  border-color: var(--accent);
  background: var(--panel-2);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.home-action.alert-action {
  border-left: 3px solid #fbbf24;
}
.home-action.alert-action:hover { border-color: #fbbf24; }
.home-action-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.home-action.alert-action .home-action-icon {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
}
.home-action-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}
.home-action-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* Do / Don't guide on home page */
.dodont-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 800px) { .dodont-grid { grid-template-columns: 1fr; } }
.dodont {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  border-left-width: 3px;
}
.dodont-do   { border-left-color: #4ade80; }
.dodont-dont { border-left-color: #f87171; }
.dodont-h {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.dodont-do   .dodont-h { color: #4ade80; }
.dodont-dont .dodont-h { color: #f87171; }
.dodont ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dodont li {
  font-size: 13px;
  line-height: 1.5;
  padding-left: 18px;
  position: relative;
}
.dodont-do li::before,
.dodont-dont li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.dodont-do li::before   { background: #4ade80; }
.dodont-dont li::before { background: #f87171; }
.dodont code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--accent);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.dodont-ex {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
}
.home-tip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  font-size: 13px;
}
.home-tip summary {
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.home-tip-body {
  padding: 4px 24px 16px;
  line-height: 1.55;
}
.home-tip-body ol { padding-left: 18px; margin: 0; }
.home-tip-body li { margin-bottom: 6px; }

/* Auto-routing policy table */
.policy-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}
.policy-table th,
.policy-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.policy-table thead th {
  background: var(--panel-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}
.policy-table tbody tr:last-child td { border-bottom: none; }
.policy-table tr.policy-fallback {
  background: rgba(251, 191, 36, 0.05);
}
.policy-table code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  color: var(--accent);
}
.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  margin: 1px 3px 1px 0;
}
.cat-pill.cat-monthly {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
}
.cat-pill.cat-warn {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}
.cat-pill.cat-warn .icon { color: #fbbf24; }

.home-policy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(56, 189, 248, 0.05);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}
.home-policy-note .icon { color: #38bdf8; flex-shrink: 0; margin-top: 1px; }
.home-policy-note code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--text);
}
.home-policy-note a, .home-section a {
  color: var(--accent);
  text-decoration: underline;
}

/* File-tree code block */
.home-tree pre {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.65;
}
.home-tree code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text);
}
.home-tree .muted { color: var(--muted-2); }
.home-tree .hi    { color: var(--accent); font-weight: 600; }

/* Best practices list */
.home-bp {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 10px;
}
.home-bp li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.home-bp li code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  color: var(--accent);
}
.home-bp strong { font-weight: 700; }

/* Workflow steps */
.home-workflow {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wf-step {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.wf-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}
.wf-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.wf-text  { font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.wf-text strong { color: var(--text); font-weight: 600; }
.wf-text code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--accent);
}

.home-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted-2);
}

.muted { color: var(--muted); }

@media (max-width: 700px) {
  .home-hero { flex-direction: column; align-items: flex-start; padding: 22px; }
  .home-hero-logo { width: 56px; height: 56px; }
  .home-hero h1 { font-size: 22px; }
  .home-stats { grid-template-columns: repeat(2, 1fr); }
  .home-actions { grid-template-columns: 1fr; }
  .home-bp { grid-template-columns: 1fr; }
  .policy-table { font-size: 12px; }
  .policy-table th, .policy-table td { padding: 8px 10px; }
}

/* ---- Context banner (path-aware, e.g. syndication folders) ---- */
.context-banner {
  margin-bottom: 14px;
}
.ctx-banner {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
}
.ctx-banner .ctx-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ctx-banner .ctx-body { min-width: 0; }
.ctx-banner .ctx-title {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--text);
  margin-bottom: 4px;
}
.ctx-banner .ctx-sub {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}
.ctx-banner .ctx-sub code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--accent);
}
.ctx-banner .ctx-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
  font-size: 12px;
}
.ctx-banner .ctx-meta-row span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
}
.ctx-banner .ctx-meta-row .icon { color: var(--muted); }
.ctx-banner .ctx-description {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
  white-space: pre-wrap;
}
.ctx-banner .ctx-actions {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .ctx-banner { grid-template-columns: 32px 1fr; }
  .ctx-banner .ctx-actions { grid-column: 1 / -1; margin-top: 8px; }
}

/* ---- Stats banner (PD/MD overview) ---- */
.stats-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 14px;
  align-items: center;
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}
.stat-chip:hover {
  background: var(--panel-2);
  border-color: var(--accent);
  color: var(--text);
}
.stat-name { color: var(--muted); }
.stat-count {
  font-weight: 700;
  color: var(--text);
  background: var(--panel-2);
  padding: 1px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}
.stat-chip:hover .stat-count { background: var(--accent-soft); color: var(--accent); }

/* Folder count badge */
.folder-count {
  background: var(--panel-2);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
}

/* ---- Cat-move dropdown (in file row) ---- */
.cat-move {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11.5px;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  max-width: 110px;
}
.cat-move:hover { border-color: var(--accent); }
.cat-move:focus { outline: none; border-color: var(--accent); }

/* ---- Modal wide variant ---- */
dialog.modal.modal-wide {
  max-width: 640px;
}

/* ---- Rotate modal ---- */
.modal-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
}
.rotate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.rotate-section { display: flex; flex-direction: column; gap: 6px; }
.rotate-section.full { grid-column: 1 / -1; }
.rotate-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.rotate-stations {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}
.rotate-station {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
}
.rotate-station:hover { border-color: var(--accent); }
.rotate-station input { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.rotate-station-info { flex: 1; min-width: 0; }
.rotate-station-name {
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.rotate-station-format {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.rotate-station:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rotate-hint {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}
.rotate-lists {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
}
.rotate-list-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  user-select: none;
}
.rotate-list-opt:hover { border-color: var(--accent); }
.rotate-list-opt input { width: 14px; height: 14px; cursor: pointer; flex-shrink: 0; }
.rotate-list-opt:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rotate-summary-line {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rotate-summary-line strong {
  color: var(--accent);
  font-weight: 700;
}
.rotate-summary-line.rotate-math-warn {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.05);
}

/* ---- Playlist viewer ---- */
.playlist-viewer {
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.pl-header { margin-bottom: 14px; }
.pl-header h3 { margin-bottom: 4px; }
.pl-meta {
  font-size: 12px;
  color: var(--muted);
}
.pl-tracks {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 16px;
  max-height: 50vh;
}
.pl-track {
  display: grid;
  grid-template-columns: 18px 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.pl-track:last-child { border-bottom: none; }
.pl-track:hover { background: var(--panel-2); }
.pl-track-icon { color: var(--accent); display: inline-flex; }
.pl-track-name { min-width: 0; }
.pl-track-name > div:first-child {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pl-track-key {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.pl-track-cat {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

@media (max-width: 700px) {
  .rotate-grid { grid-template-columns: 1fr; }
  .pl-track {
    grid-template-columns: 18px 1fr auto;
    gap: 8px;
  }
  .pl-track-cat { display: none; }
}

/* ---- Review queue panel ---- */
.review-panel,
.categories-panel,
.cat-view-panel {
  display: flex;
  flex-direction: column;
  max-height: 78vh;
}
.review-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 4px;
}
/* "Select all" header strip above the rows */
.rq-bulk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.rq-select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}
.rq-select-all input { width: 16px; height: 16px; cursor: pointer; }
.rq-select-all .rq-count {
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}
.rq-bulk-hint {
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
}

.rq-row {
  display: grid;
  /* Added a leading 28px column for the per-row select checkbox */
  grid-template-columns: 28px 24px 1fr auto;
  gap: 14px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid #fbbf24;
  border-radius: 8px;
}
.rq-row-check {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2px;
}
.rq-row-check input { width: 16px; height: 16px; cursor: pointer; }
.rq-row-icon { color: #fbbf24; padding-top: 2px; }
.rq-row-body { min-width: 0; }
.rq-row-title { font-weight: 700; font-size: 14px; word-break: break-word; }
.rq-row-sub  { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.rq-row-key {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 4px;
  word-break: break-all;
}
.rq-row-reason {
  font-size: 12px;
  color: #fbbf24;
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(251, 191, 36, 0.08);
  padding: 4px 8px;
  border-radius: 6px;
}
.rq-row-reason .icon { flex-shrink: 0; }
.rq-row-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
}
.rq-cat-select {
  font-size: 12px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  min-width: 180px;
}
.rq-cat-select:focus { outline: none; border-color: var(--accent); }
.rq-row-actions .icon-btn { padding: 6px 8px; }

/* Per-row category picker container - sized to fit the right column */
.rq-cat-picker {
  min-width: 240px;
  max-width: 320px;
}
.rq-row-buttons {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* PD Helper - rule-based suggestions panel */
.rq-helper { margin-top: 10px; }
.rq-helper-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.rq-helper-btn:hover { background: rgba(56, 189, 248, 0.18); }

.rq-helper-results {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(56, 189, 248, 0.04);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
}
.rq-helper-loading,
.rq-helper-empty,
.rq-helper-error {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.rq-helper-error { color: #f87171; font-style: normal; }
.rq-helper-header {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rq-helper-header em { color: var(--text); font-style: normal; }
.rq-helper-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.rq-helper-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.12s, transform 0.12s;
}
.rq-helper-card:hover { border-color: #38bdf8; }
.rq-helper-card.picked {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.06);
}
.rq-helper-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.rq-helper-card-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.rq-helper-card-conf {
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 1px 7px;
  border-radius: 999px;
}
.rq-helper-card.picked .rq-helper-card-conf {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}
.rq-helper-card-reasons {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}
.rq-helper-reason { margin-bottom: 2px; }
.rq-helper-pick {
  margin-top: 4px;
  padding: 5px 10px;
  font-size: 11.5px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  align-self: flex-start;
  font-family: inherit;
}
.rq-helper-pick:hover { background: var(--accent-soft); }
.rq-helper-pick:disabled {
  background: rgba(74, 222, 128, 0.1);
  border-color: #4ade80;
  color: #4ade80;
  cursor: default;
}

/* Spotify lookup banner inside helper results */
.rq-lookup-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
}
.rq-lookup-found {
  background: rgba(74, 222, 128, 0.07);
  border: 1px solid rgba(74, 222, 128, 0.4);
  color: var(--text);
}
.rq-lookup-found .rq-lookup-icon { color: #4ade80; flex-shrink: 0; padding-top: 2px; }
.rq-lookup-headline {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4ade80;
  margin-bottom: 4px;
}
.rq-lookup-match { font-size: 13px; margin-bottom: 4px; }
.rq-lookup-match strong { color: var(--text); }
.rq-lookup-year { color: var(--accent); font-variant-numeric: tabular-nums; }
.rq-lookup-detail { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.rq-lookup-detail em { color: var(--text); font-style: normal; }
.rq-lookup-q {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}
.rq-lookup-q code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-style: normal;
  font-size: 10.5px;
}
.rq-lookup-miss {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: var(--text);
}
.rq-lookup-skip {
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border);
  color: var(--muted);
}

.rq-helper-bar {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: flex-end;
}
.rq-helper-relookup {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11.5px;
  font-family: inherit;
}
.rq-helper-relookup:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Sticky bulk-action bar - only shown when 1+ rows selected.
   Lives at the bottom of #pageReview. Slides up from bottom. */
.rq-bulk-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  margin-top: 14px;
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.25);
  flex-wrap: wrap;
  z-index: 5;
}
.rq-bulk-bar[hidden] { display: none; }
.rq-bulk-summary { display: flex; align-items: center; gap: 10px; }
.rq-bulk-count {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.rq-bulk-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.rq-bulk-cat {
  padding: 7px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  min-width: 200px;
}
.rq-bulk-cat:focus { outline: none; border-color: var(--accent); }
.rq-bulk-picker { min-width: 280px; flex: 1; max-width: 420px; }
.rq-bulk-apply {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}
.rq-bulk-apply:hover { background: var(--accent); filter: brightness(1.08); }
.rq-bulk-dismiss {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}
.rq-bulk-dismiss:hover { background: rgba(239, 68, 68, 0.15); }
.rq-bulk-clear {
  padding: 7px 13px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.rq-bulk-clear:hover { color: var(--text); border-color: var(--text); }

@media (max-width: 700px) {
  .rq-row { grid-template-columns: 28px 24px 1fr; }
  .rq-row-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .rq-cat-select { flex: 1; min-width: 140px; }
  .rq-bulk-bar { flex-direction: column; align-items: stretch; }
  .rq-bulk-actions { justify-content: stretch; }
  .rq-bulk-cat { flex: 1; }
}

/* ---- Categories panel ---- */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 4px;
}
.cat-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.cat-row-monthly {
  border-left: 3px solid #38bdf8;
}
.cat-row-icon {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cat-row-monthly .cat-row-icon { color: #38bdf8; }
.cat-row-body { min-width: 0; }
.cat-row-label {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cat-monthly-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 2px 7px;
  border-radius: 999px;
}
.cat-row-slug {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.cat-row-slug code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--accent);
}
.cat-row-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.cat-row-count {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.cat-row-count span {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-top: 2px;
}
.cat-row-actions { display: flex; gap: 4px; }

/* ---- Category-view (tracks-in-this-category) panel ---- */
.cat-view-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 4px;
}
.cat-track {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.cat-track-icon { color: var(--accent); display: inline-flex; }
.cat-track-body { min-width: 0; }
.cat-track-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-track-sub  {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.cat-track-key {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10.5px;
  color: var(--muted-2);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Recent activity widget (home page) ---- */
.home-activity {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  max-height: 320px;
  overflow-y: auto;
}
.activity-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.activity-item:hover { background: var(--panel-2); }
.activity-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
}
.activity-body { min-width: 0; }
.activity-text {
  color: var(--text);
  word-break: break-word;
  line-height: 1.4;
}
.activity-text code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}
.activity-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.activity-time code {
  background: transparent;
  color: var(--muted-2);
  padding: 0;
  font-size: 10.5px;
}

/* ---- Routing rules panel ---- */
.rules-panel {
  display: flex;
  flex-direction: column;
  max-height: 78vh;
}
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 4px;
}
.rule-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
}
.rule-row.rule-inactive {
  opacity: 0.5;
  border-left-color: var(--muted-2);
}
.rule-prio {
  font-weight: 800;
  font-size: 18px;
  color: var(--accent);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.rule-row.rule-inactive .rule-prio { color: var(--muted-2); }
.rule-body { min-width: 0; }
.rule-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}
.rule-cond {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
  line-height: 1.55;
}
.rule-cond code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--accent);
}
.rule-cond .rd-and { color: var(--accent); margin: 0 4px; }
.rule-cond .rd-or  { color: #38bdf8; margin: 0 4px; }
.rule-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}
.rule-notes {
  font-size: 11.5px;
  color: var(--muted-2);
  font-style: italic;
}
.rule-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ---- Rule editor (per-condition rows) ---- */
.re-cond-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.re-cond-head select { font-size: 13px; padding: 6px 10px; }
.re-cond-head button { padding: 6px 12px; font-size: 12px; }
.re-conditions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.re-cond-row {
  display: grid;
  grid-template-columns: 240px 1fr 32px;
  gap: 8px;
  align-items: center;
}
.re-cond-row select,
.re-cond-row input {
  font-size: 12.5px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-family: inherit;
}
.re-cond-row select:focus,
.re-cond-row input:focus { outline: none; border-color: var(--accent); }
.re-cond-row.re-cond-nested {
  grid-template-columns: 1fr 32px;
  background: var(--bg);
  border-radius: 6px;
  padding: 8px 10px;
}
.re-cond-readonly {
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.re-cond-readonly small {
  color: var(--muted-2);
  font-style: italic;
  font-family: inherit;
}

@media (max-width: 700px) {
  .rule-row { grid-template-columns: 40px 1fr; }
  .rule-actions { grid-column: 1 / -1; flex-wrap: wrap; }
  .re-cond-row { grid-template-columns: 1fr 32px; }
  .re-cond-row .re-cond-type { grid-column: 1 / -1; }
}

/* ---- Audit log panel ---- */
.audit-panel {
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}
.al-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.al-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.al-filter-row:nth-child(2) {
  grid-template-columns: 1fr 1fr 2fr;
}
.al-filter-row.al-filter-row-dates {
  grid-template-columns: 1fr 1fr 32px;
}
.al-filters select,
.al-filters input[type="text"],
.al-filters input[type="datetime-local"] {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12.5px;
  min-width: 0;
}
.al-filters select:focus,
.al-filters input:focus { outline: none; border-color: var(--accent); }

.al-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 56vh;
  padding-right: 4px;
}
.al-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.12s;
}
.al-row:hover { background: var(--panel-2); }
.al-row-head {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 10px;
  align-items: center;
}
.al-row-icon {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.al-row-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.al-action {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}
.al-entity-type {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  background: var(--panel-2);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 999px;
}
.al-entity-id {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--accent);
  word-break: break-all;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.al-row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
}
.al-meta-line {
  display: flex;
  align-items: center;
  gap: 6px;
}
.al-meta-secondary { font-size: 10.5px; color: var(--muted-2); }
.al-actor {
  font-weight: 600;
  color: var(--text);
  font-size: 11.5px;
}
.al-country {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.al-ip {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10.5px;
  color: var(--muted-2);
}
.al-time { font-variant-numeric: tabular-nums; }
.al-row-ua {
  font-size: 11px;
  color: var(--muted-2);
  margin-left: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.al-row-ua .icon { color: var(--muted); }
.activity-ip {
  background: var(--bg);
  padding: 0 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10.5px;
  color: var(--muted-2);
}
.al-expand {
  padding: 4px;
  transition: transform 0.18s;
}
.al-row-summary {
  font-size: 12px;
  color: var(--muted);
  margin-left: 34px;
  word-break: break-word;
}
.al-row-summary strong {
  color: var(--text);
  font-weight: 600;
}
.al-detail {
  margin: 6px 0 0 34px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  line-height: 1.55;
  overflow-x: auto;
  max-height: 240px;
  overflow-y: auto;
  color: var(--text);
}

.al-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.al-pagination button {
  padding: 6px 14px;
  font-size: 12px;
}

@media (max-width: 700px) {
  .al-filter-row,
  .al-filter-row:nth-child(2) { grid-template-columns: 1fr; }
  .al-row-head { grid-template-columns: 24px 1fr auto; }
  .al-row-meta { grid-column: 2 / -1; align-items: flex-start; flex-direction: row; gap: 8px; }
}

/* ---- Tool buttons in sidebar (Tasks / Meetings) ---- */
.tool-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
}
.tool-btn:hover { background: var(--panel-2); border-color: transparent; }

/* ---- Note button on file/folder rows ---- */
.note-btn { color: var(--muted); }
.note-btn.has-note {
  color: var(--accent);
  background: var(--accent-soft);
}
.note-btn.has-note:hover { background: rgba(249, 115, 22, 0.2); }

/* ---- Note modal ---- */
.note-h {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.note-subject {
  font-weight: 700;
  word-break: break-all;
}
.note-path {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 14px;
  word-break: break-all;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
#noteText {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 180px;
}
#noteText:focus { outline: none; border-color: var(--accent); }

/* ---- Modal extra-wide variant (panels) ---- */
dialog.modal.modal-xl {
  max-width: 920px;
  width: 95%;
}

dialog.modal textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
dialog.modal textarea:focus { outline: none; border-color: var(--accent); }

dialog.modal label > select { width: 100%; }
dialog.modal label > input[type="date"] { width: 100%; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid-2 .span-2 { grid-column: 1 / -1; }

/* ---- Tasks panel ---- */
.tasks-panel, .meetings-panel {
  display: flex;
  flex-direction: column;
  max-height: 75vh;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  gap: 10px;
  flex-wrap: wrap;
}
.panel-head h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 17px;
}
.panel-head-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.panel-head-actions select { padding: 6px 10px; font-size: 12.5px; }

.task-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 4px;
}
.task {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-left-width: 3px;
}
.task.task-pri-urgent { border-left-color: var(--danger); }
.task.task-pri-high { border-left-color: #fbbf24; }
.task.task-pri-normal { border-left-color: var(--border-strong); }
.task.task-pri-low { border-left-color: var(--muted-2); }

.task.task-done { opacity: 0.55; }
.task.task-done .task-title { text-decoration: line-through; }

.task-status {
  width: 30px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.task.task-done .task-status,
.task.task-done .task-status:hover { color: var(--success); }
.task.task-in-progress .task-status { color: var(--accent); }
.task.task-wont-do .task-status { color: var(--muted-2); }

.task-body { min-width: 0; }
.task-title {
  font-weight: 600;
  font-size: 14px;
  word-wrap: break-word;
}
.task-desc {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
  white-space: pre-wrap;
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}
.task-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.task-priority {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
}
.task-priority.pri-urgent { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.task-priority.pri-high   { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.task-priority.pri-low    { background: var(--panel-2); color: var(--muted); }
.task-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ---- Meetings panel ---- */
.meetings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 4px;
}
.meeting-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color 0.12s;
}
.meeting-card:hover { border-color: var(--border-strong); }
.meeting-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.meeting-title { font-weight: 600; font-size: 15px; }
.meeting-date { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.meeting-card-actions { display: flex; gap: 4px; }
.meeting-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 8px;
}
.meeting-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.meeting-notes {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  white-space: pre-wrap;
}

/* ---- Meeting editor ---- */
.me-stations-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.me-stations-list label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  margin: 0;
  cursor: pointer;
}
.me-stations-list label:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.me-stations-list input { width: 14px; height: 14px; cursor: pointer; }

#meDecisions { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.me-decision {
  display: grid;
  grid-template-columns: 1fr 140px 32px;
  gap: 6px;
  align-items: center;
}
.me-decision input { font-size: 12.5px; padding: 6px 10px; }
.me-d-del { padding: 4px 8px; }

/* ---- Meeting viewer ---- */
.meeting-view h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 18px 0 8px;
}
.meeting-view-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.mv-notes {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.55;
}
.mv-decisions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}
.meeting-decision {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.md-icon { color: var(--success); display: inline-flex; padding-top: 2px; }
.md-text { font-weight: 500; }
.md-track, .md-station {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

@media (max-width: 700px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .me-decision { grid-template-columns: 1fr 32px; }
  .me-decision .me-d-station { grid-column: 1; }
  .task { grid-template-columns: 28px 1fr; }
  .task-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ---- Upload type menu (popover) ---- */
.upload-menu {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 6px;
  min-width: 280px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.upload-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.upload-menu-item:hover { background: var(--panel-2); border-color: var(--border); }
.upload-menu-icon { color: var(--accent); display: inline-flex; }
.upload-menu-text { flex: 1; min-width: 0; }
.upload-menu-label { font-weight: 600; font-size: 13px; }
.upload-menu-hint { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---- Notify progress card ---- */
.notify-progress-card {
  border-left-color: var(--accent) !important;
}
.notify-progress-card .notify-icon { color: var(--accent); }
.notify-progress-title { font-weight: 600; }
.notify-progress-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.notify-progress-bar {
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}
.notify-progress-bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease-out;
  border-radius: 3px;
}

/* ---- Notify progress: counts strip + chevron + expandable file panel ---- */

.notify-progress-card .notify-meta { gap: 8px; flex-wrap: wrap; }
.notify-progress-card .notify-counts {
  display: inline-flex;
  gap: 10px;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.notify-progress-card .np-active { color: var(--accent); font-weight: 600; }
.notify-progress-card .np-done   { color: #4ade80;       font-weight: 600; }
.notify-progress-card .np-failed { color: #f87171;       font-weight: 700; }

/* Chevron toggle - rotates open when files panel expands */
.notify-progress-card .notify-toggle {
  transition: transform 0.18s ease, color 0.12s;
}
.notify-progress-card .notify-toggle.open { transform: rotate(180deg); color: var(--accent); }

/* When the file list opens, give the card more breathing room */
.notify-progress-expanded {
  max-width: min(560px, 92vw) !important;
}

.notify-files {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
}
.np-section { display: flex; flex-direction: column; gap: 4px; }
.np-section-h {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
.np-done-cap {
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}
.np-active-list, .np-done-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.np-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  grid-template-rows: auto 4px;
  align-items: center;
  gap: 4px 8px;
  padding: 6px 8px;
  background: var(--panel-2, var(--bg));
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11.5px;
}
.np-row-icon {
  grid-row: 1;
  grid-column: 1;
  display: inline-flex;
  align-items: center;
}
.np-row-icon[data-status="active"] {
  color: var(--accent);
  animation: np-pulse 1.4s ease-in-out infinite;
}
.np-row-icon[data-status="done"]   { color: #4ade80; }
.np-row-icon[data-status="failed"] { color: #f87171; }
.np-row-icon[data-status="queued"] { color: var(--muted); }
.np-row-name {
  grid-row: 1;
  grid-column: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.np-row-size {
  grid-row: 1;
  grid-column: 3;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.np-row-bar {
  grid-row: 2;
  grid-column: 1 / -1;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}
.np-row-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s ease-out;
}
.np-row-done .np-row-bar-fill   { background: #4ade80; }
.np-row-failed .np-row-bar-fill { background: #f87171; }
.np-row-failed .np-row-name     { text-decoration: line-through; color: var(--muted); }
.np-queue-line {
  font-size: 10.5px;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 4px;
}
@keyframes np-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* ---- Delete-confirm modal ---- */
.del-confirm-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.del-step {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.del-tag-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.del-confirm-stage {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
  align-items: flex-start;
}
.del-warn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.del-warn-icon.danger { color: var(--danger); background: rgba(239, 68, 68, 0.12); }
.del-h { font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.del-confirm-text p { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin-bottom: 6px; }
.del-confirm-text .del-warn-line { color: var(--danger); font-weight: 600; margin-top: 8px; }
.del-single {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  word-break: break-all;
}
.del-list {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px 8px 28px;
  margin: 8px 0;
  max-height: 200px;
  overflow-y: auto;
  font-size: 12.5px;
}
.del-list li { padding: 2px 0; word-break: break-all; }
.del-list-more { color: var(--muted); list-style: none; margin-left: -18px; padding-top: 4px; }
.del-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--danger);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin: 14px 0;
}
.del-input:focus { outline: 2px solid rgba(239, 68, 68, 0.3); outline-offset: 1px; }

/* ---- Metadata editor ---- */
.md-head { margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.md-head h3 {
  margin-bottom: 4px;
  word-break: break-all;
  font-size: 16px;
}
.md-path {
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  word-break: break-all;
}
.md-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 12px;
  margin-bottom: 18px;
}
.md-grid .span-2 { grid-column: span 2; }
.md-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0;
}
.md-grid input { width: 100%; padding: 7px 10px; font-size: 13px; }
.md-explicit-wrap {
  flex-direction: row !important;
  align-items: center;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--text) !important;
  font-weight: 500 !important;
  grid-column: 1 / -1;
  font-size: 12.5px !important;
}
.md-explicit-wrap input { width: 16px !important; height: 16px; cursor: pointer; }

.md-section { margin-bottom: 20px; }
.md-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.md-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.md-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.md-chip:hover { border-color: var(--accent); color: var(--text); }
.md-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.md-cues {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}
.md-cues label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0;
}
.md-cue-hint {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}
.md-cue-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}
.md-cue-row input {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  padding: 7px 10px;
}
.md-mark {
  padding: 7px 10px;
  font-size: 11.5px;
  background: var(--panel-2);
}
.md-mark:hover { background: var(--panel-3); border-color: var(--accent); color: var(--accent); }

.md-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Metadata badge on file rows (small tag icon) */
.meta-btn { color: var(--muted); }
.meta-btn.has-meta { color: var(--accent); background: var(--accent-soft); }
.meta-btn.has-meta:hover { background: rgba(249, 115, 22, 0.2); }

@media (max-width: 700px) {
  .md-grid { grid-template-columns: 1fr 1fr; }
  .md-grid .span-2 { grid-column: span 2; }
  .md-cues { grid-template-columns: 1fr; }
}

/* ---- Voicetrack recorder ---- */
.recorder {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.rec-head h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 17px;
}
.rec-indicator {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  flex-shrink: 0;
  transition: background 0.18s, box-shadow 0.18s;
}
.rec-indicator.rec-recording {
  background: var(--danger);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.7);
  animation: rec-pulse 1.2s ease-in-out infinite;
}
.rec-indicator.rec-paused { background: #fbbf24; }
.rec-indicator.rec-recorded { background: var(--success); }
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(239, 68, 68, 0.7); transform: scale(1); }
  50% { box-shadow: 0 0 22px rgba(239, 68, 68, 1); transform: scale(1.12); }
}
.rec-timer {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.recorder[data-state="recording"] .rec-timer { color: var(--danger); }
.recorder[data-state="paused"] .rec-timer { color: #fbbf24; }

.rec-level {
  width: 100%;
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: block;
}

.rec-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.rec-controls button { padding: 10px 20px; font-size: 13.5px; }

.rec-preview {
  width: 100%;
  height: 40px;
  background: var(--bg);
  border-radius: 6px;
}

.rec-form {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.rec-form label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.rec-form input, .rec-form select { font-family: inherit; }

.rec-hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}
.rec-hint code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
}

/* ---- Metadata: album art ---- */
.md-artwork {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  align-items: flex-start;
}
.md-artwork-frame {
  width: 140px;
  height: 140px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.md-artwork-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.md-artwork-empty {
  text-align: center;
  color: var(--muted-2);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.md-artwork-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.md-artwork-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}
.md-artwork-hint code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10.5px;
}

@media (max-width: 700px) {
  .md-artwork { grid-template-columns: 1fr; }
  .md-artwork-frame { width: 100%; max-width: 200px; height: 200px; margin: 0 auto; }
}

/* ---- Metadata: toolbar (EZtag button) ---- */
.md-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.md-eztag-btn {
  background: rgba(29, 185, 84, 0.1);
  border-color: #1DB954;
  color: #1DB954;
  font-weight: 600;
}
.md-eztag-btn:hover {
  background: rgba(29, 185, 84, 0.18);
  border-color: #1DB954;
}
.md-write-btn {
  background: var(--panel-2);
  color: var(--text);
}

/* ---- Visual waveform (in metadata editor) ---- */
.md-waveform-section {
  margin-bottom: 18px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.md-waveform-stack {
  position: relative;
  margin-bottom: 8px;
}
.md-waveform {
  width: 100%;
  height: 96px;
  display: block;
  background: #0e1117;
  border-radius: 6px;
  cursor: crosshair;
}
.md-wave-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Draggable cue marker pins */
.wf-pin {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
  transform: translateX(-50%);
  z-index: 5;
}
.wf-pin-handle {
  pointer-events: auto;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--pin-color);
  color: #0e1117;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: grab;
  white-space: nowrap;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s, box-shadow 0.12s;
  z-index: 6;
}
.wf-pin-handle:hover {
  transform: translateX(-50%) translateY(-1px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
.wf-pin.dragging .wf-pin-handle {
  cursor: grabbing;
  transform: translateX(-50%) translateY(-2px) scale(1.08);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.6);
}
.wf-pin-line {
  position: absolute;
  top: 22px;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--pin-color);
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0.85;
}
.wf-pin.dragging .wf-pin-line { opacity: 1; box-shadow: 0 0 8px var(--pin-color); }
.md-wave-audio {
  width: 100%;
  height: 32px;
  margin-bottom: 8px;
}
.md-waveform-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  align-items: center;
}
.wf-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--text);
}
.wf-leg-pin {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.wf-leg-hint { margin-left: auto; color: var(--muted-2); font-style: italic; }

/* ---- EZtag (Spotify) modal ---- */
.eztag {
  display: flex;
  flex-direction: column;
  max-height: 75vh;
}
.eztag-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.eztag-head h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
}
.eztag-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 14px;
}
.eztag-search input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.eztag-search input:focus { outline: none; border-color: #1DB954; }
.eztag-search button { padding: 10px 18px; }

.eztag-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 55vh;
  padding-right: 4px;
}
.eztag-hint {
  text-align: center;
  padding: 30px 20px;
  color: var(--muted);
  font-size: 13px;
}
.eztag-hint.eztag-error { color: var(--danger); }

.eztag-result {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: all 0.12s;
  width: 100%;
}
.eztag-result:hover {
  border-color: #1DB954;
  background: rgba(29, 185, 84, 0.06);
}
.eztag-cover {
  width: 56px; height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}
.eztag-info { min-width: 0; }
.eztag-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}
.eztag-tag-explicit {
  font-size: 9px;
  font-weight: 700;
  background: var(--bg);
  color: var(--muted);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.eztag-artist {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eztag-meta {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 4px;
  flex-wrap: wrap;
}
.eztag-pick {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #1DB954;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(29, 185, 84, 0.12);
  flex-shrink: 0;
}
.eztag-pick-icon { display: inline-flex; }

@media (max-width: 700px) {
  .eztag-result { grid-template-columns: 48px 1fr; }
  .eztag-pick { grid-column: 1 / -1; justify-content: center; }
  .eztag-cover { width: 48px; height: 48px; }
  .md-waveform { height: 80px; }
  .md-toolbar { flex-direction: column; align-items: stretch; }
  .md-toolbar button { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .rec-indicator.rec-recording { animation: none !important; }
}

/* ============================================================================
   Tool pages - the seven full-page routes that used to be modal dialogs:
   /tasks/  /meetings/  /review-queue/  /categories/
   /routing-rules/  /audit-log/  /traffic/
   ============================================================================ */
.tool-page {
  display: block;
  padding: 16px 0 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.tool-page[hidden] { display: none !important; }

/* The interior panels were originally laid out for a constrained modal.
   In page mode they should breathe - drop the modal padding constraints. */
.tool-page .panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tool-page .panel-head h3 {
  margin: 0;
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tool-page .panel-head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tool-page .modal-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
  line-height: 1.5;
}

/* ---- Searchable multi-select category picker (widgets/category-picker.js) ---- */
.cp-wrap {
  position: relative;
  width: 100%;
  font-size: 13px;
}
.cp-input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 34px;
  cursor: text;
}
.cp-input-row:focus-within {
  border-color: var(--accent);
  outline: none;
}
.cp-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.cp-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft, rgba(249, 115, 22, 0.12));
  color: var(--accent);
  padding: 2px 6px 2px 8px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  max-width: 200px;
}
.cp-chip-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-chip-x {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.7;
}
.cp-chip-x:hover { opacity: 1; }
.cp-input {
  flex: 1;
  min-width: 100px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 4px 6px;
  font: inherit;
  font-size: 13px;
}
.cp-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  display: inline-flex;
  align-items: center;
}
.cp-toggle:hover { color: var(--text); }

.cp-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 50;
  overflow: hidden;
}
.cp-options {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.cp-option {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12.5px;
}
.cp-option.highlight { background: var(--bg); }
.cp-option.selected { color: var(--accent); font-weight: 600; }
.cp-check {
  text-align: center;
  font-size: 11px;
  color: var(--accent);
}
.cp-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  font-weight: 700;
}
.cp-empty {
  padding: 14px 12px;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  font-size: 12px;
}
.cp-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.cp-actions-count {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}
.cp-apply {
  padding: 5px 14px;
  font-size: 12px;
}

/* ---- Mount-as-drive page ---- */
.mount-panel { max-width: 820px; }
.mt-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 8px 0 18px;
}
.mt-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}
.mt-tab:hover { color: var(--text); }
.mt-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.mt-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.mt-section h3 {
  font-size: 14px;
  margin: 0 0 8px;
  font-weight: 700;
}
.mt-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: mt-step;
}
.mt-steps li {
  counter-increment: mt-step;
  position: relative;
  padding-left: 30px;
  margin-bottom: 14px;
}
.mt-steps li::before {
  content: counter(mt-step);
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.mt-step-label { font-size: 13px; line-height: 1.5; margin-bottom: 6px; }

.mt-cmd {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  overflow-x: auto;
}
.mt-cmd code { flex: 1; min-width: 0; white-space: nowrap; }
.mt-cmd-headline {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-size: 13px;
  padding: 12px 14px;
}
.mt-copy {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.mt-copy:hover { color: var(--accent); border-color: var(--accent); }
.mt-copy.copied { color: #4ade80; border-color: #4ade80; }

.mt-secret {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0;
}
.mt-secret summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 13px;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mt-pre {
  position: relative;
  margin: 0;
  padding: 14px;
  background: var(--panel);
  font-size: 11.5px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  border-top: 1px solid var(--border);
  white-space: pre;
  overflow-x: auto;
}
.mt-pre .mt-copy { position: absolute; top: 8px; right: 8px; }

.mt-tip {
  background: rgba(56, 189, 248, 0.06);
  border-color: rgba(56, 189, 248, 0.3);
  font-size: 13px;
  line-height: 1.55;
}
.mt-fineprint { font-size: 11.5px !important; line-height: 1.5; margin-top: 6px; }

/* ---- Add-station progress view ---- */
.as-progress {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 380px;
}
.as-name-echo { color: var(--accent); font-weight: 700; }
.as-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.as-step {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.as-step-icon {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: inline-block;
  position: relative;
}
/* Active = pulsing accent ring + spinner */
.as-step.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(249, 115, 22, 0.06);
}
.as-step.active .as-step-icon {
  border-color: transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  animation: as-spin 0.8s linear infinite;
}
/* Done = solid green check */
.as-step.done {
  color: var(--text);
}
.as-step.done .as-step-icon {
  background: #4ade80;
  border-color: #4ade80;
}
.as-step.done .as-step-icon::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #0a0e1a;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
/* Failed = red X */
.as-step.failed {
  color: var(--text);
  border-color: #f87171;
  background: rgba(239, 68, 68, 0.08);
}
.as-step.failed .as-step-icon {
  background: #f87171;
  border-color: #f87171;
}
.as-step.failed .as-step-icon::before,
.as-step.failed .as-step-icon::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 2px;
  width: 2px;
  height: 10px;
  background: #0a0e1a;
}
.as-step.failed .as-step-icon::before { transform: rotate(45deg); }
.as-step.failed .as-step-icon::after  { transform: rotate(-45deg); }

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

.as-success-summary {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
}
.as-success-summary code {
  background: rgba(249, 115, 22, 0.1);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--accent);
}

.as-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* ---- Duplicate-files upload handler ---- */
.dup-confirm {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dup-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.dup-icon { color: #fbbf24; flex-shrink: 0; margin-top: 2px; }
.dup-h {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}
.dup-sub { color: var(--muted); font-size: 13px; margin: 0; }
.dup-list {
  list-style: none;
  margin: 0;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 12px;
}
.dup-list li { padding: 2px 0; }
.dup-list code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}
.dup-more { color: var(--muted); font-style: italic; }
.dup-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dup-choice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.12s, background 0.12s;
}
.dup-choice:hover { border-color: var(--accent); background: var(--panel-2); }
.dup-choice.danger:hover { border-color: #f87171; }
.dup-choice-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}
.dup-choice-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---- Rotate monthly modal ---- */
.rm-current-info {
  margin: 8px 0 14px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.rm-current-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rm-current-empty {
  color: var(--muted);
  font-style: italic;
}
.rm-current-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.rm-arrow {
  color: var(--accent);
  font-weight: 700;
}
.rm-affected-rules {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.rm-rule {
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid #38bdf8;
  border-radius: 6px;
}
.rm-rule-inactive {
  border-left-color: var(--muted);
  opacity: 0.65;
}
.rm-rule-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.rm-rule-name {
  font-weight: 600;
  font-size: 13px;
}
.rm-rule-meta {
  color: var(--muted);
  font-size: 11px;
}
.rm-rule-diff {
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.rm-rule-diff code {
  display: inline-block;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
  font-size: 11px;
}
.rm-diff-label {
  display: inline-block;
  width: 56px;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
}
.rm-rule-diff code.rm-old {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
  text-decoration: line-through;
}
.rm-rule-diff code.rm-new {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

/* ============================================================================
   Traffic / Ad Manager
   ============================================================================ */

.traffic-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.traffic-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.traffic-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.traffic-tab:hover { color: var(--text); }
.traffic-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.traffic-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* ---- Common: toolbar / table / pills ---- */

.tr-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.tr-toolbar-left,
.tr-toolbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.tr-search {
  min-width: 240px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}
.tr-filter {
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}
.tr-inline-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

.tr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tr-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tr-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.tr-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}
.tr-table .tr-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tr-row-sub {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}
.tr-key {
  background: var(--bg);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--accent);
  word-break: break-all;
}
.tr-muted { color: var(--muted); font-size: 12px; }

.tr-list-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tr-pill {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  font-weight: 600;
}
.tr-pill-tag {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  margin-left: 4px;
}

.tr-credit {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tr-credit-ok     { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.tr-credit-warn   { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.tr-credit-danger { background: rgba(239, 68, 68, 0.15);  color: #f87171; }

.tr-status {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}
.tr-status-pending   { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.tr-status-approved  { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.tr-status-running   { background: rgba(34, 197, 94, 0.15);  color: #4ade80; }
.tr-status-completed { background: rgba(148, 163, 184, 0.10); color: #94a3b8; }
.tr-status-cancelled { background: rgba(239, 68, 68, 0.15);  color: #f87171; }

.tr-pacing {
  position: relative;
  height: 18px;
  background: var(--bg);
  border-radius: 4px;
  min-width: 100px;
  overflow: hidden;
}
.tr-pacing-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  transition: width 0.2s ease;
}
.tr-pacing-pct {
  position: relative;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  padding-left: 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---- Dashboard ---- */

.tr-dash { display: flex; flex-direction: column; gap: 18px; }
.tr-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.tr-kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.tr-kpi-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}
.tr-kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tr-kpi-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.tr-warn { color: #fbbf24 !important; font-weight: 700; }
.tr-dash-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 900px) { .tr-dash-row { grid-template-columns: 1fr; } }
.tr-dash-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.tr-dash-card h4 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}
.tr-dash-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
}

/* ---- Form (shared editor for clients/campaigns/spots) ---- */

.tr-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tr-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
@media (max-width: 700px) { .tr-form-grid { grid-template-columns: 1fr; } }
.tr-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.tr-form-grid input,
.tr-form-grid select,
.tr-form-grid textarea {
  padding: 7px 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
.tr-span-2 { grid-column: span 2; }
@media (max-width: 700px) { .tr-span-2 { grid-column: span 1; } }
.tr-section-divider {
  grid-column: span 2;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  color: var(--muted);
  font-weight: 700;
}
.tr-section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

/* ---- Stations grid (inside campaign editor) ---- */

.tr-stations-grid input,
.tr-stations-grid select {
  width: 100%;
  padding: 5px 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
}
.tr-station-rate {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.tr-station-line-gross {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tr-totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}
@media (max-width: 700px) { .tr-totals { grid-template-columns: repeat(2, 1fr); } }
.tr-total {
  display: flex;
  flex-direction: column;
}
.tr-total-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
.tr-total-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.tr-total-net .tr-total-value {
  color: #4ade80;
}

.tr-detail { display: flex; flex-direction: column; gap: 14px; }
.tr-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.tr-detail-client { font-size: 14px; font-weight: 600; }
.tr-detail-flight { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tr-detail-totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}
.tr-detail-totals > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tr-detail-totals label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
.tr-detail-totals span {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tr-detail h4 {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 8px 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.tr-notes {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  margin: 0;
  white-space: pre-wrap;
  font-size: 13px;
}

/* ---- Rate cards grid ---- */

.tr-pricing-guide {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
}
.tr-pricing-guide summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 13px;
  user-select: none;
}
.tr-guide-body { padding: 4px 16px 14px; font-size: 13px; line-height: 1.55; }
.tr-guide-body ul { padding-left: 18px; margin: 6px 0; }
.tr-guide-body code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

.tr-rate-wrap { overflow-x: auto; padding-bottom: 50px; }
.tr-rate-table { font-size: 12px; }
.tr-rate-table th { font-size: 10px; }
.tr-rate-station-col { min-width: 160px; }
.tr-rate-station strong { display: block; }
.tr-rate-head { font-size: 10px; }
.tr-rate-tier {
  font-size: 9px;
  text-transform: uppercase;
  margin-top: 2px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.tr-tier-premium  { color: #4ade80; }
.tr-tier-standard { color: #38bdf8; }
.tr-tier-value    { color: #fbbf24; }
.tr-tier-overnight{ color: #94a3b8; }
.tr-rate-cell { padding: 4px !important; min-width: 80px; }
.tr-rate-cell.tr-tier-premium  { background: rgba(34, 197, 94, 0.04); }
.tr-rate-cell.tr-tier-standard { background: rgba(56, 189, 248, 0.04); }
.tr-rate-cell.tr-tier-value    { background: rgba(251, 191, 36, 0.04); }
.tr-rate-cell.tr-tier-overnight{ background: rgba(148, 163, 184, 0.04); }
.tr-currency {
  position: absolute;
  margin-left: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}
.tr-rate-input {
  width: 100%;
  padding: 6px 6px 6px 16px;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text);
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.tr-rate-input:focus {
  border-color: var(--accent);
  outline: none;
  background: var(--panel);
}
.tr-length-toggle {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.tr-len-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.tr-len-btn.active {
  background: var(--accent);
  color: #000;
}
.tr-rate-savebar {
  position: sticky;
  bottom: 0;
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 6px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
}
.tr-rate-savebar.active { display: flex; }
.tr-rate-savebar button {
  padding: 6px 12px;
}
