/* Bag Recorder · polar-ops-console · module accordion + topic list */

.app {
  height: calc(100vh / var(--zoom, 1));
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

/* ── Top bar ── */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--accent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 13px; font-weight: 650; letter-spacing: .02em; }
.brand-text .sub { font-size: 11px; color: var(--text-2); }
.top-nav { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.nav-link {
  height: 32px; padding: 0 12px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2); font-weight: 560; font-size: 13px;
  display: inline-flex; align-items: center;
}
.nav-link.is-active { color: var(--accent); background: var(--accent-soft); }
span.nav-link { cursor: default; }
.topbar-spacer { flex: 1; }
.top-search input {
  height: 32px; width: min(240px, 24vw); padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-muted); outline: none;
}
.top-search input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.topbar-meta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface-muted); border: 1px solid var(--border); font-size: 12px;
}
.topbar-meta.is-ok .dot { background: var(--online); color: var(--online); }
.topbar-meta.is-bad .dot { background: var(--offline); color: var(--offline); }
.topbar-meta.is-rec .dot {
  background: var(--offline); color: var(--offline);
  animation: pulse 1.5s ease-in-out infinite;
}
.topbar-meta.is-play .dot {
  background: var(--accent); color: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}
.topbar-prefs { display: flex; gap: 6px; align-items: center; }
.zoom-select {
  height: 32px; padding: 0 8px; width: auto;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-muted);
}

.dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
  position: relative; flex: none; background: var(--unknown); color: var(--unknown);
}
.dot::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 1px solid currentColor; opacity: .25;
}
.dot.on { background: var(--online); color: var(--online); }
.dot.warn { background: var(--warning); color: var(--warning); }
.dot.off { background: var(--unknown); color: var(--unknown); }
@keyframes pulse { 50% { opacity: .35; } }

/* ── Shell ── */
.shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  background: var(--bg);
}

.rail {
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.rail-btn {
  width: 40px; height: 40px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2);
  display: grid; place-items: center;
}
.rail-btn svg { width: 18px; height: 18px; }
.rail-btn:hover { background: var(--surface-muted); color: var(--text-1); }
.rail-btn.is-active { background: var(--accent-soft); color: var(--accent); }
.rail-spacer { flex: 1; }

/* ── Main stage: modules | topics ── */
.stage {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  background: var(--bg);
}

.module-pane {
  flex: 0 0 var(--module-w);
  width: var(--module-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.module-pane-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.module-pane-head h2 {
  margin: 0; font-size: 13px; font-weight: 650; letter-spacing: .02em;
}
.module-pane-tools { display: flex; gap: 4px; }
.icon-btn {
  width: 28px; height: 28px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--text-2); display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-muted); color: var(--text-1); }
.icon-btn.is-active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.icon-btn svg { width: 14px; height: 14px; }

.module-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 6px;
}

.group-block { margin-bottom: 6px; }
.group-head {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 4px 6px 2px;
}

/* 模块行卡片化（紧凑行高） */
.mod-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 0 0 2px;
  padding: 4px 8px 4px 10px;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text-1);
  text-align: left;
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.mod-card::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: transparent;
  transition: background .15s var(--ease);
}
.mod-card:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}
.mod-card.is-active {
  background: var(--accent-soft);
  border-color: rgba(var(--accent-rgb), .35);
  box-shadow: var(--shadow-1);
}
.mod-card.is-active::before { background: var(--accent); width: 4px; }
.mod-card.is-offline-all { color: var(--text-2); }
.mod-card.is-offline-all .mod-icon { color: var(--text-3); }

.mod-check {
  flex: 0 0 auto;
  width: 13px; height: 13px;
  accent-color: var(--accent);
  margin: 0;
}
.mod-icon {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 5px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
}
.mod-card.is-active .mod-icon {
  background: var(--surface);
  border-color: rgba(var(--accent-rgb), .4);
}
.mod-icon svg { width: 13px; height: 13px; }
.mod-meta {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: baseline; gap: 6px;
  flex-wrap: nowrap;
}
.mod-title {
  font-size: 12px; font-weight: 560; line-height: 1.15;
  display: inline-flex; align-items: center; gap: 4px;
  flex: 0 1 auto; min-width: 0;
}
.mod-card.is-active .mod-title { font-weight: 680; color: var(--accent-strong); }
.mod-sub {
  margin-top: 0;
  font-size: 10px;
  color: var(--text-3);
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.mod-badge {
  flex: 0 0 auto;
  min-width: 30px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-badge);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.mod-card.is-active .mod-badge {
  background: var(--surface);
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), .35);
}
.mod-badge .dot { width: 6px; height: 6px; }
.mod-badge .dot::after { display: none; }

