/* ==========================================================================
   Animations Library
   One accent (signal lime), neutral zinc surfaces, 14px card radius,
   pill radius for interactive chips/buttons.
   ========================================================================== */

:root {
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius-card: 14px;
  --radius-media: 10px;
  --radius-pill: 999px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --gutter: clamp(16px, 3vw, 40px);
  --maxw: 1680px;
  --card-min: 340px;
  --topbar-h: 60px;

  /* z-index scale */
  --z-filters: 20;
  --z-topbar: 30;
  --z-toast: 60;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0d;
  --bg-raise: #111114;
  --surface: #151518;
  --surface-2: #1c1c20;
  --surface-3: #25252a;
  --line: rgb(255 255 255 / 0.07);
  --line-strong: rgb(255 255 255 / 0.13);
  --text: #f1f1f3;
  --text-2: #a4a4ad;
  --text-3: #71717a;
  --accent: #c8f23c;
  --accent-hover: #d6fb5c;
  --accent-ink: #151a02;
  --accent-text: #c8f23c;
  --accent-soft: rgb(200 242 60 / 0.12);
  --media-bg: #09090b;
  --shadow-card: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 12px 32px -18px rgb(0 0 0 / 0.8);
  --shadow-pop: 0 30px 80px -20px rgb(0 0 0 / 0.75);
  --scrim: rgb(5 5 7 / 0.72);
  --code-bg: #0e0e11;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f5;
  --bg-raise: #fafafa;
  --surface: #ffffff;
  --surface-2: #f0f0f2;
  --surface-3: #e4e4e7;
  --line: rgb(24 24 27 / 0.08);
  --line-strong: rgb(24 24 27 / 0.15);
  --text: #16161a;
  --text-2: #52525b;
  --text-3: #71717a;
  --accent: #c8f23c;
  --accent-hover: #bde52c;
  --accent-ink: #151a02;
  --accent-text: #4a6200;
  --accent-soft: rgb(118 150 0 / 0.12);
  --media-bg: #e9e9ec;
  --shadow-card: 0 1px 2px rgb(24 24 27 / 0.04), 0 12px 30px -20px rgb(24 24 27 / 0.25);
  --shadow-pop: 0 30px 80px -24px rgb(24 24 27 / 0.35);
  --scrim: rgb(228 228 231 / 0.7);
  --code-bg: #fafafa;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 72px);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; }

img, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
code, kbd, pre { font-family: var(--font-mono); }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip {
  position: fixed;
  left: 16px; top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-pill);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s var(--ease-out);
}
.skip:focus { top: 12px; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
}

/* --------------------------------------------------------------- buttons */

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-2);
  font-size: 18px;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s var(--ease-out);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--line-strong); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn[aria-pressed="true"] { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: var(--accent-soft); }
.icon-btn:disabled { opacity: 0.35; pointer-events: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s var(--ease-out);
}
.btn i { font-size: 17px; }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn-ghost[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

/* --------------------------------------------------------------- nav */

.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: var(--maxw);
  height: var(--topbar-h);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.04em;
  transition: transform 0.5s var(--ease-out);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }
.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.brand-sub {
  position: relative;
  padding-left: 11px;
  font-size: 14px;
  color: var(--text-3);
}
.brand-sub::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 14px;
  background: var(--line-strong);
  transform: translateY(-50%) rotate(18deg);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 260px;
  height: 36px;
  padding: 0 8px 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--surface);
  transition: width 0.45s var(--ease-out), border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.search:hover { border-color: var(--line); }
.search:focus-within {
  width: 360px;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.search > i { font-size: 16px; color: var(--text-3); }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13.5px;
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { transition: opacity 0.2s; }
.search:focus-within kbd { opacity: 0; }

.icon-btn.ghost { border-color: transparent; background: transparent; }
.icon-btn.ghost:hover,
.icon-btn.ghost[aria-expanded="true"] { background: var(--surface); border-color: var(--line); color: var(--text); }

/* settings popover */

.menu { position: relative; }
.popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 280px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  transform-origin: top right;
  animation: pop-in 0.28s var(--ease-out);
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.pop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 13.5px;
}
.pop-row + .pop-row { border-top: 1px solid var(--line); border-radius: 0; }
label.pop-row { cursor: pointer; }
.pop-row small { display: block; font-size: 12px; color: var(--text-3); }
.pop-row .seg { flex: none; }
.pop-row .seg-sm button { font-family: var(--font-sans); font-size: 12.5px; }
.pop-row select {
  appearance: none;
  -webkit-appearance: none;
  padding: 5px 26px 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%2371717a' stroke-width='1.5'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: 12.5px;
  outline: 0;
}
.pop-row select:focus-visible { border-color: var(--accent); }

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  cursor: pointer;
  transition: background 0.25s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform 0.35s var(--ease-out), background 0.25s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); background: var(--accent-ink); }

