/* Design tokens follow huggingface.co: Tailwind gray scale, Source Sans + IBM Plex Mono,
   brand yellow #FFD21E / orange #FF9D00, rounded-lg cards with a gray-50 -> white wash. */
:root {
  --bg: #ffffff;
  --wash: #f9fafb;          /* gray-50 */
  --wash-2: #f3f4f6;        /* gray-100 */
  --border: #e5e7eb;        /* gray-200 */
  --border-soft: #f3f4f6;   /* gray-100 */
  --text: #111827;          /* gray-900 */
  --text-2: #374151;        /* gray-700 */
  --muted: #6b7280;         /* gray-500 (brand gray) */
  --faint: #9ca3af;         /* gray-400 */
  --hover-title: #dc2626;   /* red-600, as on hub repo cards */
  --yellow: #ffd21e;
  --orange: #ff9d00;
  --btn-dark-bg: #111827;
  --btn-dark-fg: #ffffff;
  --wave: #d1d5db;
  --wave-played: #ff9d00;
  --danger: #dc2626;
  --sel-bg: #f3f4f6;
  --sel-border: #d1d5db;
  --font: "Source Sans 3", "Source Sans Pro", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  /* HF modality tag colors */
  --m-audio: #c026d3; --m-image: #059669; --m-video: #3730a3; --m-text: #dc2626; --m-document: #f43f5e;
  --m-tabular: #9ca3af; --m-time-series: #f97316; --m-3d: #2563eb; --m-geospatial: #f59e0b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f19; --wash: #111827; --wash-2: #1f2937; --border: #1f2937; --border-soft: #141c2e;
    --text: #e5e7eb; --text-2: #d1d5db; --muted: #9ca3af; --faint: #6b7280; --hover-title: #eab308;
    --btn-dark-bg: #f3f4f6; --btn-dark-fg: #111827; --wave: #374151; --danger: #f87171;
    --sel-bg: #1f2937; --sel-border: #374151; --m-video: #818cf8; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f19; --wash: #111827; --wash-2: #1f2937; --border: #1f2937; --border-soft: #141c2e;
  --text: #e5e7eb; --text-2: #d1d5db; --muted: #9ca3af; --faint: #6b7280; --hover-title: #eab308;
  --btn-dark-bg: #f3f4f6; --btn-dark-fg: #111827; --wave: #374151; --danger: #f87171;
  --sel-bg: #1f2937; --sel-border: #374151; --m-video: #818cf8; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 6px; }
.mono { font-family: var(--mono); }
.muted { color: var(--faint); font-weight: 400; }
code { font-family: var(--mono); font-size: .85em; background: var(--wash-2); padding: 1px 5px; border-radius: 4px; }
h1, h2, h3 { margin: 0; }

/* ------------------------------------------------ header (mirrors the hf.co top bar) */
.top { border-bottom: 1px solid var(--border-soft); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.top-inner { display: flex; align-items: center; gap: 22px; max-width: 1440px; margin: 0 auto; padding: 0 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 700; font-size: 20px; letter-spacing: -.01em; white-space: nowrap; }
.brand img { width: 34px; height: 34px; display: block; }
.top-search { position: relative; flex: 1; max-width: 520px; }
.top-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2; }
.top-search input {
  width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px 0 34px; background: var(--bg); outline: none; font-size: 15px;
}
.top-search input:focus { border-color: var(--sel-border); box-shadow: 0 0 0 3px color-mix(in srgb, var(--yellow) 35%, transparent); }
nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 6px 10px; border-radius: 6px; font-weight: 600; font-size: 15px; color: var(--text-2); }
.nav-link svg { width: 15px; height: 15px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-link:hover { color: var(--text); }
.nav-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: none; color: var(--muted); flex: none; }
.nav-icon svg { width: 16px; height: 16px; fill: currentColor; }
.nav-icon:hover { color: var(--text); }

/* ------------------------------------------------ page layout (mirrors hf.co/datasets) */
.page { display: grid; grid-template-columns: 330px minmax(0, 1fr); max-width: 1440px; margin: 0 auto; min-height: calc(100vh - 64px); }
.side { border-right: 1px solid var(--border-soft); padding: 24px 24px 80px; min-width: 0; }
.results { padding: 28px 32px 120px; min-width: 0; }