/* ── Topic pane ── */
.topic-pane {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.topic-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topic-search {
  flex: 1 1 auto;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  outline: none;
  min-width: 0;
}
.topic-search:focus { border-color: var(--accent); box-shadow: var(--ring); }
.topic-summary {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}
.topic-summary strong { color: var(--text-1); font-weight: 650; }

.topic-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px 12px 16px;
}
.topic-row {
  display: grid;
  grid-template-columns: 18px 18px minmax(0, 1.2fr) minmax(0, .9fr) 72px;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.topic-row:hover { background: var(--surface); border-color: var(--border); }
.topic-row.is-hit {
  background: var(--accent-soft);
  border-color: rgba(var(--accent-rgb), .2);
}
.topic-row.is-selected {
  background: var(--surface);
  border-color: var(--border);
}
.topic-row .name {
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topic-row .type {
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topic-row .hz {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 650;
  text-align: right;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.topic-row .hz.is-live { color: var(--accent); }
.topic-row .hz.is-zero { color: var(--warning); }
.topic-row .hz.is-wait { color: var(--text-3); font-weight: 500; }
.topic-row mark {
  background: rgba(var(--accent-rgb), .22);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.topic-empty {
  margin: 40px auto;
  text-align: center;
  color: var(--text-3);
  max-width: 280px;
}
.btn-quiet {
  height: 32px; padding: 0 12px;
  border: 1px solid transparent;
  background: transparent; color: var(--text-2);
}
.btn-quiet:hover { background: var(--surface-muted); color: var(--text-1); border-color: var(--border); }

/* ── Detail panel ── */
.detail {
  flex: 0 0 var(--detail-w);
  width: var(--detail-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
.detail-head {
  flex: 0 0 auto;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.detail-head-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.detail-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  border-radius: var(--radius-badge);
  font-size: 11px; font-weight: 650;
  background: var(--surface-muted); color: var(--text-2);
  border: 1px solid var(--border);
}
.badge.is-online { background: #EAF7EF; color: var(--online); border-color: transparent; }
.badge.is-busy { background: #FDECEC; color: var(--offline); border-color: transparent; }
.badge.is-play { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.cfg-check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-1); margin-bottom: 10px;
  cursor: pointer; user-select: none;
}
.cfg-check input { width: 15px; height: 15px; accent-color: var(--accent); }
.cfg-textarea {
  width: 100%; min-height: 56px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-muted); outline: none; resize: vertical;
  line-height: 1.4;
}
.cfg-textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
.btn-play-stop {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-play-stop:hover:not(:disabled) {
  background: var(--accent-soft);
}

.detail-tabs {
  display: flex; gap: 2px; padding: 8px 12px 0;
  border-bottom: 1px solid var(--border);
}
.detail-tab {
  height: 32px; padding: 0 12px; border: 0; border-radius: 6px 6px 0 0;
  background: transparent; color: var(--text-2); font-weight: 560;
}
.detail-tab:hover { color: var(--text-1); background: var(--surface-muted); }
.detail-tab.is-active {
  color: var(--accent); background: var(--accent-soft);
}

.detail-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 16px;
}
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.kpi .label { font-size: 11px; color: var(--text-2); }
.kpi .value {
  margin-top: 2px;
  font-size: 18px; font-weight: 650; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.kpi .hint { margin-top: 2px; font-size: 11px; color: var(--text-3); }

.section-title {
  margin: 14px 0 8px;
  font-size: 11px; font-weight: 650;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3);
}
.section-title:first-child { margin-top: 0; }

/* Config 分组：常改默认展开，存储/压缩默认折叠 */
.cfg-group {
  margin: 0 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.cfg-group > summary {
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  background: var(--surface-muted);
}
.cfg-group > summary::-webkit-details-marker { display: none; }
.cfg-group > summary::before {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(-45deg);
  margin-right: 2px;
  flex: 0 0 auto;
  transition: transform .15s ease;
}
.cfg-group[open] > summary::before {
  transform: rotate(45deg);
  margin-top: 2px;
}
.cfg-group-title {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-1);
}
.cfg-group-hint {
  font-size: 11px;
  color: var(--text-3);
}
.cfg-group-body {
  padding: 10px 12px 2px;
  border-top: 1px solid var(--border);
}
.field label[title] { cursor: help; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr; }
}
.cfg-save { width: 100%; margin-top: 4px; }

.field { margin-bottom: 10px; }
.field label {
  display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px;
}
.field-hint {
  margin: -4px 0 12px;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.35;
}
.field input, .field select {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-muted); outline: none;
}
.field input:focus, .field select:focus {
  border-color: var(--accent); box-shadow: var(--ring);
}
.kv-list { display: flex; flex-direction: column; gap: 6px; }
.kv-row {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 12px; min-height: 28px; align-items: center;
}
.kv-row .k { color: var(--text-2); }
.kv-row .v { color: var(--text-1); font-weight: 560; text-align: right; }

.log-box {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  max-height: 220px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-2);
  white-space: pre-wrap;
}

.detail-actions {
  flex: 0 0 auto;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
}
.btn {
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-1);
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover:not(:disabled) { background: var(--surface-muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-muted); color: var(--text-2);
  display: grid; place-items: center;
}
.btn-icon:hover { color: var(--text-1); }
.btn-ghost {
  background: transparent; border-color: transparent; color: var(--text-2); height: 28px;
}
.btn-ghost:hover { color: var(--accent); background: var(--accent-soft); }
.btn-danger-ghost { color: var(--offline); }
.btn-danger-ghost:hover { background: #FDECEC; color: var(--offline); }

.toast-host {
  position: fixed; right: 16px; bottom: 88px; z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  min-width: 220px; max-width: 360px;
  padding: 10px 14px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-2); font-size: 12px;
}
.toast.err { border-color: rgba(214, 69, 69, .4); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(26, 35, 48, .28);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  width: min(720px, 100%);
  max-height: min(80vh, 640px);
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 14px; }
.modal-body {
  padding: 12px 16px; overflow: auto;
  font-family: var(--mono); font-size: 11px; white-space: pre-wrap;
  color: var(--text-2); line-height: 1.5;
}
.bag-info-topic {
  color: var(--accent);
  font-weight: 700;
}
.bag-info-count {
  color: #C05621;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
html.dark .bag-info-count { color: #F6AD55; }

@media (max-width: 1100px) {
  :root { --detail-w: 300px; --module-w: 220px; }
}

/* ── Bags library + cards + player ── */
.bags-view {
  flex: 1 1 auto;
  min-width: 0;
  background:
    radial-gradient(900px 280px at 12% -10%, rgba(var(--accent-rgb), 0.07), transparent 60%),
    var(--bg);
}
.lib-pane {
  flex: 0 0 248px;
  width: 248px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.lib-pane .module-pane-head {
  border-bottom: 1px solid var(--border);
}
.lib-roots {
  flex: 1 1 auto;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}
.lib-item {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 10px;
  background: transparent;
  padding: 8px 8px;
  color: var(--text-1);
  transition: background .15s var(--ease), box-shadow .15s var(--ease);
}
.lib-item:hover { background: var(--surface-muted); }
.lib-item.is-active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.lib-item-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
}
.lib-item.is-active .lib-item-icon {
  background: rgba(var(--accent-rgb), 0.16);
  color: var(--accent);
}
.lib-item-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lib-item-name { font-size: 12px; font-weight: 650; }
.lib-item-path {
  font-size: 10px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lib-item-count {
  font-size: 11px; font-weight: 700; color: var(--text-2);
  min-width: 22px; height: 22px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--surface-muted);
}
.lib-item.is-active .lib-item-count { background: var(--surface); color: var(--accent); }
.lib-item-remove {
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-3); font-size: 14px; line-height: 1;
}
.lib-item-remove:hover { background: #FDECEC; color: var(--offline); }
.lib-import {
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-muted), var(--surface));
}
.lib-import-head {
  font-size: 11px; font-weight: 700; color: var(--text-2);
  margin-bottom: 8px;
}
.lib-import-btn {
  width: 100%; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700;
}
.lib-import .field-hint { margin: 8px 0 0; font-size: 10px; }

/* ── Directory picker (local file manager) ── */
.modal.dir-picker {
  width: min(720px, 100%);
  max-height: min(86vh, 720px);
  border-radius: 14px;
  overflow: hidden;
}
.dir-picker-body {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 14px 0;
  min-height: 0; flex: 1 1 auto;
}
.dir-shortcuts { display: flex; flex-wrap: wrap; gap: 6px; }
.dir-chip {
  height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-muted);
  color: var(--text-2); font-size: 11px; font-weight: 650;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.dir-chip:hover, .dir-chip.is-active {
  border-color: rgba(var(--accent-rgb), 0.45);
  background: var(--accent-soft);
  color: var(--accent);
}
.dir-pathbar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-muted);
}
.dir-up {
  width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: var(--surface); color: var(--text-2);
  display: grid; place-items: center; flex: none;
  box-shadow: var(--shadow-1);
}
.dir-up:hover:not(:disabled) { color: var(--accent); }
.dir-up:disabled { opacity: 0.35; cursor: not-allowed; }
.dir-crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  min-width: 0; flex: 1 1 auto;
  max-height: 64px; overflow: auto;
}
.dir-crumb {
  border: 0; background: transparent; color: var(--text-2);
  font-size: 12px; font-weight: 600; font-family: var(--mono);
  padding: 4px 6px; border-radius: 6px; cursor: pointer;
}
.dir-crumb:hover { background: var(--surface); color: var(--accent); }
.dir-crumb.is-current { color: var(--text-1); cursor: default; }
.dir-crumb-sep { color: var(--text-3); font-size: 11px; user-select: none; }
.dir-list {
  flex: 1 1 auto;
  min-height: 280px; max-height: min(48vh, 420px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.04), transparent 48px),
    var(--surface);
}
.dir-empty {
  padding: 36px 16px; text-align: center;
  color: var(--text-3); font-size: 12px;
}
.dir-item {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 0; border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text-1);
  transition: background .12s var(--ease);
}
.dir-item:last-child { border-bottom: 0; }
.dir-item:hover { background: var(--surface-muted); }
.dir-item.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.dir-item-ico {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: rgba(233, 168, 32, 0.14); color: #C05621;
}
.dir-item.is-bag .dir-item-ico {
  background: var(--accent-soft); color: var(--accent);
}
.dir-item-name {
  min-width: 0;
  font-size: 13px; font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dir-item-meta {
  font-size: 10px; font-weight: 700; color: var(--text-3);
  white-space: nowrap;
}
.dir-item.is-bag .dir-item-meta { color: var(--accent); }
.dir-current {
  display: flex; align-items: baseline; gap: 8px;
  padding: 2px 2px 0; min-width: 0;
}
.dir-current-label {
  flex: none; font-size: 10px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.dir-current code {
  min-width: 0; font-size: 11px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dir-picker-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  background: var(--surface-muted);
}

.bags-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: transparent; }
.bags-toolbar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px 8px;
}
.bags-toolbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bags-toolbar-left strong { font-size: 15px; font-weight: 700; }
.bags-filter-chip {
  height: 22px; padding: 0 8px; border-radius: 999px;
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft);
}
.bags-list {
  flex: 1 1 auto; min-height: 0; overflow: auto;
  padding: 4px 16px 18px;
}
.bag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  align-content: start;
}
.bag-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.bag-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}
.bag-card.is-selected {
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12), var(--shadow-1);
}
.bag-card.is-playing { border-color: rgba(var(--accent-rgb), 0.55); }
.bag-card.is-recording { border-color: rgba(214, 69, 69, 0.4); }
.bag-card.is-broken { opacity: 0.8; }