/* --------------------------------------------------------------- intro */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 40px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(40px, 7vw, 88px) var(--gutter) clamp(28px, 4vw, 44px);
}

.intro h1 {
  margin: 0;
  font-size: clamp(40px, 5.6vw, 76px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.045em;
}
.intro h1 em {
  font-style: normal;
  color: var(--text-3);
}
.intro p {
  max-width: 52ch;
  margin: 20px 0 0;
  color: var(--text-2);
  font-size: clamp(15px, 1.2vw, 17px);
}

.intro-stats {
  display: flex;
  gap: clamp(20px, 3vw, 44px);
  margin: 0;
}
.intro-stats div { min-width: 0; }
.intro-stats dt {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}
.intro-stats dd {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 500;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- category tabs */

.tabs-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: var(--z-filters);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.tabs-inner {
  display: flex;
  align-items: stretch;
  gap: 16px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
}

.tabs {
  position: relative;
  display: flex;
  flex: 1;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
  padding-right: 48px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs.at-end { mask-image: none; -webkit-mask-image: none; }

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 46px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s;
}
.tab:first-child { padding-left: 0; }
.tab:hover { color: var(--text-2); }
.tab[aria-selected="true"] { color: var(--text); }
.tab i { font-size: 14px; }
.tab-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
  transform: translateY(-4px);
}
.tab[data-empty]:not([aria-selected="true"]) { opacity: 0.4; }
.tab:focus-visible { outline-offset: -6px; }

.tab-ink {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform-origin: left;
  transition: transform 0.5s var(--ease-out);
  pointer-events: none;
}

.stack-select {
  position: relative;
  display: flex;
  align-items: center;
  flex: none;
  color: var(--text-2);
}
.stack-select i { position: absolute; right: 2px; font-size: 12px; pointer-events: none; color: var(--text-3); }
.stack-select select {
  appearance: none;
  -webkit-appearance: none;
  height: 30px;
  padding: 0 20px 0 10px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 13.5px;
  font-weight: 500;
  text-align: right;
  outline: 0;
  transition: background 0.2s, color 0.2s;
}
.stack-select select:hover { background: var(--surface); color: var(--text); }
.stack-select select:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.stack-select.is-active select { color: var(--accent-text); }
select option { background: var(--surface); color: var(--text); }

/* --------------------------------------------------------------- grid */

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px var(--gutter) 80px;
}

.result-line {
  margin: 10px 0 18px;
  font-size: 13px;
  color: var(--text-3);
  min-height: 20px;
}
.result-line strong { color: var(--text-2); font-weight: 500; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-min)), 1fr));
  gap: clamp(14px, 1.6vw, 24px);
}
body.is-compact { --card-min: 240px; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: border-color 0.3s, transform 0.4s var(--ease-out), background 0.3s;
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
}
.card:hover { border-color: var(--line-strong); }

.card.is-entering {
  animation: card-in 0.6s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.card-media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  padding: 0;
  border: 0;
  border-radius: var(--radius-media);
  overflow: hidden;
  background: var(--media-bg);
  isolation: isolate;
}
.card-media img,
.card-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s var(--ease-out), opacity 0.4s;
}
.card-media img { opacity: 0; }
.card-media img.is-loaded { opacity: 1; }
.card-media video { opacity: 0; }
.card-media video.is-playing { opacity: 1; }
.card:hover .card-media img,
.card:hover .card-media video { transform: scale(1.025); }

.card-media::after {
  /* skeleton shimmer until the poster lands */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--text) 5%, transparent) 50%, transparent 70%) var(--media-bg);
  background-size: 250% 100%;
  animation: shimmer 1.6s linear infinite;
}
.card-media.is-ready::after { animation: none; }
@keyframes shimmer { to { background-position: -150% 0; } }

.card-noposter {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-3);
  font-size: 28px;
}

.card-open {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: rgb(10 10 12 / 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f4f4f5;
  font-size: 12.5px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s, transform 0.4s var(--ease-out);
  pointer-events: none;
}
.card:hover .card-open,
.card-media:focus-visible .card-open { opacity: 1; transform: none; }

.card-body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px 8px 10px;
}
.card-text { flex: 1; min-width: 0; }
.card-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
}
.card-sub .num { font-family: var(--font-mono); font-size: 11.5px; }
.card-sub .stack { overflow: hidden; text-overflow: ellipsis; }
.card-sub .copied {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--accent-text);
}

.copy-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s var(--ease-out);
}
.copy-btn i { font-size: 15px; }
.copy-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.copy-btn:active { transform: scale(0.95); }
.copy-btn.is-done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.copy-btn:disabled { opacity: 0.4; pointer-events: none; }

