:root {
  --bg: #101210;
  --bg-elevated: #171a18;
  --panel: rgba(23, 26, 24, 0.96);
  --panel-strong: rgba(16, 18, 17, 0.98);
  --panel-soft: rgba(242, 240, 232, 0.045);
  --border: rgba(218, 221, 211, 0.16);
  --border-strong: rgba(226, 230, 222, 0.32);
  --text: #f2f0e8;
  --muted: #a9aea6;
  --accent: #93b7ff;
  --accent-strong: #e0b768;
  --warning: #e0b768;
  --danger: #df7772;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  --radius-xl: 10px;
  --radius-lg: 8px;
  --radius-md: 6px;
  --radius-sm: 4px;
  --sidebar-width: 330px;
  --content-max: 1860px;
  --font-stack: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #121411 0%, #0f1110 58%, #0b0d0c 100%);
  color: var(--text);
  font-family: var(--font-stack);
}

body {
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

a.secondary-button:hover,
a.footer-link:hover {
  text-decoration: none;
}

button,
input {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1rem 1.25rem;
  background: rgba(17, 19, 18, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-main,
.topbar-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-tools {
  margin-left: auto;
  align-self: center;
}

.source-label-short {
  display: none;
}

.nav-toggle,
.icon-button,
.secondary-button,
.tree-toggle,
.tree-label,
.detail-link,
.folder-card,
.item-card {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
}

.icon-button,
.secondary-button {
  border: 1px solid var(--border);
  background: rgba(242, 240, 232, 0.055);
  border-radius: var(--radius-lg);
  height: 42px;
  padding: 0 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.icon-button:hover,
.secondary-button:hover,
.tree-toggle:hover,
.tree-label:hover,
.folder-card:hover,
.item-card:hover {
  border-color: var(--border-strong);
  background: rgba(242, 240, 232, 0.08);
}

.icon-button svg,
.secondary-button svg,
.detail-link svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-mark {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  background: rgba(242, 240, 232, 0.055);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(242, 240, 232, 0.08);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
  stroke: var(--accent);
  stroke-width: 1.6;
  fill: none;
}

.brand-copy h1,
.hero-copy h2,
.detail-copy h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand-copy h1 {
  font-size: 1.45rem;
}

.brand-subtitle,
.sidebar-caption,
.folder-description,
.detail-copy p,
.statusbar-note {
  color: var(--muted);
}

.brand-subtitle,
.sidebar-caption {
  margin: 0.25rem 0 0;
  max-width: 54ch;
}

.eyebrow {
  margin: 0 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.72rem;
  color: var(--accent-strong);
}

.search-box {
  min-width: min(40vw, 420px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.95rem;
  height: 46px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(242, 240, 232, 0.055);
}

.search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
}

.search-box input::placeholder {
  color: var(--muted);
}

.search-icon svg {
  width: 18px;
  height: 18px;
  stroke: var(--muted);
  stroke-width: 1.8;
  fill: none;
}

.workspace {
  flex: 1;
  width: min(100%, calc(var(--content-max) + 2rem));
  margin: 0 auto;
  padding: 1.1rem 1rem 1rem;
  display: grid;
  grid-template-columns: minmax(280px, var(--sidebar-width)) minmax(0, 1fr);
  gap: 1rem;
  position: relative;
}

@media (min-width: 981px) {
  .app-shell.nav-collapsed .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-shell.nav-collapsed .sidebar {
    display: none;
  }
}

.sidebar,
.window-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sidebar-header,
.sidebar-footer,
.panel-toolbar,
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sidebar-header {
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.tree-nav {
  margin-top: 0.8rem;
  min-height: 0;
  overflow: auto;
  padding-right: 0.2rem;
}

.tree-section {
  margin-bottom: 0.4rem;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-md);
}

.tree-row.is-selected {
  background: rgba(147, 183, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(147, 183, 255, 0.22);
}

.tree-row.is-leaf .tree-toggle {
  visibility: hidden;
}

.tree-toggle {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.tree-toggle svg,
.tree-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
}

.tree-toggle svg {
  transition: transform 140ms ease;
}

.tree-row.is-expanded .tree-toggle svg {
  transform: rotate(90deg);
}

.tree-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  color: var(--accent);
}

.tree-label {
  flex: 1;
  min-width: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.tree-label-title,
.item-title,
.folder-title {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-label-meta,
.item-meta,
.folder-meta,
.meta-hint {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.item-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-children {
  margin-left: 1.2rem;
  border-left: 1px dashed rgba(218, 221, 211, 0.16);
  padding-left: 0.65rem;
}

.sidebar-scrim {
  display: none;
}

.content {
  display: grid;
  gap: 1rem;
  min-width: 0;
  align-content: start;
}

.hero-panel,
.collection-panel,
.detail-panel {
  overflow: hidden;
}

.hero-panel {
  padding: 0.9rem 1.1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.hero-copy p {
  margin: 0.28rem 0 0;
  max-width: 90ch;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.hero-metrics,
.sidebar-stat-list {
  display: grid;
  gap: 0.65rem;
}

.hero-metrics {
  grid-template-columns: repeat(auto-fit, minmax(110px, max-content));
  justify-content: start;
  gap: 0.5rem;
}

.metric-card {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  border: 1px solid rgba(218, 221, 211, 0.13);
}

.hero-panel.is-compact .metric-label,
.hero-panel.is-compact .metric-value {
  display: inline;
}

.hero-panel.is-compact .metric-value {
  margin-top: 0;
  margin-left: 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.metric-label {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metric-value {
  margin-top: 0.25rem;
  font-size: 1.45rem;
  font-weight: 700;
}

.browser-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.72fr) minmax(460px, 1.35fr);
  gap: 1rem;
  min-height: 0;
}

.collection-panel,
.detail-panel {
  display: flex;
  flex-direction: column;
  min-height: min(74vh, 920px);
}

.panel-toolbar {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-body {
  padding: 1rem;
  min-height: 0;
  overflow: auto;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.breadcrumb-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-md);
  background: rgba(242, 240, 232, 0.045);
  border: 1px solid rgba(218, 221, 211, 0.12);
}

.folder-summary {
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(218, 221, 211, 0.13);
  background: rgba(242, 240, 232, 0.035);
}

.folder-summary h3,
.folder-summary p {
  margin: 0;
}

.folder-summary p {
  margin-top: 0.4rem;
  color: var(--muted);
  max-width: 74ch;
}

.folder-summary.is-search-mode {
  margin-bottom: 0.8rem;
  padding: 0 0 0.8rem;
  border: 0;
  border-bottom: 1px solid rgba(218, 221, 211, 0.16);
  border-radius: 0;
  background: transparent;
}

.folder-summary.is-search-mode p {
  margin-top: 0.22rem;
  max-width: none;
}

.item-grid {
  display: grid;
  gap: 0.95rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-content: start;
}

.item-card,
.folder-card {
  padding: 0.8rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(218, 221, 211, 0.13);
  background: rgba(242, 240, 232, 0.035);
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.item-card:hover,
.folder-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25);
  border-color: rgba(147, 183, 255, 0.42);
}

.item-card.is-selected,
.folder-card.is-selected {
  border-color: rgba(147, 183, 255, 0.58);
  box-shadow: inset 0 0 0 1px rgba(147, 183, 255, 0.34);
}

.folder-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 146px;
}

.folder-card-head,
.item-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.item-card-head > div {
  min-width: 0;
}

.folder-icon,
.item-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  background: rgba(147, 183, 255, 0.105);
  border: 1px solid rgba(218, 221, 211, 0.16);
  color: var(--accent);
}

.folder-icon svg,
.item-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
}

.folder-title,
.item-title {
  font-size: 0.98rem;
}

.thumb-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(218, 221, 211, 0.13);
  background: rgba(8, 10, 9, 0.88);
}

.thumb-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-frame .item-icon {
  position: absolute;
  inset: auto auto 0.7rem 0.7rem;
}

.badge-row,
.detail-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.type-badge,
.status-badge,
.tiny-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  font-size: 0.78rem;
  line-height: 1;
  border: 1px solid rgba(218, 221, 211, 0.14);
  background: rgba(242, 240, 232, 0.05);
}

.status-ready {
  color: var(--accent-strong);
}

.status-pending {
  color: var(--warning);
}

.status-audio {
  color: var(--accent);
}

.detail-body {
  display: block;
}

.empty-state,
.pending-card,
.audio-card {
  display: grid;
  place-items: center;
  gap: 0.7rem;
  padding: 2rem 1.25rem;
  min-height: 320px;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(218, 221, 211, 0.18);
  background: rgba(242, 240, 232, 0.03);
  text-align: center;
}

.empty-icon svg {
  width: 42px;
  height: 42px;
  stroke: var(--accent);
  stroke-width: 1.8;
  fill: none;
}

.detail-card {
  display: grid;
  gap: 1rem;
}

.detail-overview {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 1rem;
}

.detail-thumb-wrap {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(218, 221, 211, 0.13);
  background: rgba(242, 240, 232, 0.04);
}

.detail-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-copy p {
  margin: 0.6rem 0 0;
}

.meta-grid {
  margin: 1rem 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

.meta-grid dt {
  margin: 0 0 0.18rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.meta-grid dd {
  margin: 0;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 38px;
  padding: 0 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(242, 240, 232, 0.055);
  cursor: pointer;
}

.viewer-shell {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(218, 221, 211, 0.13);
  overflow: hidden;
  background: rgba(6, 8, 7, 0.96);
  min-height: clamp(480px, 58vh, 820px);
}

.viewer-shell iframe {
  width: 100%;
  min-height: clamp(480px, 58vh, 820px);
  border: 0;
  background: #070807;
}

.audio-card audio {
  width: min(100%, 420px);
}

.statusbar {
  padding: 0.8rem 1rem 1rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: rgba(17, 19, 18, 0.72);
}

.run-status {
  color: var(--text);
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(218, 221, 211, 0.13);
  background: rgba(242, 240, 232, 0.045);
  color: var(--text);
  font-size: 0.9rem;
}

.footer-link:hover {
  border-color: var(--border-strong);
  background: rgba(242, 240, 232, 0.08);
}

.sidebar-stat-list {
  width: 100%;
}

.sidebar-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.92rem;
}

.sidebar-stat strong {
  font-size: 1rem;
}

@media (max-width: 1180px) {
  .hero-panel,
  .browser-layout,
  .detail-overview {
    grid-template-columns: 1fr;
  }

  .hero-metrics {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 84px auto 16px 16px;
    width: min(calc(100vw - 32px), 360px);
    transform: translateX(calc(-100% - 24px));
    transition: transform 180ms ease;
    z-index: 60;
  }

  .app-shell.nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    border: 0;
    background: rgba(2, 5, 13, 0.62);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 50;
  }

  .app-shell.nav-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    padding: 0.8rem;
  }

  .topbar-main,
  .topbar-tools {
    width: 100%;
  }

  .topbar-main {
    gap: 0.7rem;
  }

  .topbar-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.65rem;
  }

  .source-label-full {
    display: none;
  }

  .source-label-short {
    display: inline;
  }

  .brand-lockup {
    min-width: 0;
    gap: 0.7rem;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .brand-mark svg {
    width: 25px;
    height: 25px;
  }

  .brand-copy {
    min-width: 0;
  }

  .brand-copy h1 {
    font-size: 1.15rem;
  }

  .brand-subtitle {
    display: none;
  }

  .icon-button,
  .secondary-button {
    height: 40px;
  }

  .search-box {
    min-width: 0;
    width: auto;
    height: 42px;
    padding-inline: 0.75rem;
  }

  .search-box input {
    min-width: 0;
    font-size: 0.92rem;
  }

  .secondary-button {
    padding-inline: 0.75rem;
  }

  .topbar-source-link {
    padding-inline: 0.65rem;
  }

  .workspace {
    padding: 0.75rem;
  }

  .panel-toolbar,
  .panel-body {
    padding-inline: 0.85rem;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .item-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .folder-summary {
    padding: 0.75rem;
  }

  .folder-card {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    grid-template-areas: "folder-icon folder-body folder-badge";
    align-items: center;
    min-height: 0;
    gap: 0.55rem;
    padding: 0.7rem;
  }

  .folder-card-head {
    display: contents;
  }

  .folder-card .folder-icon {
    grid-area: folder-icon;
    width: 42px;
    height: 42px;
  }

  .folder-card .badge-row {
    grid-area: folder-badge;
    align-self: start;
  }

  .folder-card > div:not(.folder-card-head) {
    grid-area: folder-body;
    min-width: 0;
  }

  .item-card {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    grid-template-areas:
      "thumb title"
      "thumb badges";
    gap: 0.65rem;
    align-items: start;
    padding: 0.65rem;
  }

  .item-card .thumb-frame {
    grid-area: thumb;
    width: 86px;
    aspect-ratio: 4 / 3;
  }

  .item-card .thumb-frame .item-icon {
    inset: auto auto 0.35rem 0.35rem;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-md);
  }

  .item-card .thumb-frame .item-icon svg {
    width: 17px;
    height: 17px;
  }

  .item-card .item-card-head {
    grid-area: title;
  }

  .item-card > .badge-row {
    grid-area: badges;
    align-self: end;
  }

  .folder-title,
  .item-title {
    font-size: 0.92rem;
  }

  .folder-meta,
  .item-meta {
    display: -webkit-box;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .type-badge,
  .status-badge,
  .tiny-badge {
    padding: 0.24rem 0.5rem;
    font-size: 0.73rem;
  }

  .viewer-shell,
  .viewer-shell iframe {
    min-height: 360px;
  }

  .statusbar {
    align-items: stretch;
    flex-direction: column;
    gap: 0.7rem;
  }

  .footer-links {
    justify-content: flex-start;
  }
}