.bag-card-hero {
  position: relative;
  height: 52px;
  cursor: pointer;
  background:
    radial-gradient(100px 60px at 80% 20%, rgba(var(--accent-rgb), 0.18), transparent 70%),
    linear-gradient(145deg, #E8F4F6 0%, #F4F7F8 55%, #EEF2F4 100%);
  display: grid;
  place-items: center;
}
html.dark .bag-card-hero {
  background:
    radial-gradient(100px 60px at 80% 20%, rgba(var(--accent-rgb), 0.22), transparent 70%),
    linear-gradient(145deg, #1A2430 0%, #161C24 100%);
}
.bag-card.is-playing .bag-card-hero {
  background:
    radial-gradient(110px 70px at 70% 30%, rgba(var(--accent-rgb), 0.35), transparent 70%),
    linear-gradient(145deg, rgba(var(--accent-rgb), 0.22), #EAF6F8);
}
.bag-card-hero-art { color: rgba(var(--accent-rgb), 0.45); }
.bag-card-hero-art svg { width: 18px; height: 18px; }
.bag-card-badges {
  position: absolute; top: 6px; left: 8px;
  display: flex; flex-wrap: wrap; gap: 4px; max-width: calc(100% - 48px);
}
.bag-play-btn {
  position: absolute; right: 8px; bottom: 8px;
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 6px 14px -6px rgba(var(--accent-rgb), 0.85);
  transition: transform .15s var(--ease), background .15s var(--ease);
}
.bag-play-btn:hover:not(:disabled) { background: var(--accent-strong); transform: scale(1.06); }
.bag-play-btn:disabled {
  background: rgba(154, 163, 173, 0.55); color: #fff;
  box-shadow: none; cursor: not-allowed;
}

.bag-card-body {
  min-width: 0; cursor: pointer;
  padding: 12px 12px 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.bag-name {
  font-size: 12px; font-weight: 700; color: var(--text-1);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}
.bag-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  background: var(--surface-muted);
}
.bag-stat { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bag-stat .k {
  font-size: 10px; color: var(--text-3); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bag-stat strong {
  font-size: 12px; color: var(--text-1); font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bag-pill {
  height: 18px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--text-2); background: rgba(255,255,255,0.82);
  border: 1px solid rgba(226, 230, 234, 0.9);
}
html.dark .bag-pill { background: rgba(22, 28, 36, 0.8); border-color: var(--border); }
.bag-pill.is-play { color: var(--accent); border-color: rgba(var(--accent-rgb), 0.25); background: var(--accent-soft); }
.bag-pill.is-rec { color: var(--offline); border-color: rgba(214, 69, 69, 0.25); background: rgba(214, 69, 69, 0.12); }
.bag-pill.is-warn { color: #B7791F; border-color: rgba(233, 168, 32, 0.3); background: rgba(233, 168, 32, 0.16); }

.bag-card-foot {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border);
}
.bag-mtime {
  font-size: 10px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bag-card-actions { display: flex; gap: 2px; flex: none; }
.icon-act {
  width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-3);
  display: grid; place-items: center;
}
.icon-act:hover { background: var(--surface-muted); color: var(--text-1); }
.icon-act.is-expanded { color: var(--accent); background: var(--accent-soft); }
.icon-act.is-danger:hover { background: #FDECEC; color: var(--offline); }
.icon-act:disabled { opacity: 0.35; cursor: not-allowed; }


/* ── Bottom player dock ── */
.player-dock {
  flex: 0 0 auto;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 30px -20px rgba(26, 35, 48, 0.35);
}
html.dark .player-dock { background: rgba(22, 28, 36, 0.92); }
.player-progress-track {
  height: 3px; background: var(--surface-3); overflow: hidden;
}
.player-progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), #3DB8C5);
  transition: width .2s linear;
}
.player-dock.is-playing .player-progress-fill {
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.45);
}
.player-dock.is-error .player-progress-fill { background: var(--offline); }
.player-dock-inner {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(280px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 10px 18px 12px;
}
.player-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.player-cover {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.player-dock.is-playing .player-cover {
  background: var(--accent); color: #fff;
  animation: pulse 1.8s ease-in-out infinite;
}
.player-dock.is-paused .player-cover { background: rgba(233, 168, 32, 0.18); color: var(--warning); }
.player-dock.is-error .player-cover { background: rgba(214, 69, 69, 0.14); color: var(--offline); }
.player-title-block { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.player-title { font-size: 12px; font-weight: 700; }
.player-sub { font-size: 11px; color: var(--text-3); }
.player-dock.is-error .player-sub { color: var(--offline); }
.player-center { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.player-controls { display: flex; align-items: center; justify-content: center; gap: 8px; }
.player-btn {
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: var(--surface-muted); color: var(--text-1);
  display: grid; place-items: center;
}
.player-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.player-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#btnPlayerPlay, #btnPlayerPause {
  width: 42px; height: 42px;
  background: var(--accent); color: #fff;
  box-shadow: 0 8px 18px -10px rgba(var(--accent-rgb), 0.9);
}
#btnPlayerPlay:hover:not(:disabled),
#btnPlayerPause:hover:not(:disabled) { background: var(--accent-strong); color: #fff; }
.player-timeline {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.player-time { font-size: 11px; color: var(--text-2); min-width: 40px; text-align: center; }
.player-seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  outline: none;
  cursor: pointer;
}
.player-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.player-seek:disabled { opacity: 0.4; cursor: not-allowed; }
.player-opts {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; justify-content: flex-end;
}
.player-rate select {
  height: 30px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-muted); font-weight: 600;
}
.player-chip {
  height: 30px; padding: 0 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  font-size: 11px; color: var(--text-2); cursor: pointer; user-select: none;
}
.player-chip:has(input:checked) {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}
.player-chip input { accent-color: var(--accent); }

html.dark .player-seek::-webkit-slider-thumb { border-color: var(--surface); }

@media (max-width: 1100px) {
  .player-dock-inner {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .player-opts { justify-content: center; }
  .lib-pane { flex-basis: 220px; width: 220px; }
  .bag-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
}
