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

/* ============================================================================
   HomelabToolkit — Tracearr-modeled design system (ported from app-theme.css)
   ========================================================================== */
:root {
  --bg: #0a0c0f;
  --bg-2: #0c0f13;
  --surface: #101419;
  --surface2: #151a21;
  --surface3: #1b222b;
  --surface4: #232c37;

  --border: rgba(151, 167, 187, 0.12);
  --border-strong: rgba(151, 167, 187, 0.22);
  --border-active: #36d6e0;

  --text: #e8edf3;
  --text-2: #9aa7b6;
  --text-3: #5e6b7b;

  --accent: #36d6e0;
  --accent-h: #5ee7ef;
  --accent-2: #2bb6c4;
  --accent-glow: rgba(54, 214, 224, 0.15);
  --accent-soft: rgba(54, 214, 224, 0.12);

  --green: #46d99a;
  --green-bg: rgba(70, 217, 154, 0.12);
  --green-bd: rgba(70, 217, 154, 0.3);
  --amber: #f3c969;
  --amber-bg: rgba(243, 201, 105, 0.12);
  --amber-bd: rgba(243, 201, 105, 0.3);
  --red: #f0726f;
  --red-bg: rgba(240, 114, 111, 0.12);
  --red-bd: rgba(240, 114, 111, 0.3);

  --purple: #b18cff;
  --purple-bg: rgba(177, 140, 255, 0.12);
  --purple-bd: rgba(177, 140, 255, 0.3);

  --shadow-soft: 0 14px 38px rgba(2, 5, 10, 0.42);
  --shadow-strong: 0 26px 60px rgba(2, 5, 10, 0.55);
  --r: 10px;
  --r-lg: 14px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
  background-clip: padding-box;
}

html {
  color-scheme: dark;
}
body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
input,
button,
select,
textarea {
  font-family: inherit;
}
a {
  color: var(--accent-h);
  text-decoration: none;
}
::selection {
  background: var(--accent-glow);
  color: var(--text);
}

/* ── App layout ───────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
}
.app.app-compact {
  display: block;
}
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}
.nav-backdrop {
  display: none;
}
.app.app-compact .nav {
  position: fixed;
  left: 0;
  top: 0;
  width: min(320px, 86vw);
  max-width: 100%;
  transform: translateX(-100%);
  transition: transform 220ms var(--ease-out);
  box-shadow: var(--shadow-strong);
}
.app.app-compact .nav.mobile-open {
  transform: translateX(0);
}
.app.app-compact .nav-backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(6, 10, 14, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease-out);
  z-index: 35;
  display: block;
}
.app.app-compact .nav-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 64px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.nav-logo {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-weight: 800;
  font-size: 15px;
  background: linear-gradient(155deg, #5ee7ef 0%, #36d6e0 45%, #1f9aa6 100%);
  color: #04181b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 14px rgba(54, 214, 224, 0.28);
}
.nav-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.nav-name small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}
.nav-group + .nav-group {
  margin-top: 6px;
}
/* Collapsible category header (button) */
.nav-group-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  cursor: pointer;
  border-radius: 9px;
  transition: background 150ms var(--ease-out), color 150ms var(--ease-out);
}
.nav-group-head:hover {
  background: var(--surface2);
  color: var(--text-2);
}
.nav-group-head > svg {
  width: 15px;
  height: 15px;
  opacity: 0.8;
  flex-shrink: 0;
}
.nav-caret {
  width: 15px !important;
  height: 15px !important;
  opacity: 0.7;
  transition: transform 240ms var(--ease-out);
}
.nav-caret.open {
  transform: rotate(90deg);
}
/* Modern height animation via grid-template-rows 0fr → 1fr */
.nav-group-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 260ms var(--ease-out);
}
.nav-group-panel.open {
  grid-template-rows: 1fr;
}
.nav-group-inner {
  overflow: hidden;
  min-height: 0;
  padding: 2px 0;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
}
.nav-group-panel.open .nav-group-inner {
  opacity: 1;
  transform: translateY(0);
}
.stat-icon svg {
  width: 19px;
  height: 19px;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 9px 12px 9px 22px;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background 160ms var(--ease-out), color 160ms var(--ease-out);
}
.nav-item-top {
  padding-left: 12px;
}
.nav-item + .nav-item {
  margin-top: 2px;
}
.nav-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.85;
  flex-shrink: 0;
}
.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-h);
}
.nav-item.active svg {
  opacity: 1;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.nav-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nav-version {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.02em;
  padding-left: 4px;
  font-variant-numeric: tabular-nums;
}

/* connection chip */
.status-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 9px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.status-chip .label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-bg), 0 0 8px var(--green);
  flex-shrink: 0;
}
.dot.off {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-bg), 0 0 8px var(--red);
}
.dot.idle {
  background: var(--text-3);
  box-shadow: 0 0 0 3px rgba(94, 107, 123, 0.15);
}