.side-group { margin-bottom: 26px; }
.side-group h3 { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
.side-group h3 .muted { font-size: 13px; }

/* HF tag chips */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px; border-radius: 8px;
  border: 1px solid var(--border); background: linear-gradient(to bottom, var(--bg), var(--wash)); font-size: 14px; color: var(--text-2); white-space: nowrap;
}
.tag:hover { border-color: var(--sel-border); color: var(--text); }
.tag .n { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.tag.sel { background: var(--sel-bg); border-color: var(--sel-border); color: var(--text); font-weight: 600; }
.tag.sel::after { content: "×"; color: var(--faint); font-weight: 400; margin-left: 1px; }
.tag[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.tag[aria-disabled="true"]:hover { border-color: var(--border); color: var(--text-2); }
.mod-dot { width: 15px; height: 15px; border-radius: 4px; display: grid; place-items: center; color: #fff; flex: none; }
.mod-dot svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.more-tags { background: none; border: 0; color: var(--muted); font-size: 13.5px; padding: 4px 2px; }
.more-tags:hover { color: var(--text); text-decoration: underline; }

.ds-list { list-style: none; margin: 0; padding: 0; }
.ds-list li { border-radius: 8px; padding: 6px 8px; margin: 0 -8px; cursor: pointer; }
.ds-list li:hover { background: var(--wash); }
.ds-list li.sel { background: var(--sel-bg); }
.ds-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.ds-row .box { width: 15px; height: 15px; border: 1.5px solid var(--sel-border); border-radius: 4px; flex: none; display: grid; place-items: center; }
.ds-list li.sel .box { background: var(--text); border-color: var(--text); }
.ds-list li.sel .box::after { content: ""; width: 7px; height: 4px; border: 2px solid var(--bg); border-top: 0; border-right: 0; transform: rotate(-45deg) translateY(-1px); }
.ds-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 13px; }
.ds-row .n { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.ds-row .info { border: 0; background: none; color: var(--faint); padding: 0 2px; font-size: 13px; }
.ds-row .info:hover { color: var(--text); }
.ds-share { height: 3px; border-radius: 2px; background: var(--wash-2); margin: 5px 0 0 23px; overflow: hidden; }
.ds-share span { display: block; height: 100%; background: var(--orange); border-radius: 2px; transition: width .3s ease; }
@media (prefers-reduced-motion: reduce) { .ds-share span { transition: none; } }

/* ------------------------------------------------ intro + results header */
.intro h1 { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.intro p { color: var(--muted); max-width: 70ch; margin: 8px 0 18px; font-size: 16.5px; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 26px; }
.examples button { border: 1px dashed var(--sel-border); background: none; border-radius: 999px; padding: 3px 12px; font-size: 14px; color: var(--muted); }
.examples button:hover { color: var(--text); border-style: solid; }

.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results-head h2 { font-size: 19px; font-weight: 600; }
.results-head .count { font-family: var(--mono); font-weight: 400; color: var(--faint); font-size: 15px; margin-left: 6px; }
.status { color: var(--muted); font-size: 14.5px; margin: 6px 0 4px; min-height: 22px; }
.status strong { color: var(--text); font-weight: 600; }
.active { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.active:empty { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border); background: linear-gradient(to bottom, var(--bg), var(--wash)); font-size: 14.5px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--sel-border); color: var(--text); }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-dark { background: var(--btn-dark-bg); color: var(--btn-dark-fg); border-color: var(--btn-dark-bg); }
.btn-dark:hover { color: var(--btn-dark-fg); opacity: .9; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13.5px; }
.btn.in { background: var(--sel-bg); border-color: var(--sel-border); color: var(--text); }

/* ------------------------------------------------ sample cards (hub repo-card style) */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; transition: opacity .15s; }
.cards.stale { opacity: .45; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .cards { transition: none; } }
.card { border: 1px solid var(--border-soft); border-radius: 8px; padding: 12px 14px; background: linear-gradient(to right, var(--wash), var(--bg) 60%); }
.card:hover .repo { color: var(--hover-title); }
.card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-head .mod-icon { width: 15px; height: 15px; border-radius: 4px; background: var(--m-audio); flex: none; display: grid; place-items: center; color: #fff; }
.card-head .mod-icon svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.repo { font-size: 15px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; max-width: 60%; }
.where { font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dur { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.player { display: flex; align-items: center; gap: 10px; margin: 10px 0 8px; }
.play { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); display: grid; place-items: center; flex: none; color: var(--text); }
.play:hover { border-color: var(--sel-border); }
.play svg { width: 14px; height: 14px; fill: currentColor; }
.play .i-pause, .play .spinner { display: none; }
.card.playing .play { background: var(--text); color: var(--bg); border-color: var(--text); }
.card.playing .play .i-play { display: none; }
.card.playing .play .i-pause { display: block; }
.card.loading .play .i-play { display: none; }
.card.loading .play .spinner { display: block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--text); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .card.loading .play .spinner { animation: none; } }
.wave { position: relative; height: 34px; flex: 1; cursor: pointer; }
.wave svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave rect { fill: var(--wave); }
.wave .progress { position: absolute; inset: 0; clip-path: inset(0 100% 0 0); }
.wave .progress rect { fill: var(--wave-played); }

.caption { margin: 0; color: var(--text-2); font-size: 15.5px; max-width: 90ch; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.caption.open { -webkit-line-clamp: unset; }
.transcript { margin: 4px 0 0; font-family: var(--mono); font-size: 13px; color: var(--muted); max-width: 100ch; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.caption:empty, .transcript:empty, .why:empty { display: none; }
.card-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 6px; font-size: 12.5px; color: var(--muted); background: var(--wash-2); white-space: nowrap; }
.chip.label { color: var(--text-2); background: color-mix(in srgb, var(--yellow) 22%, var(--bg)); }
.chip.warn { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--bg)); }
.actions { display: flex; gap: 6px; }
.why { margin: 8px 0 0; font-size: 13px; color: var(--faint); }
.error { margin: 6px 0 0; color: var(--danger); font-size: 13.5px; }
.empty { border: 1px dashed var(--border); border-radius: 8px; padding: 28px; color: var(--muted); list-style: none; }
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.more-wrap { display: flex; justify-content: center; padding: 22px 0; }

/* ------------------------------------------------ mix bar */
.mixbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); }
.mixbar-inner { max-width: 1440px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 12px; }
.mixbar p { margin: 0; flex: 1; font-size: 15px; color: var(--text-2); }
.mixbar p strong { color: var(--text); }
.mix-dist { display: flex; width: 120px; height: 8px; border-radius: 4px; overflow: hidden; gap: 1px; background: var(--wash-2); }
.mix-dist span { background: var(--orange); }
.mix-dist span:nth-child(2n) { background: var(--yellow); }
.mix-list { list-style: none; padding: 0; margin: 0; max-height: 50vh; overflow: auto; }
.mix-list li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 14px; }
.mix-list .mono { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.mix-list .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mix-list button { border: 0; background: none; color: var(--faint); }
.mix-list button:hover { color: var(--danger); }

/* ------------------------------------------------ modals */
dialog.modal { border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 20px 24px 24px; box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .35); }
dialog.modal.wide { width: min(920px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(11, 15, 25, .5); }
dialog header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
dialog h2 { font-size: 21px; font-weight: 700; }
dialog h2.mono { font-size: 18px; font-weight: 500; }
dialog h3 { font-size: 15px; font-weight: 600; margin: 18px 0 6px; }
.modal-lede { color: var(--muted); margin: 0 0 16px; max-width: 75ch; }
.note { color: var(--muted); font-size: 14px; }
.preview-note { display: block; margin-top: 6px; font-size: 14px; color: var(--text-2); }
.tool-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.tool-list li { border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; background: linear-gradient(to right, var(--wash), var(--bg)); }
.tool-list code { background: none; padding: 0; font-size: 13.5px; color: var(--text); }
.tool-list p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.code { background: var(--wash); border: 1px solid var(--border); border-radius: 8px; padding: 14px; overflow: auto; font: 12.5px/1.6 var(--mono); max-height: 46vh; white-space: pre; margin: 0; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; border-bottom: 1px solid var(--border-soft); }
.tabs button { border: 0; background: none; padding: 6px 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }


.profile-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.profile-head p { margin: 2px 0; color: var(--muted); max-width: 62ch; }
.profile-head .links { display: flex; gap: 6px; align-items: flex-start; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-bottom: 18px; }
.stat { border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; background: linear-gradient(to bottom, var(--wash), var(--bg)); }
.stat b { display: block; font-size: 20px; font-weight: 700; font-family: var(--mono); }
.stat span { font-size: 13px; color: var(--muted); }
.dists { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px 28px; }
.dist h4 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) 90px 32px; gap: 8px; align-items: center; font-size: 13px; padding: 2px 0; }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar .track-bg { display: block; height: 6px; background: var(--wash-2); border-radius: 3px; overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--orange); border-radius: 3px; }
.bar .v { font-family: var(--mono); font-size: 12px; color: var(--faint); text-align: right; }

/* ------------------------------------------------ responsive */
@media (max-width: 960px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--border-soft); padding: 18px 16px 6px; }
  .results { padding: 20px 16px 120px; }
  .top-inner { padding: 0 16px; gap: 12px; }
}
@media (max-width: 640px) {
  .top-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; }
  .top-search { order: 3; flex-basis: 100%; max-width: none; }
  .nav-link svg { display: none; }
  .intro h1 { font-size: 24px; }
  .where { display: none; }
  .repo { max-width: 75%; }
  .mixbar-inner { padding: 10px 16px; flex-wrap: wrap; }
  .mix-dist { display: none; }
}