body.is-compact .copy-btn span { display: none; }
body.is-compact .copy-btn { width: 34px; padding: 0; justify-content: center; }

/* --------------------------------------------------------------- empty */

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 90px 20px;
  text-align: center;
  color: var(--text-2);
}
.empty > i { font-size: 34px; color: var(--text-3); margin-bottom: 8px; }
.empty h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }
.empty p { margin: 0 0 16px; }

/* --------------------------------------------------------------- footer */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px var(--gutter) 40px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-3);
}
.foot p { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.foot kbd + kbd { margin-left: -2px; }
.foot kbd:not(:first-child) { margin-left: 10px; }
.foot kbd + kbd:not(:first-child) { margin-left: 0; }
.foot code { font-size: 12px; color: var(--text-2); }

/* --------------------------------------------------------------- viewer */

.viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: hidden;
}
.viewer::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.35s;
}
.viewer[open]::backdrop { opacity: 1; }
.viewer.is-open .viewer-shell { opacity: 1; transform: none; }
.viewer.is-closing .viewer-shell { opacity: 0; transform: translateY(12px) scale(0.99); }
.viewer.is-closing::backdrop { opacity: 0; }

.viewer-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  width: min(1560px, calc(100vw - 32px));
  height: calc(100dvh - 32px);
  margin: 16px auto;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  transition: opacity 0.35s var(--ease-out), transform 0.5s var(--ease-out);
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  background: var(--bg);
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stage-nav { display: flex; align-items: center; gap: 6px; }
.stage-close { display: none; }
.stage-pos {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}
.seg button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.seg-sm button { height: 26px; padding: 0 9px; font-family: var(--font-mono); font-size: 11.5px; }

.stage-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--media-bg);
  overflow: hidden;
}
.stage-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.35s;
}
.stage-frame video.is-ready { opacity: 1; }
.stage-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stage-frame:fullscreen { border-radius: 0; background: #000; }

.stage-loading {
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
}
.stage-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 30%;
  background: var(--accent);
  animation: loading 1.1s var(--ease-in-out) infinite;
}
.stage-frame.is-loading .stage-loading { opacity: 1; }
@keyframes loading { from { transform: translateX(-100%); } to { transform: translateX(400%); } }

.stage-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--text-3);
  text-align: center;
}
.stage-empty i { font-size: 32px; }
.stage-empty p { margin: 0; }

.player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 2px;
}
.player .icon-btn { flex: none; }
.player.is-disabled { opacity: 0.35; pointer-events: none; }

.scrub {
  flex: 1;
  display: flex;
  align-items: center;
  height: 28px;
  cursor: pointer;
  touch-action: none;
}
.scrub-track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
  transition: height 0.2s var(--ease-out);
}
.scrub:hover .scrub-track,
.scrub.is-dragging .scrub-track { height: 6px; }
.scrub-fill {
  position: absolute;
  inset: 0;
  transform-origin: left;
  transform: scaleX(0);
  background: var(--accent);
}

.time {
  flex: none;
  min-width: 86px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* panel */

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  min-height: 0;
  padding: 18px 22px 22px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
}
.panel-kicker .num {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
}

.panel-title {
  margin: -6px 0 0;
  font-size: clamp(24px, 2vw, 30px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 0;
  padding: 0;
  list-style: none;
}
.tags li {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface);
}

.btn-copy {
  justify-content: space-between;
  height: 54px;
  padding: 0 8px 0 20px;
  font-size: 15px;
}
.btn-copy-label { display: inline-flex; align-items: center; gap: 10px; }
.btn-copy-label i { font-size: 19px; }
.btn-copy-meta {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgb(0 0 0 / 0.1);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
}
.btn-copy.is-done { background: var(--accent-hover); }

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: -8px;
}
.panel-actions .btn { height: 40px; padding: 0 12px; font-size: 13px; }

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.facts div { padding: 12px 14px; }
.facts div + div { border-left: 1px solid var(--line); }
.facts dt { font-size: 11.5px; color: var(--text-3); }
.facts dd {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.code {
  display: flex;
  flex-direction: column;
  min-height: 320px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--code-bg);
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 14px 8px;
}
.code-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.code-head span { font-size: 12px; color: var(--text-3); }

.file-tabs {
  display: flex;
  gap: 4px;
  padding: 0 10px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}
.file-tabs::-webkit-scrollbar { display: none; }
.file-tab {
  flex: none;
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11.5px;
  transition: background 0.2s, color 0.2s;
}
.file-tab:hover { color: var(--text); background: var(--surface-2); }
.file-tab[aria-selected="true"] { color: var(--text); background: var(--surface-2); border-color: var(--line); }