/* ── Topbar / header ──────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 36px;
  min-height: 60px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-menu {
  display: none;
}
.app.app-compact .topbar-menu {
  display: inline-flex;
  flex-shrink: 0;
}
.topbar .crumbs {
  font-size: 12.5px;
  color: var(--text-3);
  letter-spacing: 0.02em;
  min-width: 0;
}
.topbar .crumbs b {
  color: var(--text-2);
  font-weight: 600;
}
.topbar-spacer {
  flex: 1;
}

.content {
  padding: 26px 36px 40px;
  width: 100%;
}
.app.app-compact .topbar {
  padding: 0 20px;
  gap: 12px;
}
.app.app-compact .content {
  padding: 22px 20px 32px;
}
.app.app-compact .cmdk {
  width: min(300px, 46vw);
  max-width: none;
}

.page-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.page-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
}
.page-head-icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  flex-shrink: 0;
  color: #05161b;
  background: linear-gradient(140deg, var(--accent-h) 0%, var(--accent) 42%, var(--purple) 100%);
  box-shadow:
    0 14px 30px -12px var(--accent-glow),
    0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.page-head-icon svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
}
.page-head h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  background: linear-gradient(180deg, var(--text) 30%, var(--text-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Cards / panels ───────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel-head .sub {
  font-size: 13px;
  color: var(--text-3);
}
.panel-body {
  padding: 18px;
}

.task-stack {
  display: grid;
  gap: 14px;
}
.task-panel {
  overflow: hidden;
}
.task-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.task-toggle:hover {
  background: rgba(255, 255, 255, 0.02);
}
.task-meta {
  min-width: 0;
}
.task-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.task-title-row h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.task-summary {
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.45;
}
.task-body {
  border-top: 1px solid var(--border);
}
.task-toolbar {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ── Section labels (dashboard groupings) ─────────────────────────────────── */
.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.section-label svg {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}

/* ── Dashboard split (Emby | Navidrome) ───────────────────────────────────── */
.dash-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 26px;
}
@media (max-width: 1080px) {
  .dash-split {
    grid-template-columns: 1fr;
  }
}
.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.mini-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--surface2);
  border: 1px solid var(--border);
}
.mini-stat .stat-icon {
  width: 34px;
  height: 34px;
}
.mini-stat .stat-value {
  font-size: 19px;
}
.mini-stat .stat-label {
  font-size: 12px;
}

/* genre breakdown bars */
.genre-row {
  display: grid;
  grid-template-columns: 110px 1fr 52px;
  align-items: center;
  gap: 12px;
  padding: 5px 0;
}
.genre-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.genre-bar {
  height: 7px;
  border-radius: 99px;
  background: var(--surface3);
  overflow: hidden;
}
.genre-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}
.genre-count {
  font-size: 12px;
  color: var(--text-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* format distribution (stacked bar + legend) */
.stack-bar {
  display: flex;
  height: 14px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--surface3);
}
.stack-seg {
  height: 100%;
  transition: width 240ms var(--ease-out);
}
.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  margin-top: 12px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-name {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text);
}
.legend-count {
  margin-left: auto;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* user activity cards */
.activity-shell {
  display: grid;
  gap: 18px;
}
.activity-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.activity-summary-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 108px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)),
    var(--surface2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}