.code-body {
  position: relative;
  flex: 1;
  min-height: 0;
  max-height: 520px;
  overflow: auto;
  scrollbar-width: thin;
}
.code-body pre {
  margin: 0;
  padding: 14px 16px 20px;
  font-size: 12px;
  line-height: 1.65;
  tab-size: 2;
}
.code-body code { font-family: var(--font-mono); color: var(--text-2); }
.code-body.is-loading::after {
  content: "";
  position: absolute;
  inset: 14px 16px auto;
  height: 120px;
  border-radius: 8px;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--text) 6%, transparent) 50%, transparent 70%) var(--surface-2);
  background-size: 250% 100%;
  animation: shimmer 1.4s linear infinite;
}

.origin {
  margin: 0;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.6;
}
.origin code { font-size: 11.5px; color: var(--text-2); word-break: break-word; }

/* syntax colours (highlight.js classes), tuned to the palette */
.hljs-comment, .hljs-quote { color: var(--text-3); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-built_in { color: #c792ea; }
.hljs-string, .hljs-attr-value, .hljs-template-tag, .hljs-regexp { color: var(--accent-text); }
.hljs-number, .hljs-symbol { color: #f5a97f; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #7dcfff; }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-variable, .hljs-params { color: var(--text); }
.hljs-tag, .hljs-name, .hljs-selector-class, .hljs-selector-id { color: #89b4fa; }
.hljs-meta { color: var(--text-3); }
:root[data-theme="light"] .hljs-keyword,
:root[data-theme="light"] .hljs-selector-tag,
:root[data-theme="light"] .hljs-literal,
:root[data-theme="light"] .hljs-built_in { color: #7c3aed; }
:root[data-theme="light"] .hljs-number { color: #c2410c; }
:root[data-theme="light"] .hljs-title,
:root[data-theme="light"] .hljs-section { color: #0369a1; }
:root[data-theme="light"] .hljs-tag,
:root[data-theme="light"] .hljs-name,
:root[data-theme="light"] .hljs-selector-class { color: #1d4ed8; }

/* --------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 12px 18px 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, 16px) scale(0.98);
  transition: opacity 0.3s, transform 0.45s var(--ease-out);
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast > i { font-size: 22px; color: var(--accent-text); }
.toast.is-error > i { color: #f87171; }
.toast div { display: grid; }
.toast strong { font-size: 14px; font-weight: 600; }
.toast span { font-size: 12.5px; color: var(--text-3); }

/* the toast must sit above the modal dialog's top layer */
.viewer .toast { position: fixed; }

/* --------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .viewer-shell { grid-template-columns: minmax(0, 1fr) 380px; }
  .intro { grid-template-columns: 1fr; align-items: start; gap: 28px; }
}

@media (max-width: 860px) {
  .brand-sub { display: none; }
  .search, .search:focus-within { width: min(46vw, 260px); }

  .viewer-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    width: 100vw;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
    border: 0;
    overflow-y: auto;
  }
  .stage { grid-template-rows: auto auto auto; }
  .stage-frame { aspect-ratio: 16 / 10; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .stage-close { display: inline-grid; }
  #v-close { display: none; }
  .stage-top .seg { margin-left: auto; }
  .search kbd { display: none; }
  .stack-select select { max-width: 96px; padding-left: 6px; font-size: 13px; }
  .tabs-inner { gap: 8px; }
  .code-body { max-height: 420px; }
}

@media (max-width: 560px) {
  :root { --card-min: 260px; }
  .intro-stats { gap: 22px; }
  .foot { flex-direction: column; }
  .player .seg-sm { display: none; }
  .time { min-width: 0; }
  .panel-actions { grid-template-columns: 1fr; }
}

@media (hover: none) {
  .card-open { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .card:hover .card-media img,
  .card:hover .card-media video { transform: none; }
}

/* --------------------------------------------------------------- saved */

.card-save {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgb(10 10 12 / 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f4f4f5;
  font-size: 15px;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.25s, transform 0.35s var(--ease-out), background 0.2s, color 0.2s;
}
.card:hover .card-save,
.card-save:focus-visible,
.card-save[aria-pressed="true"] { opacity: 1; transform: none; }
.card-save:hover { background: rgb(10 10 12 / 0.8); }
.card-save[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.card-save.is-pop { animation: save-pop 0.45s var(--ease-out); }
@keyframes save-pop { 40% { transform: scale(1.22); } }
@media (hover: none) { .card-save { opacity: 1; transform: none; } }

.panel-head #v-save { margin-left: auto; }

.foot-brand { font-weight: 600; color: var(--text); }

/* Hosted build: no original packs on the server, so hide what depends on them. */
.is-hosted .stage-top .seg,
.is-hosted .panel-actions { display: none; }