.activity-summary-card strong {
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.activity-summary-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.activity-summary-sub {
  font-size: 12px;
  color: var(--text-2);
}
.activity-summary-platform {
  position: relative;
  padding-left: 54px;
}
.activity-summary-icon {
  position: absolute;
  left: 16px;
  top: 16px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface3);
  color: var(--text-2);
}
.activity-summary-icon.apple {
  background: rgba(54, 214, 224, 0.12);
  color: var(--accent-h);
}
.activity-summary-icon.android {
  background: rgba(70, 217, 154, 0.12);
  color: #8ef0be;
}
.activity-summary-icon.web {
  background: rgba(243, 201, 105, 0.12);
  color: #f6d98c;
}
.activity-summary-icon svg {
  width: 15px;
  height: 15px;
}
.activity-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.activity-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at top right, rgba(54, 214, 224, 0.09), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)),
    var(--surface2);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.16);
  transition: transform 180ms var(--ease-out), border-color 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
}
.activity-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.22);
}
.activity-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.activity-user-meta {
  min-width: 0;
}
.activity-user-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.015em;
}
.activity-user-when {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-3);
}
.activity-device-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.activity-device-chip.apple {
  border-color: rgba(54, 214, 224, 0.24);
  background: rgba(54, 214, 224, 0.12);
  color: var(--accent-h);
}
.activity-device-chip.android {
  border-color: rgba(70, 217, 154, 0.24);
  background: rgba(70, 217, 154, 0.12);
  color: #8ef0be;
}
.activity-device-chip.web {
  border-color: rgba(243, 201, 105, 0.24);
  background: rgba(243, 201, 105, 0.12);
  color: #f6d98c;
}
.activity-device-chip svg {
  width: 14px;
  height: 14px;
}
.activity-device-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}
.activity-card-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.activity-meta-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}
.activity-meta-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.activity-meta-value {
  font-size: 13px;
  color: var(--text-2);
  word-break: break-word;
}
@media (max-width: 640px) {
  .activity-card {
    padding: 16px;
  }
  .activity-card-head {
    flex-direction: column;
    align-items: stretch;
  }
  .activity-device-chip {
    align-self: flex-start;
  }
  .activity-card-meta {
    grid-template-columns: 1fr;
  }
}

/* ── Completeness rows ────────────────────────────────────────────────────── */
.completeness-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 140ms var(--ease-out);
}
.completeness-row:hover {
  background: rgba(54, 214, 224, 0.04);
}
.completeness-pct {
  width: 52px;
  text-align: right;
  color: var(--text-2);
  font-weight: 600;
}

/* ── Tool quick-links ─────────────────────────────────────────────────────── */
.tool-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-width: 0;
}
.tool-card:hover {
  border-color: var(--border-strong);
}

/* ── Stat cards ───────────────────────────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-h);
  flex-shrink: 0;
}
.stat-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-value {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 13.5px;
  color: var(--text-2);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 120ms var(--ease-out),
    opacity 160ms var(--ease-out);
}
.btn svg {
  width: 16px;
  height: 16px;
}
.btn:hover:not(:disabled) {
  background: var(--surface3);
  border-color: var(--border-strong);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: rgba(54, 214, 224, 0.4);
  color: #04181b;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-h);
  border-color: rgba(94, 231, 239, 0.5);
}
.btn-green {
  background: var(--green-bg);
  border-color: var(--green-bd);
  color: #b7f0d4;
}
.btn-green:hover:not(:disabled) {
  background: rgba(70, 217, 154, 0.22);
}
.btn-danger {
  background: var(--red-bg);
  border-color: var(--red-bd);
  color: #ffb4b2;
}
.btn-danger:hover:not(:disabled) {
  background: rgba(240, 114, 111, 0.22);
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}
.btn-block {
  width: 100%;
}

/* ── Inputs ───────────────────────────────────────────────────────────────── */
.input,
.select,
.textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  display: flex;
  justify-content: space-between;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
input[type="color"] {
  width: 42px;
  height: 38px;
  padding: 2px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
}

/* ── Segmented control ────────────────────────────────────────────────────── */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms var(--ease-out), color 150ms var(--ease-out);
}
.seg-btn:hover {
  color: var(--text);
}
.seg-btn.active {
  background: var(--surface4);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* ── Chips / toggles ──────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms var(--ease-out);
}
.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.chip.active {
  background: var(--accent-soft);
  border-color: var(--border-active);
  color: var(--text);
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  background: var(--surface3);
  color: var(--text-2);
  white-space: nowrap;
}
.badge-ok {
  background: var(--green-bg);
  border-color: var(--green-bd);
  color: #b7f0d4;
}
.badge-warn {
  background: var(--amber-bg);
  border-color: var(--amber-bd);
  color: #f6d98c;
}
.badge-bad {
  background: var(--red-bg);
  border-color: var(--red-bd);
  color: #ffb4b2;
}
.badge-accent {
  background: var(--accent-soft);
  border-color: rgba(54, 214, 224, 0.3);
  color: var(--accent-h);
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: background 140ms var(--ease-out);
}
.data-table tbody tr:hover {
  background: rgba(54, 214, 224, 0.04);
}
.data-table tbody tr:last-child td {
  border-bottom: 0;
}
.cell-strong {
  color: var(--text);
  font-weight: 600;
}
.cell-sub {
  color: var(--text-3);
  font-size: 12px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #06121a;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ── Grids ────────────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}
.media-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.media-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.media-card.selected {
  border-color: var(--border-active);
  box-shadow: 0 0 0 1px var(--accent-glow);
}
.media-cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--surface3);
}
.media-cover.poster {
  aspect-ratio: 2 / 3;
}
.media-body {
  padding: 11px 12px;
}
.media-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Result list (sidebar search) ─────────────────────────────────────────── */
.result-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 140ms var(--ease-out);
}
.result-item:hover {
  background: var(--surface2);
}
.result-item.active {
  background: var(--accent-soft);
  border-color: var(--border-active);
}
.result-poster {
  width: 38px;
  height: 57px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface3);
  flex-shrink: 0;
}
.result-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.result-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── Empty / loading ──────────────────────────────────────────────────────── */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-3);
  line-height: 1.6;
}
.empty svg {
  width: 38px;
  height: 38px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner.lg {
  width: 30px;
  height: 30px;
  border-width: 3px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.center-load {
  display: grid;
  place-items: center;
  padding: 60px;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}
.toast {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
  background: var(--surface3);
  color: var(--text);
  animation: toast-in 240ms var(--ease-out);
}
.toast.ok {
  background: var(--green-bg);
  border-color: var(--green-bd);
  color: #b7f0d4;
}
.toast.err {
  background: var(--red-bg);
  border-color: var(--red-bd);
  color: #ffb4b2;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row.wrap {
  flex-wrap: wrap;
}
.between {
  justify-content: space-between;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.muted {
  color: var(--text-2);
}
.dim {
  color: var(--text-3);
}
.grow {
  flex: 1;
}
.mono {
  font-variant-numeric: tabular-nums;
}
.gap-sm {
  gap: 8px;
}
.mt {
  margin-top: 16px;
}
.hint {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}

/* ── Search bar ───────────────────────────────────────────────────────────── */
.search-inner {
  position: relative;
}
.search-inner svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-3);
}
.search-inner .input {
  padding-left: 36px;
}

/* ── Command palette (topbar) ─────────────────────────────────────────────── */
.cmdk {
  position: relative;
  width: 340px;
  max-width: 42vw;
  flex-shrink: 0;
}
.cmdk-field {
  position: relative;
  display: flex;
  align-items: center;
}
.cmdk-field > svg {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}
.cmdk-input {
  width: 100%;
  padding: 8px 44px 8px 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.cmdk-input::placeholder {
  color: var(--text-3);
}
.cmdk-input:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}
.cmdk-kbd {
  position: absolute;
  right: 9px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  pointer-events: none;
}
.cmdk-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(420px, 80vw);
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  z-index: 60;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.cmdk-item.active {
  background: var(--accent-soft);
  color: var(--accent-h);
}
.cmdk-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.cmdk-icon svg {
  width: 16px;
  height: 16px;
  opacity: 0.9;
}
.cmdk-label {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmdk-section {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.cmdk-empty {
  padding: 16px 12px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* ── Two-column workbench (generator) ─────────────────────────────────────── */
.workbench {
  display: grid;
  grid-template-columns: 320px 1fr 300px;
  gap: 18px;
  align-items: start;
}
@media (max-width: 1100px) {
  .workbench {
    grid-template-columns: 1fr;
  }
}
.scroll-col {
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

/* preview frame */
.preview-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.preview-frame {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 220px;
}
.preview-frame img {
  width: 100%;
  display: block;
}

/* log console */
.console {
  background: #06090d;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  max-height: 360px;
  overflow-y: auto;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.settings-update-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

@media (max-width: 1180px) {
  .topbar {
    padding: 0 20px;
    gap: 12px;
  }
  .content {
    padding: 22px 20px 32px;
  }
  .cmdk {
    width: min(300px, 46vw);
    max-width: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 16px;
    min-height: auto;
  }
  .topbar .crumbs {
    order: 1;
    flex: 1 1 0;
    font-size: 12px;
    line-height: 1.5;
  }
  .topbar-spacer {
    display: none;
  }
  .cmdk {
    order: 3;
    width: 100%;
    max-width: none;
  }
  .cmdk-kbd {
    display: none;
  }
  .content {
    padding: 18px 16px 28px;
  }
  .page-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .page-toolbar-actions {
    justify-content: stretch;
  }
  .page-toolbar-actions > * {
    width: 100%;
  }
  .page-head {
    gap: 12px;
    margin-bottom: 18px;
  }
  .page-head-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }
  .page-head h1 {
    font-size: 24px;
    background: none;
    -webkit-text-fill-color: initial;
    color: var(--text);
  }
  .mini-grid,
  .legend,
  .settings-grid,
  .settings-update-grid,
  .activity-card-grid,
  .activity-summary-grid,
  .stat-row {
    grid-template-columns: 1fr;
  }
  .genre-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .genre-count {
    text-align: left;
  }
  .tool-card {
    padding: 13px 14px;
  }
  .toast-wrap {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

@media (max-width: 520px) {
  .nav-brand {
    min-height: 58px;
    padding: 0 14px;
  }
  .nav-scroll {
    padding: 10px 8px;
  }
  .nav-foot {
    padding: 10px;
  }
  .panel-head,
  .panel-body {
    padding-left: 14px;
    padding-right: 14px;
  }
  .panel-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .panel-head h3 {
    font-size: 16px;
  }
  .btn,
  .chip,
  .status-chip {
    max-width: 100%;
  }
  .row.between {
    flex-wrap: wrap;
  }
  .cmdk-menu {
    width: 100%;
  }
}
.log-line {
  display: flex;
  gap: 10px;
}
.log-tag {
  flex-shrink: 0;
  width: 58px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
  padding-top: 1px;
}
.log-ok {
  color: var(--green);
}
.log-dry {
  color: var(--accent);
}
.log-skip {
  color: var(--text-3);
}
.log-warn {
  color: var(--amber);
}
.log-info {
  color: var(--text-2);
}
