* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 260px),
    repeating-linear-gradient(90deg, rgba(18, 18, 16, 0.025) 0 1px, transparent 1px 5px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 280px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 5px),
    var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 280px),
      repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 5px),
      var(--bg);
  }
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.adult-age-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  background: center / contain no-repeat url("./assets/icons/adult-18-plus.svg");
  line-height: 0;
  vertical-align: -0.38em;
}

.adult-age-icon-small {
  width: 22px;
  height: 22px;
}

.adult-age-icon-inline {
  width: 20px;
  height: 20px;
  margin: 0 3px;
  vertical-align: -0.42em;
}

.adult-age-icon-label {
  width: 28px;
  height: 28px;
}

.adult-age-icon-large {
  width: 54px;
  height: 54px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 52px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.topbar-title {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.topbar h1 {
  display: -webkit-box;
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  font-size: 32px;
  line-height: 1.12;
  font-weight: 720;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.home-brand-heading {
  display: block;
  line-height: 0;
  -webkit-line-clamp: unset;
}

.home-brand-image {
  display: block;
  width: min(300px, 100%);
  height: auto;
}

:root[data-theme="dark"] .home-brand-image {
  filter: invert(1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .home-brand-image {
    filter: invert(1);
  }
}

.title-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.topbar p {
  margin: 8px 0 0;
  max-width: 560px;
  color: var(--muted-soft);
  font-size: 13px;
  line-height: 1.6;
}

.source-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.version-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  background: var(--sort-idle-bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.version-pill:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
  color: var(--text);
}

.version-pill:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

body.is-version-history-open {
  overflow: hidden;
}

.version-history-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 11, 10, 0.48);
  backdrop-filter: blur(18px);
}

.version-history-backdrop[hidden] {
  display: none;
}

.version-history-panel {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 20px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

.version-history-panel:focus {
  outline: none;
}

.version-history-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.version-history-kicker {
  margin: 0 0 6px;
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 720;
}

.version-history-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1.2;
  font-weight: 760;
}

.version-history-close {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.version-history-close:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
  color: var(--text);
}

.version-history-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.version-history-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.version-history-summary {
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.version-history-list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.version-history-item {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.version-history-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.version-history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.version-history-version {
  color: var(--accent);
  font-size: 14px;
  font-weight: 780;
}

.version-history-date,
.version-history-current {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 660;
}

.version-history-current {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

.version-history-item h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 720;
}

.version-history-item ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.random-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 0 13px;
  background: var(--surface-strong);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 720;
  letter-spacing: 0;
  line-height: 1;
  box-shadow: var(--shadow-soft);
}

.random-button:hover {
  filter: brightness(1.08);
}

.random-button:active:not(:disabled) {
  background: var(--surface-strong);
  color: #fff;
  filter: none;
  transform: translateY(1px);
}

.random-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-soft);
}

.random-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.random-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.favorite-nav-button,
.detail-favorite-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 720;
  line-height: 1;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.favorite-nav-button:hover,
.detail-favorite-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--control-hover);
  color: var(--text);
}

.favorite-nav-button:active,
.detail-favorite-button:active:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--control-active);
  color: var(--text);
}

.favorite-nav-button:disabled {
  color: var(--disabled);
  cursor: wait;
  opacity: 0.58;
}

.favorite-nav-button:disabled:hover,
.favorite-nav-button:disabled:active {
  border-color: var(--line);
  background: var(--surface);
  color: var(--disabled);
}

.favorite-nav-button:focus-visible,
.detail-favorite-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-soft);
}

.favorite-nav-button svg,
.detail-favorite-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.favorite-nav-button strong {
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  padding: 0 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 780;
}

.favorite-nav-button.is-active {
  border-color: var(--accent);
  color: var(--text);
}

.detail-favorite-button.is-favorite {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.detail-favorite-button.is-favorite svg,
.happy-card-favorite-button.is-favorite svg {
  fill: currentColor;
}

.detail-favorite-button:disabled {
  cursor: default;
  opacity: 0.54;
}

.detail-icon-button {
  position: relative;
  width: 38px;
  padding: 0;
  gap: 0;
}

.detail-icon-button svg {
  width: 17px;
  height: 17px;
}

.detail-icon-button .icon-button-label,
.compact-mode-switch .mode-switch-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.detail-random-button[aria-busy="true"] svg {
  animation: detail-random-pulse 700ms ease-in-out infinite alternate;
}

@keyframes detail-random-pulse {
  from {
    opacity: 0.62;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.happy-mode-button {
  background: var(--accent);
}

.home-settings {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  margin-left: auto;
}

.settings-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.settings-button:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
}

.settings-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.settings-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  display: grid;
  width: min(356px, calc(100vw - 32px));
  gap: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.2);
}

.settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}

.settings-heading-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
}

.settings-heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.settings-heading-context {
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 700;
}

.settings-close-button {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  cursor: pointer;
}

.settings-close-button:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
  color: var(--text);
}

.settings-close-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-close-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.settings-stack {
  display: grid;
  gap: 10px;
}

.settings-field,
.settings-toggle,
.settings-segmented {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.settings-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
}

.settings-select-field {
  grid-template-columns: minmax(0, 1fr) 128px;
}

.settings-field span,
.settings-toggle > span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}

.settings-field-status {
  grid-column: 1 / -1;
  min-height: 16px;
  color: var(--text);
  white-space: normal;
}

.settings-field-status[hidden] {
  display: none;
}

.settings-field input,
.settings-field select {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 8px;
  background: var(--surface-solid);
  color: var(--text);
  text-align: center;
  outline: none;
}

.settings-field select {
  text-align: left;
}

.settings-field input:focus,
.settings-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 9px 10px;
  cursor: pointer;
  user-select: none;
}

.settings-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.settings-switch {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.18);
  transition: background 140ms ease, border-color 140ms ease;
}

.settings-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 140ms ease, background 140ms ease;
}

.settings-toggle input:checked + .settings-switch {
  border-color: transparent;
  background: var(--accent);
}

.settings-toggle input:checked + .settings-switch::after {
  background: #fff;
  transform: translateX(16px);
}

.settings-toggle:focus-within,
.settings-toggle:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-danger-toggle {
  align-items: center;
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--danger) 7%, transparent), transparent),
    var(--field);
}

.settings-danger-toggle[data-enabled="true"] {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line-strong));
  background: color-mix(in srgb, var(--danger) 10%, var(--field));
}

.settings-danger-toggle input:checked + .settings-switch {
  border-color: transparent;
  background: var(--danger);
}

.settings-toggle-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
  white-space: normal;
}

.settings-toggle-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  line-height: 1.2;
  white-space: normal;
}

.settings-toggle-note {
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
  white-space: normal;
}

.settings-age-chip {
  min-width: 0;
}

.settings-toggle-state {
  min-width: 14px;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 760;
  text-align: center;
}

.settings-segmented {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 9px 10px 10px;
}

.settings-segmented legend {
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}

.settings-segmented-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.settings-segmented button {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-solid);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 720;
  line-height: 1;
}

.settings-segmented button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.settings-segmented button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-segmented button.is-active {
  border-color: transparent;
  background: var(--sort-active-bg);
  color: var(--sort-active-text);
}

.settings-action {
  display: grid;
  gap: 7px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--field);
}

.settings-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.2;
}

.settings-action-button:hover {
  background: var(--control-hover);
}

.settings-action-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-action-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.settings-action-button[href] {
  text-decoration: none;
}

.settings-action-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.settings-action-button.is-busy svg {
  animation: restart-spin 900ms linear infinite;
}

.settings-action-button.is-sync-error,
.favorite-nav-button.is-sync-error,
.source-settings-button.is-sync-error {
  border-color: color-mix(in srgb, var(--danger) 58%, var(--line));
  color: var(--danger);
}

.favorite-sync-entry-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  max-width: 100%;
  border: 1px solid color-mix(in srgb, var(--danger) 34%, transparent);
  border-radius: 999px;
  padding: 0 8px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 11px;
  font-weight: 780;
  line-height: 1.2;
  white-space: nowrap;
}

.favorite-sync-entry-status[hidden] {
  display: none;
}

.settings-status {
  min-height: 16px;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 680;
  line-height: 1.35;
}

.source-domain-action {
  gap: 8px;
}

.source-domain-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 7px;
}

.source-domain-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.source-domain-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.source-domain-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.source-domain-field input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  background: var(--surface-solid);
  color: var(--text);
  outline: none;
}

.source-domain-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.source-domain-buttons {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 7px;
}

.source-domain-buttons .settings-action-button {
  min-height: 34px;
  font-size: 12px;
}

@keyframes restart-spin {
  to {
    transform: rotate(360deg);
  }
}

.source-settings-shell {
  max-width: 1180px;
}

.source-settings-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.source-settings-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.source-settings-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.source-settings-legend i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--muted-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted-soft) 14%, transparent);
}

.source-settings-legend i[data-legend="saved"] {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.source-settings-legend i[data-legend="failed"] {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent);
}

.source-settings-legend i[data-legend="empty"] {
  background: var(--amber);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 16%, transparent);
}

#sourceSettingsSummary {
  flex: 1 1 220px;
  min-width: 180px;
}

.source-settings-search {
  display: grid;
  flex: 1 1 280px;
  min-width: 220px;
  gap: 4px;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 760;
}

.source-settings-search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--field);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  outline: none;
}

.source-settings-search input::placeholder {
  color: var(--muted-soft);
  font-weight: 650;
}

.source-settings-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.source-settings-search input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.source-settings-clear-search-button {
  align-self: stretch;
  min-height: 44px;
  white-space: nowrap;
}

.source-settings-toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
}

.source-settings-toast {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  z-index: 300;
  width: max-content;
  min-width: min(320px, calc(100vw - 32px));
  max-width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--surface-solid) 94%, var(--bg));
  color: var(--text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, -10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.source-settings-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.source-settings-toast[data-tone="good"] {
  border-color: color-mix(in srgb, var(--good) 45%, var(--line));
  background: color-mix(in srgb, var(--good) 12%, var(--surface-solid));
  color: var(--text);
}

.source-settings-toast[data-tone="danger"] {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  background: color-mix(in srgb, var(--danger) 13%, var(--surface-solid));
  color: var(--text);
}

.interface-source-form {
  display: grid;
  grid-template-columns: minmax(126px, 0.82fr) minmax(170px, 0.95fr) minmax(260px, 1.75fr) 70px 118px;
  align-items: end;
  gap: 10px;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.interface-source-heading {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.interface-source-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}

.interface-source-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.interface-source-field span {
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 760;
}

.interface-source-adult-check,
.source-edit-adult-check,
.ai-source-save-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid color-mix(in srgb, var(--danger) 34%, var(--line));
  border-radius: 8px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--danger) 9%, var(--field));
  color: var(--danger);
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.interface-source-adult-check input,
.source-edit-adult-check input,
.ai-source-save-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--danger);
}

.interface-source-field input {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.interface-source-api-field input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.interface-source-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.source-settings-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.source-settings-section-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}

.source-settings-section-heading span {
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 760;
}

.source-settings-ai-workbench {
  margin: 12px 0;
}

.source-settings-sync-panel {
  scroll-margin-top: 20px;
  margin: 12px 0;
}

.source-settings-ai-result {
  margin: 0 0 12px;
}

.source-settings-ai-dialog,
.source-settings-sync-dialog,
.source-settings-interface-dialog,
.source-settings-edit-dialog,
.source-settings-confirm-dialog {
  width: min(940px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.source-settings-sync-dialog {
  width: min(980px, calc(100vw - 32px));
}

.source-settings-interface-dialog {
  width: min(720px, calc(100vw - 32px));
}

.source-settings-edit-dialog {
  width: min(520px, calc(100vw - 32px));
}

.source-settings-confirm-dialog {
  width: min(480px, calc(100vw - 32px));
}

.source-settings-ai-dialog::backdrop,
.source-settings-sync-dialog::backdrop,
.source-settings-interface-dialog::backdrop,
.source-settings-edit-dialog::backdrop,
.source-settings-confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.54);
  backdrop-filter: blur(10px);
}

.source-settings-ai-dialog:not([open]),
.source-settings-sync-dialog:not([open]),
.source-settings-interface-dialog:not([open]),
.source-settings-edit-dialog:not([open]),
.source-settings-confirm-dialog:not([open]) {
  display: none;
}

.source-settings-ai-panel,
.source-settings-sync-dialog-panel,
.source-settings-interface-panel,
.source-settings-edit-panel,
.source-settings-confirm-panel {
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.source-settings-confirm-panel {
  gap: 18px;
  padding: 18px;
}

.source-settings-confirm-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.source-settings-confirm-mark {
  align-self: start;
}

.source-settings-confirm-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
}

.source-settings-confirm-head p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  line-height: 1.6;
}

.source-settings-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.source-settings-ai-header,
.source-settings-sync-header,
.source-settings-interface-header,
.source-settings-edit-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.source-settings-ai-header h2,
.source-settings-sync-header h2,
.source-settings-interface-header h2,
.source-settings-edit-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
}

.source-settings-ai-header p,
.source-settings-sync-header p,
.source-settings-interface-header p,
.source-settings-edit-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.source-settings-ai-dialog .source-settings-ai-workbench,
.source-settings-ai-dialog .source-settings-ai-result {
  margin: 0;
}

.source-settings-ai-dialog .ai-source-workbench {
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.source-settings-ai-dialog .ai-source-result {
  box-shadow: none;
}

.source-settings-sync-dialog .source-settings-sync-panel {
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.source-settings-interface-dialog .interface-source-form {
  grid-template-columns: minmax(0, 1fr) 70px 118px 70px;
  grid-template-areas:
    "name adult button cancel"
    "api api api api"
    "status status status status";
  align-items: end;
  gap: 10px;
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.source-settings-interface-dialog .interface-source-field:first-of-type {
  grid-area: name;
}

.source-settings-interface-dialog .interface-source-api-field {
  grid-area: api;
}

.source-settings-interface-dialog .interface-source-adult-check {
  grid-area: adult;
}

.source-settings-interface-dialog #saveInterfaceSourceButton {
  grid-area: button;
}

.source-settings-interface-dialog .interface-source-cancel-button {
  grid-area: cancel;
  height: 34px;
  padding: 0 10px;
}

.source-settings-interface-dialog .interface-source-status {
  grid-area: status;
  min-height: 18px;
}

.source-edit-form {
  display: grid;
  gap: 12px;
}

.source-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 10px;
  align-items: end;
}

.source-edit-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.source-edit-field span {
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 760;
}

.source-edit-field input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
  outline: none;
}

.source-edit-type-field {
  align-self: stretch;
}

.source-edit-type-field .source-settings-type-tag {
  width: 100%;
  min-height: 38px;
}

.source-edit-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}

.source-edit-url-row .source-settings-icon-button {
  width: 38px;
  height: 38px;
}

.source-edit-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.source-edit-field input[readonly] {
  color: var(--muted);
  cursor: default;
}

.source-edit-adult-check {
  align-self: end;
  min-height: 38px;
}

.source-edit-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.source-edit-actions #resetSourceEditDomainButton {
  width: 38px;
  padding: 0;
}

.source-edit-status {
  min-height: 18px;
  text-align: right;
}

.source-settings-log-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.source-settings-log-dialog::backdrop {
  background: rgba(0, 0, 0, 0.54);
  backdrop-filter: blur(10px);
}

.source-settings-log-dialog:not([open]) {
  display: none;
}

.source-settings-log-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.source-settings-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-settings-log-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
}

.source-settings-log-header p {
  margin: 3px 0 0;
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 700;
}

.source-settings-log-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.source-settings-log-filter {
  min-width: 0;
}

.source-settings-log-insights {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: color-mix(in srgb, var(--field) 72%, var(--surface));
}

.source-settings-log-insights[hidden] {
  display: none;
}

.source-settings-log-insight-overview {
  flex: 1 1 100%;
  margin: 0 0 1px;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 760;
  line-height: 1.35;
}

.source-settings-log-insight-group {
  display: flex;
  flex: 1 1 220px;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.source-settings-log-insight-title,
.source-settings-log-insight-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.source-settings-log-insight-empty {
  color: var(--muted-soft);
}

.source-settings-log-insight-chip,
.source-settings-log-insight-clear {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-solid);
  color: var(--text);
  font: inherit;
  font-size: 11px;
  font-weight: 760;
  line-height: 1;
  cursor: pointer;
}

.source-settings-log-insight-chip {
  max-width: min(220px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-settings-log-insight-chip:hover,
.source-settings-log-insight-clear:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.source-settings-log-insight-chip[data-active="true"] {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-solid));
  color: var(--accent-strong);
}

.source-settings-log-insight-clear {
  margin-left: auto;
  color: var(--muted);
}

.source-settings-log-list {
  display: grid;
  gap: 8px;
  max-height: min(56vh, 520px);
  overflow: auto;
}

.source-settings-log-empty {
  border: 1px dashed var(--line);
  border-radius: 7px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.source-settings-log-entry {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: var(--surface-solid);
}

.source-settings-log-entry[data-level="warn"] {
  border-color: color-mix(in srgb, var(--warning, #c58b2c) 42%, var(--line));
}

.source-settings-log-entry-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}

.source-settings-log-entry-title {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  font-weight: 780;
  line-height: 1.35;
}

.source-settings-log-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--field);
  color: var(--muted);
  font-size: 10px;
  font-weight: 780;
}

.source-settings-log-entry time {
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.source-settings-log-meta,
.source-settings-log-url {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.4;
}

.source-settings-log-url {
  color: var(--muted-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.source-settings-log-detail-shell {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}

.source-settings-log-detail-shell summary {
  min-height: 30px;
  padding: 7px 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  cursor: pointer;
}

.source-settings-log-detail-shell summary:hover {
  color: var(--accent-strong);
}

.source-settings-log-detail {
  max-height: 180px;
  overflow: auto;
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 8px;
  background: color-mix(in srgb, var(--field) 78%, var(--surface-solid));
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.source-settings-log-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-settings-log-actions .source-settings-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 11px;
}

.source-settings-log-actions .source-settings-button[data-copied="true"] {
  border-color: color-mix(in srgb, var(--success, #2f9e44) 58%, var(--line));
  color: var(--success, #2f9e44);
}

.source-settings-log-actions .source-settings-button[data-copied="false"] {
  border-color: color-mix(in srgb, var(--danger, #d94848) 58%, var(--line));
  color: var(--danger, #d94848);
}

.source-settings-log-more-button {
  width: 100%;
  min-height: 36px;
  justify-content: center;
  background: var(--field);
}

.source-settings-list {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.source-settings-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.source-settings-empty-action {
  display: grid;
  gap: 12px;
  justify-items: start;
}

.source-settings-empty-action p {
  margin: 0;
}

.source-settings-list-header,
.source-settings-row {
  display: grid;
  grid-template-columns: minmax(156px, 1fr) minmax(118px, 0.55fr) 128px minmax(92px, 0.62fr) 68px;
  align-items: center;
  gap: 8px;
}

.source-settings-list-header {
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--field);
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 760;
}

.source-settings-row {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  min-height: 66px;
  padding: 9px 12px;
  transition: background 160ms ease, box-shadow 160ms ease;
}

.source-settings-row:hover {
  background: rgba(255, 255, 255, 0.025);
}

.source-settings-row:last-child {
  border-bottom: 0;
}

.source-settings-row.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.source-settings-row.is-recently-saved {
  box-shadow: inset 3px 0 0 var(--accent), 0 0 0 1px color-mix(in srgb, var(--accent) 42%, transparent);
}

.source-settings-source {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.source-settings-source-title {
  min-width: 0;
}

.source-settings-source h2 {
  min-width: 0;
  overflow: hidden;
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-settings-source-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.source-settings-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--field);
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
}

.source-settings-badge[data-source-badge="default"] {
  border-color: color-mix(in srgb, var(--good) 46%, var(--line));
  background: color-mix(in srgb, var(--good) 13%, var(--field));
  color: var(--good);
}

.source-settings-badge[data-source-badge="parser"] {
  border-color: color-mix(in srgb, #4f7fb8 48%, var(--line));
  background: color-mix(in srgb, #4f7fb8 14%, var(--field));
  color: #356ca7;
}

:root[data-theme="dark"] .source-settings-badge[data-source-badge="parser"] {
  color: #8fb8ee;
}

.source-settings-badge[data-source-badge="interface"],
.source-settings-row.is-interface-source .source-settings-badge {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: var(--accent-soft);
  color: var(--accent);
}

.source-settings-badge[data-source-badge="hidden"] {
  border-color: color-mix(in srgb, var(--muted-soft) 48%, var(--line));
  background: color-mix(in srgb, var(--muted-soft) 14%, var(--field));
  color: var(--muted);
}

.source-settings-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.source-settings-field > span,
.source-settings-field > label {
  display: none;
}

.source-settings-endpoints {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}

.source-settings-field input {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  background: var(--surface-solid);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  outline: none;
}

.source-settings-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.source-settings-type-control {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.source-settings-type-tag {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  max-width: 100%;
  min-height: 32px;
  border: 1px solid color-mix(in srgb, var(--good) 34%, var(--line));
  border-radius: 999px;
  padding: 0 11px;
  background: color-mix(in srgb, var(--good) 10%, var(--field));
  color: var(--good);
  font-size: 12px;
  font-weight: 820;
  line-height: 1.2;
  white-space: nowrap;
  cursor: default;
}

.source-settings-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.source-settings-actions .source-settings-button {
  min-width: 34px;
  padding: 0;
}

.source-settings-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 7px;
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
  font-weight: 760;
  line-height: 1.2;
}

.source-settings-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--control-hover);
  color: var(--text);
}

.source-settings-button:active:not(:disabled) {
  background: var(--control-active);
  color: var(--text);
  transform: translateY(1px);
}

.source-settings-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.source-settings-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.source-settings-button svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.source-action-label {
  display: none;
  white-space: nowrap;
}

.source-settings-icon-button {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.source-settings-icon-button svg {
  width: 15px;
  height: 15px;
}

.source-settings-button.is-busy svg {
  animation: restart-spin 900ms linear infinite;
}

.source-settings-button.is-cancel-action {
  color: var(--danger);
  border-color: rgba(184, 79, 56, 0.38);
  background: rgba(184, 79, 56, 0.1);
}

.source-settings-adult-button span {
  color: currentColor;
  font-size: 10px;
  font-weight: 860;
  letter-spacing: 0;
}

.source-settings-primary-button {
  border-color: transparent;
  background: var(--sort-active-bg);
  color: var(--sort-active-text);
}

.source-settings-skeleton-row {
  pointer-events: none;
}

.source-settings-skeleton-cell {
  display: grid;
  align-content: center;
  gap: 6px;
  min-width: 0;
}

.source-settings-skeleton-line {
  display: block;
  max-width: 100%;
  height: 10px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      color-mix(in srgb, var(--field) 80%, transparent),
      color-mix(in srgb, var(--line-strong) 52%, transparent),
      color-mix(in srgb, var(--field) 80%, transparent)
    );
  background-size: 180% 100%;
  animation: source-skeleton-pulse 1.2s ease-in-out infinite;
}

@keyframes source-skeleton-pulse {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -80% 0;
  }
}

.source-settings-primary-button:hover:not(:disabled) {
  border-color: transparent;
  background: var(--sort-active-pressed-bg);
  color: var(--sort-active-pressed-text);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.source-settings-primary-button:active:not(:disabled) {
  background: var(--sort-active-pressed-bg);
  color: var(--sort-active-pressed-text);
}

.source-settings-primary-button.is-dirty:not(:disabled) {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.source-settings-danger-button {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  color: var(--danger);
}

.source-settings-danger-button[hidden] {
  display: none;
}

.source-settings-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 680;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.source-settings-connectivity-status {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: var(--field);
}

.source-settings-connectivity-status.has-probes {
  align-items: flex-start;
  flex-direction: column;
  border-radius: 10px;
  padding: 6px 8px;
}

.source-connectivity-probes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.source-connectivity-probe {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px;
  color: var(--muted);
  background: color-mix(in srgb, var(--field) 72%, transparent);
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.source-connectivity-probe[data-status="ok"] {
  color: var(--good);
  border-color: rgba(139, 191, 147, 0.36);
  background: rgba(139, 191, 147, 0.1);
}

.source-connectivity-probe[data-status="blocked"],
.source-connectivity-probe[data-status="error"] {
  color: var(--danger);
  border-color: rgba(184, 79, 56, 0.36);
  background: rgba(184, 79, 56, 0.1);
}

.source-connectivity-probe[data-status="empty"] {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 42%, transparent);
  background: color-mix(in srgb, var(--amber) 13%, transparent);
}

.source-settings-status[data-tone="good"],
.source-settings-row[data-status="ok"] .source-settings-connectivity-status {
  color: var(--good);
  border-color: rgba(139, 191, 147, 0.42);
  background: rgba(139, 191, 147, 0.12);
}

.source-settings-status[data-tone="danger"],
.source-settings-row[data-status="blocked"] .source-settings-connectivity-status,
.source-settings-row[data-status="error"] .source-settings-connectivity-status {
  color: var(--danger);
  border-color: rgba(184, 79, 56, 0.42);
  background: rgba(184, 79, 56, 0.12);
}

.source-settings-row[data-status="empty"] .source-settings-connectivity-status {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 42%, transparent);
  background: color-mix(in srgb, var(--amber) 12%, transparent);
}

.source-settings-row[data-status="skipped"] .source-settings-connectivity-status {
  color: var(--muted);
  border-color: var(--line);
  background: var(--field);
}

.mode-switch {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px 0 9px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
  user-select: none;
}

.mode-switch:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
}

.mode-switch:focus-within {
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-soft);
}

.mode-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.mode-switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.18);
  transition: background 140ms ease, border-color 140ms ease;
}

.mode-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 140ms ease, background 140ms ease;
}

.mode-switch input:checked + .mode-switch-track {
  border-color: transparent;
  background: var(--accent);
}

.mode-switch input:checked + .mode-switch-track::after {
  background: #fff;
  transform: translateX(14px);
}

.compact-mode-switch {
  justify-content: center;
  width: 54px;
  padding: 0;
  gap: 0;
}

.theme-toggle {
  position: relative;
  width: 38px;
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: grid;
  grid-template-columns: 18px;
  flex: 0 0 auto;
  place-items: center;
  place-content: center;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.theme-toggle:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-toggle-icon {
  grid-area: 1 / 1;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: opacity 140ms ease, transform 140ms ease;
}

.theme-toggle-label {
  display: none;
  grid-area: 1 / 2;
  color: currentColor;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
}

.theme-toggle-icon-moon {
  opacity: 0;
  transform: scale(0.82) rotate(-20deg);
}

.theme-toggle-icon-system {
  opacity: 0;
  transform: scale(0.8);
}

:root[data-theme="dark"] .theme-toggle-icon-sun {
  opacity: 0;
  transform: scale(0.82) rotate(20deg);
}

:root[data-theme="dark"] .theme-toggle-icon-moon {
  opacity: 1;
  transform: scale(1) rotate(0);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle-icon-sun {
    opacity: 0;
    transform: scale(0.82) rotate(20deg);
  }

  :root:not([data-theme="light"]) .theme-toggle-icon-moon {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

.theme-toggle[data-theme-mode="system"] .theme-toggle-icon-sun,
.theme-toggle[data-theme-mode="system"] .theme-toggle-icon-moon {
  opacity: 0;
  transform: scale(0.82);
}

.theme-toggle[data-theme-mode="system"] .theme-toggle-icon-system {
  opacity: 1;
  transform: scale(1);
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px minmax(430px, auto);
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.home-controls {
  position: relative;
  z-index: 40;
  grid-template-columns: 174px minmax(0, 1fr) 154px;
  align-items: end;
  overflow: visible;
}

.home-controls .search-box {
  position: relative;
  z-index: 150;
  width: min(100%, 480px);
}

.home-controls-placeholder[hidden],
.mobile-filter-backdrop,
.mobile-filter-sheet,
.mobile-filter-button {
  display: none;
}

.favorites-controls {
  grid-template-columns: minmax(220px, 1fr) minmax(300px, auto) auto;
}

.favorites-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.favorites-action-group .favorite-nav-button {
  height: 42px;
}

.favorites-action-group .favorite-nav-button:disabled {
  cursor: default;
  opacity: 0.58;
}

.search-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 40px;
  gap: 8px;
  align-items: end;
}

.search-box:has(.icon-button[hidden]) {
  grid-template-columns: minmax(0, 1fr) 40px;
}

.search-box label,
.search-field,
.select-box,
.sort-select {
  display: grid;
  gap: 6px;
}

.search-field {
  position: relative;
  min-width: 0;
}

.search-box span,
.select-box span,
.sort-select span,
.category-heading span {
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 640;
}

.sort-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sort-field > span {
  flex: 0 0 auto;
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 640;
}

.sort-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.sort-button {
  min-width: 58px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--sort-idle-bg);
  color: var(--sort-idle-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 680;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
  box-shadow: none;
}

.sort-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
  filter: none;
}

.sort-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sort-button.is-active {
  border-color: transparent;
  background: var(--sort-active-bg);
  color: var(--sort-active-text);
}

.search-box input,
.select-box select,
.select-box input,
.sort-select select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.search-box input {
  padding: 0 12px;
}

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

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  transform: translateY(-140%);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 13px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 780;
  text-decoration: none;
  transition: transform 160ms ease;
}

.skip-link:focus-visible {
  outline: none;
  transform: translateY(0);
  box-shadow: var(--shadow), 0 0 0 3px var(--accent-soft);
}

.credential-field {
  position: relative;
}

.credential-field input {
  padding-right: 44px;
}

.credential-toggle-button {
  position: absolute;
  right: 8px;
  bottom: 6px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.credential-toggle-button:hover,
.credential-toggle-button:focus-visible,
.credential-toggle-button.is-visible {
  outline: none;
  background: var(--accent-soft);
  color: var(--accent);
}

.credential-toggle-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.search-history-panel {
  position: absolute;
  z-index: 240;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.search-history-panel[hidden],
.search-history-list[hidden],
.search-history-clear[hidden] {
  display: none;
}

.search-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 2px;
}

.search-history-clear {
  min-width: 0;
  border: 0;
  border-radius: 6px;
  padding: 4px 6px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
  letter-spacing: 0;
  line-height: 1;
}

.search-history-clear:hover,
.search-history-clear:focus-visible {
  outline: none;
  background: var(--accent-soft);
}

.search-history-list {
  display: grid;
  gap: 4px;
  max-height: 226px;
  overflow: auto;
}

.search-history-item {
  min-width: 0;
  width: 100%;
  height: 34px;
  border: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.search-history-item > span {
  flex: 1 1 auto;
}

.search-history-item:hover,
.search-history-item:focus-visible,
.search-history-item.is-active,
.search-history-item[aria-selected="true"] {
  outline: none;
  background: var(--accent-soft);
}

.search-history-item > svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  color: var(--muted);
}

.search-history-delete {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.search-history-delete:hover,
.search-history-delete:focus-visible {
  outline: none;
  background: var(--field);
  color: var(--danger);
}

.search-history-delete svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2.2;
}

.search-history-item span {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-history-empty {
  margin: 0;
  border-radius: 6px;
  padding: 10px 8px;
  background: var(--field);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--control-hover);
}

.icon-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.select-box select,
.select-box input,
.sort-select select {
  padding: 0 10px;
}

.source-select-box select {
  font-weight: 720;
}

.search-box input:focus,
.select-box select:focus,
.select-box input:focus,
.sort-select select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.category-panel {
  --category-collapsed-height: 34px;
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
  min-width: 0;
  padding-top: 2px;
}

.category-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.category-expand-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.category-expand-button[hidden] {
  display: none;
}

.category-expand-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.category-expand-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.category-expand-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 160ms ease;
}

.category-panel.is-expanded .category-expand-button svg {
  transform: rotate(180deg);
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  overflow: visible;
  transition: max-height 180ms ease;
}

.category-panel.is-collapsed .category-tabs {
  max-height: var(--category-collapsed-height);
  overflow: hidden;
}

.category-chip {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--sort-idle-bg);
  color: var(--sort-idle-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 680;
  line-height: 1;
  white-space: nowrap;
}

.category-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.category-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.category-chip.is-active {
  border-color: transparent;
  background: var(--sort-active-bg);
  color: var(--sort-active-text);
}

.category-retry-chip {
  border-color: color-mix(in srgb, var(--warning, #c58b2c) 44%, var(--line));
  background: color-mix(in srgb, var(--warning, #c58b2c) 14%, var(--sort-idle-bg));
  color: var(--warning, #b9772e);
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin: 18px 0 18px;
  color: var(--muted-soft);
  font-size: 13px;
}

#resultSummary {
  flex: 1 1 240px;
  min-width: 0;
}

.summary-action-button {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 680;
  padding: 7px 13px;
  cursor: pointer;
}

.summary-action-button:hover:not(:disabled) {
  border-color: var(--line-strong);
}

.summary-action-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.summary-action-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.summary-action-button[hidden] {
  display: none;
}

.search-failure-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: -4px;
  color: var(--muted);
  font-size: 13px;
}

.search-failure-list[hidden] {
  display: none;
}

.search-failure-list-title {
  color: var(--text);
  font-weight: 760;
}

.search-failure-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(100%, 460px);
  min-height: 34px;
  border: 1px solid color-mix(in srgb, var(--danger) 32%, var(--line));
  border-radius: 999px;
  padding: 4px 5px 4px 12px;
  background: color-mix(in srgb, var(--danger) 7%, var(--panel));
}

.search-failure-source {
  flex: 0 0 auto;
  color: var(--text);
  font-weight: 760;
}

.search-failure-reason {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-failure-retry {
  min-height: 28px;
  padding: 4px 10px;
}

.api-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.api-action-button,
.api-link {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  background: var(--field);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
  line-height: 30px;
  text-decoration: none;
  white-space: nowrap;
}

.api-action-button:hover:not(:disabled),
.api-action-button:focus-visible,
.api-link:hover:not(.is-disabled),
.api-link:focus-visible {
  outline: none;
  border-color: var(--line-strong);
  color: var(--text);
}

.api-action-button:disabled,
.api-link.is-disabled {
  cursor: default;
  opacity: 0.54;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  margin-bottom: 14px;
  padding: 0 14px 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.back-link::before {
  content: "‹";
  font-size: 24px;
  line-height: 1;
}

.back-link:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
  color: var(--text);
  transform: translateY(-1px);
}

.back-link:active {
  background: var(--control-active);
  transform: translateY(0);
}

.back-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft), 0 10px 24px rgba(0, 0, 0, 0.12);
}

.back-to-top-button {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 90;
  width: 54px;
  min-width: 54px;
  height: 54px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--text);
  color: var(--surface-solid);
  cursor: pointer;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, opacity 140ms ease;
}

.back-to-top-button[hidden] {
  display: none;
}

.back-to-top-button:hover {
  background: color-mix(in srgb, var(--text) 88%, var(--accent));
  transform: translateY(-1px);
}

.back-to-top-button:active {
  background: color-mix(in srgb, var(--text) 82%, var(--accent));
  transform: translateY(0);
}

.back-to-top-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft), 0 18px 46px rgba(0, 0, 0, 0.28);
}

.back-to-top-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.video-grid {
  --video-grid-columns: 6;
  --video-grid-row-gap: 18px;
  --video-grid-column-gap: 14px;
  display: grid;
  grid-template-columns: repeat(var(--video-grid-columns), minmax(0, 1fr));
  gap: var(--video-grid-row-gap) var(--video-grid-column-gap);
}

.video-grid[data-card-size="large"] {
  --video-grid-columns: 4;
  --video-grid-row-gap: 20px;
  --video-grid-column-gap: 16px;
}

.video-grid[data-card-size="small"] {
  --video-grid-columns: 8;
  --video-grid-row-gap: 16px;
  --video-grid-column-gap: 12px;
}

.search-source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.search-source-tabs[hidden] {
  display: none;
}

.search-source-tabs-label {
  flex: 1 0 100%;
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 640;
}

.search-source-tab {
  min-width: 92px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.search-source-tab:hover {
  border-color: var(--line-strong);
  background: var(--control-hover);
  color: var(--text);
}

.search-source-tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-source-tab.is-active {
  border-color: transparent;
  background: var(--text);
  color: var(--surface-solid);
}

.search-source-tab.has-error:not(.is-active) {
  border-color: color-mix(in srgb, var(--danger) 38%, var(--line));
  color: var(--danger);
}

.search-source-tab.is-queued:not(.is-active) {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 54%, var(--surface));
  color: var(--muted-strong);
}

.search-source-tab span {
  overflow: hidden;
  max-width: 112px;
  text-overflow: ellipsis;
}

.search-source-tab strong {
  min-width: 22px;
  border-radius: 999px;
  padding: 2px 6px;
  background: var(--field);
  color: var(--muted);
  font-size: 10px;
  font-weight: 820;
  line-height: 1.2;
}

.search-source-tab.is-active strong {
  background: color-mix(in srgb, var(--surface-solid) 78%, transparent);
  color: var(--text);
}

.video-card {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
}

.video-card.is-visual-duplicate {
  display: none;
}

.poster-link {
  display: block;
  outline-offset: 5px;
}

.poster {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 34%),
    linear-gradient(135deg, #2b2924 0%, #12110f 56%, #3c332d 100%);
  box-shadow: var(--image-shadow);
  transform: translateZ(0);
  transition: box-shadow 180ms ease, transform 180ms ease, filter 180ms ease;
}

.poster::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 26%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.5), transparent 48%);
  opacity: 0.76;
}

.poster::after {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: 1;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  opacity: 0;
  transition: opacity 180ms ease;
}

.poster-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 240ms ease, opacity 160ms ease;
}

.poster-preview {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 240ms ease;
}

.poster-preview-status {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: calc(100% - 20px);
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.poster-preview-status:empty,
.poster-preview-status[hidden] {
  display: none;
}

.video-card:hover .poster,
.video-card:focus-within .poster {
  box-shadow: 0 24px 58px rgba(13, 14, 12, 0.24);
  transform: translateY(-3px);
}

.video-card:hover .poster::after,
.video-card:focus-within .poster::after,
.video-card.is-preview-loading .poster::after {
  opacity: 1;
}

.video-card:hover .poster-image,
.video-card:focus-within .poster-image {
  transform: scale(1.035);
}

.video-card:hover .poster-preview,
.video-card:focus-within .poster-preview {
  transform: scale(1.035);
}

.video-card.is-preview-playing .poster-image {
  opacity: 0;
}

.video-card.is-preview-playing .poster-preview {
  opacity: 1;
}

.video-card.is-preview-error .poster {
  outline: 1px solid color-mix(in srgb, var(--warning) 52%, transparent);
  outline-offset: -1px;
}

.video-card.is-preview-error .poster-image {
  opacity: 1;
}

.video-card.is-preview-error .poster-preview {
  opacity: 0;
}

.video-card.is-preview-error .poster-preview-status {
  background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
  color: var(--text);
  border-color: color-mix(in srgb, var(--warning) 38%, var(--line));
}

.video-card-skeleton {
  pointer-events: none;
}

.video-card-skeleton-poster::before {
  opacity: 0.36;
}

.video-card-skeleton-poster::after {
  inset: 0;
  border: 0;
  border-radius: 0;
  opacity: 1;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.22) 44%, transparent 68%);
  transform: translateX(-100%);
  animation: video-skeleton-shimmer 1.35s ease-in-out infinite;
}

.video-card-skeleton-body {
  display: grid;
  gap: 7px;
}

.video-card-skeleton-line {
  display: block;
  width: 100%;
  height: 13px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 13%, transparent);
  animation: video-skeleton-pulse 1.3s ease-in-out infinite;
}

.video-card-skeleton-line[data-size="short"] {
  width: 68%;
}

.video-card-skeleton-line[data-size="meta"] {
  width: 42%;
  height: 10px;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
}

@keyframes video-skeleton-shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

@keyframes video-skeleton-pulse {
  0%,
  100% {
    opacity: 0.48;
  }

  50% {
    opacity: 0.82;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .video-card-skeleton-poster::after,
  .video-card-skeleton-line {
    animation: none;
  }

  .video-card:hover,
  .source-settings-row:hover,
  .favorite-card:hover {
    transform: none !important;
  }
}

.poster-id {
  position: absolute;
  left: 9px;
  right: 62px;
  bottom: 8px;
  z-index: 2;
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poster-source-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  max-width: calc(100% - 16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(0, 0, 0, 0.52);
  color: rgba(255, 255, 255, 0.92);
  font-size: 10px;
  font-weight: 780;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.duration {
  position: absolute;
  right: 8px;
  bottom: 7px;
  z-index: 2;
  min-width: 40px;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.46);
  color: rgba(255, 255, 255, 0.88);
  font-size: 10px;
  font-weight: 680;
  text-align: center;
  backdrop-filter: blur(10px);
}

.card-body {
  padding: 8px 1px 0;
}

.title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 7px;
}

.title-row h2 {
  flex: 1 1 auto;
  margin: 0;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.36;
  font-weight: 660;
  opacity: 0.92;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.description {
  display: none;
}

.rank {
  flex: 0 0 auto;
  color: var(--muted-soft);
  padding-top: 2px;
  font-size: 10px;
  font-weight: 600;
  opacity: 0.62;
}

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 8px;
  margin: 6px 0 0;
}

.meta-grid div {
  min-width: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.meta-grid dt {
  color: var(--muted-soft);
  font-size: 10px;
  font-weight: 520;
  opacity: 0.68;
}

.meta-grid dd {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 560;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.72;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding-top: 0;
  border-top: 0;
  opacity: 0.62;
  transition: opacity 160ms ease;
}

.video-card:hover .actions,
.video-card:focus-within .actions {
  opacity: 0.9;
}

.score {
  color: var(--good);
  font-size: 10px;
  font-weight: 560;
}

.detail-link {
  color: var(--accent);
  font-size: 11px;
  font-weight: 620;
}

.detail-link.is-disabled,
.source-pill.is-disabled {
  pointer-events: none;
  opacity: 0.58;
}

.card-favorite-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 620;
}

.card-favorite-button:hover:not(:disabled) {
  color: var(--text);
}

.card-favorite-button.is-favorite {
  color: var(--accent);
}

.card-favorite-button:disabled {
  color: var(--disabled);
  cursor: default;
}

.favorite-remove-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--muted);
  line-height: 1;
}

.favorite-remove-button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  color: var(--danger);
}

.favorite-sync-shell {
  width: min(960px, calc(100% - 32px));
}

.favorite-sync-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
  padding: 16px;
}

.favorite-sync-form {
  display: grid;
  gap: 12px;
}

.favorite-sync-field {
  grid-template-columns: 112px minmax(0, 1fr);
  min-height: 64px;
}

.settings-select-field.favorite-sync-field {
  grid-template-columns: 72px minmax(0, 1fr);
}

.favorite-sync-field-wide {
  grid-column: 1 / -1;
}

.favorite-sync-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, auto);
  gap: 12px;
  align-items: center;
}

.favorite-sync-check {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}

.favorite-sync-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.favorite-sync-target {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.favorite-sync-target-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: color-mix(in srgb, var(--surface-muted) 76%, transparent);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.favorite-sync-target-summary[data-tone="warning"] {
  border-color: color-mix(in srgb, var(--warning) 36%, var(--line));
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
  color: var(--text);
}

.favorite-sync-target[hidden] {
  display: none;
}

.favorite-sync-target-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.favorite-sync-small-button,
.favorite-sync-action-button,
.favorite-sync-danger-button {
  min-height: 42px;
  white-space: nowrap;
}

.favorite-sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.favorite-sync-main-button {
  min-height: 48px;
  padding: 0 22px;
}

.favorite-sync-main-button.is-dirty {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning, #c58b2c) 24%, transparent);
}

.favorite-sync-preview {
  display: grid;
  gap: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 8px;
  padding: 12px;
  background: color-mix(in srgb, var(--surface) 90%, var(--accent));
}

.favorite-sync-preview[hidden] {
  display: none;
}

.favorite-sync-preview-title {
  margin: 0;
  font-size: 16px;
}

.favorite-sync-preview-target,
.favorite-sync-preview-description {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.favorite-sync-preview-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.favorite-sync-preview-summary div {
  display: grid;
  gap: 3px;
}

.favorite-sync-preview-summary dt {
  color: var(--muted);
  font-size: 12px;
}

.favorite-sync-preview-summary dd {
  margin: 0;
  font-size: 18px;
  font-weight: 780;
}

.favorite-sync-helper {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  word-break: break-all;
}

.favorite-sync-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.favorite-sync-preview-confirm,
.favorite-sync-preview-cancel {
  min-height: 40px;
}

@media (max-width: 640px) {
  .favorite-sync-preview-summary {
    grid-template-columns: 1fr;
  }

  .favorite-sync-preview-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .favorite-sync-preview-confirm,
  .favorite-sync-preview-cancel {
    width: 100%;
    justify-content: center;
  }
}

.favorite-sync-danger-button {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--line));
  color: var(--danger);
}

.favorite-sync-status {
  min-height: 20px;
}

.favorite-sync-inline-action {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-left: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--field);
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
}

.favorite-sync-inline-action:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: var(--control-hover);
}

.favorite-undo-toast {
  position: fixed;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 260;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px 10px 14px;
  background: color-mix(in srgb, var(--surface-solid) 94%, var(--bg));
  color: var(--text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
  font-size: 13px;
  font-weight: 720;
  line-height: 1.4;
}

.favorite-undo-toast[hidden] {
  display: none;
}

.favorite-undo-toast span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favorite-undo-toast .empty-action-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 30px;
}

.pagination button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.pagination button.is-retry {
  width: auto;
  min-width: 74px;
  grid-auto-flow: column;
  gap: 6px;
  padding: 0 12px;
}

.pagination-label {
  font-size: 12px;
  font-weight: 780;
}

.pagination button:hover:not(:disabled) {
  background: var(--control-hover);
}

.pagination button:disabled {
  color: var(--disabled);
  cursor: not-allowed;
}

.pagination svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

#pageStatus {
  min-width: 84px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 720;
}

.empty {
  display: grid;
  grid-column: 1 / -1;
  justify-items: center;
  gap: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 42px 20px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  backdrop-filter: blur(16px);
}

.empty p {
  margin: 0;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.empty-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0 16px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 720;
  text-decoration: none;
}

.empty-action-button:hover {
  filter: brightness(1.05);
}

.empty-action-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.detail-shell {
  max-width: 1180px;
  --detail-media-height: min(58vh, 540px);
}

.detail-shell .topbar > :first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.detail-shell #detailTitle {
  display: -webkit-box;
  overflow: hidden;
  font-size: 28px;
  line-height: 1.16;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.detail-status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.detail-status-strip[hidden] {
  display: none;
}

.detail-status-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.detail-status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--field);
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  line-height: 1;
  white-space: nowrap;
}

.detail-status-chip[data-tone="good"] {
  border-color: rgba(74, 138, 104, 0.26);
  background: rgba(74, 138, 104, 0.12);
  color: var(--good);
}

.detail-status-chip[data-tone="warn"],
.detail-status-chip[data-tone="info"] {
  border-color: rgba(184, 79, 56, 0.26);
  background: var(--accent-soft);
  color: var(--accent);
}

.detail-status-chip[data-tone="danger"] {
  border-color: rgba(184, 79, 56, 0.32);
  background: rgba(184, 79, 56, 0.14);
  color: var(--danger);
}

.detail-status-chip[data-tone="time"] {
  color: var(--text);
}

.captcha-card {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(280px, 1.2fr);
  gap: 18px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.captcha-card[hidden] {
  display: none;
}

.captcha-copy h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.15;
}

.captcha-copy p,
.captcha-empty,
.captcha-image-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.captcha-form {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.captcha-image {
  width: min(100%, 360px);
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.captcha-fields {
  display: grid;
  gap: 10px;
}

.captcha-field {
  display: grid;
  gap: 6px;
}

.captcha-field span {
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 620;
}

.captcha-field input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  outline: none;
}

.captcha-field input:focus {
  border-color: rgba(240, 68, 68, 0.58);
  box-shadow: 0 0 0 3px rgba(240, 68, 68, 0.12);
}

.captcha-error {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.45;
}

.captcha-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(220px, 0.5fr);
  gap: 20px;
  align-items: start;
}

.detail-layout.is-heiliao-detail {
  grid-template-columns: minmax(0, 2fr) minmax(220px, 0.5fr);
}

.detail-media {
  position: relative;
  overflow: hidden;
  min-height: var(--detail-media-height);
  max-height: var(--detail-media-height);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: var(--surface-strong);
  box-shadow: var(--image-shadow);
}

.detail-media video,
.detail-media img {
  width: 100%;
  height: var(--detail-media-height);
  max-height: var(--detail-media-height);
  display: block;
  aspect-ratio: auto;
  object-fit: contain;
}

.detail-media video {
  background: #000;
}

.detail-media.is-poster-overlay #detailPoster {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-height: none;
  background: #000;
  object-fit: contain;
  pointer-events: none;
}

.detail-media.is-poster-overlay #detailPoster[hidden] {
  display: none;
}

.detail-media.is-plyr-enabled {
  --plyr-color-main: #f04444;
  --plyr-control-radius: 7px;
}

.detail-media.is-plyr-enabled .play-button {
  display: none;
}

.detail-media.is-plyr-enabled .plyr {
  width: 100%;
  height: var(--detail-media-height);
  max-height: var(--detail-media-height);
  background: #000;
}

.detail-media.is-plyr-enabled .plyr__video-wrapper,
.detail-media.is-plyr-enabled .plyr__poster {
  width: 100%;
  height: 100%;
  background-color: #000;
}

.detail-media.is-plyr-enabled .plyr__poster {
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.detail-media.is-plyr-enabled video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.detail-media.is-local-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  border: 0;
  border-radius: 0;
  display: grid;
  place-items: center;
  background: #000;
}

.detail-media.is-local-fullscreen video {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  object-fit: contain;
}

.media-toolbar {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  gap: 8px;
  opacity: 0.78;
  transition: opacity 160ms ease;
}

.detail-media:hover .media-toolbar,
.detail-media:focus-within .media-toolbar {
  opacity: 1;
}

@media (hover: none), (pointer: coarse) {
  .media-toolbar {
    opacity: 1;
  }
}

.media-toolbar button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(0, 0, 0, 0.48);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 620;
  backdrop-filter: blur(10px);
}

.media-toolbar button:hover {
  background: rgba(0, 0, 0, 0.84);
}

.media-toolbar button:active {
  background: var(--overlay-control-active);
  color: #fff;
}

.media-notice {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  max-width: min(520px, calc(100% - 210px));
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.56);
  color: #fff;
  font-size: 12px;
  font-weight: 620;
  line-height: 1.45;
  backdrop-filter: blur(12px);
}

.media-notice[data-tone="good"] {
  border-color: rgba(139, 191, 147, 0.36);
  color: #d5f3dc;
}

.media-notice[data-tone="warn"] {
  border-color: rgba(240, 143, 114, 0.42);
  color: #ffd8ca;
}

.download-status {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  max-width: min(440px, calc(100% - 28px));
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  backdrop-filter: blur(12px);
}

.download-status[data-tone="good"] {
  border-color: rgba(139, 191, 147, 0.36);
  color: #d5f3dc;
}

.download-status[data-tone="warn"] {
  border-color: rgba(240, 143, 114, 0.42);
  color: #ffd8ca;
}

.download-status-action {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-left: 6px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font: inherit;
}

.download-status-action:hover {
  background: rgba(255, 255, 255, 0.2);
}

.compact-player-body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background: #000;
}

.compact-player-shell {
  position: fixed;
  inset: 0;
  background: #000;
}

.compact-player-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(720px, calc(100vw - 24px));
  padding: 8px 9px 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(10, 12, 16, 0.58);
  color: #fff;
  pointer-events: auto;
  backdrop-filter: blur(12px);
}

.compact-player-title {
  min-width: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-detail-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.compact-detail-link:hover {
  background: rgba(255, 255, 255, 0.22);
}

.compact-player-shell video {
  width: 100vw;
  height: 100vh;
  display: block;
  background: #000;
  object-fit: contain;
}

.compact-player-shell.is-plyr-enabled {
  --plyr-color-main: #f04444;
  --plyr-control-radius: 7px;
}

.compact-player-shell.is-plyr-enabled .plyr {
  width: 100vw;
  height: 100vh;
  background: #000;
}

.compact-player-shell.is-plyr-enabled .plyr__video-wrapper,
.compact-player-shell.is-plyr-enabled video {
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

.compact-error {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 16px;
  z-index: 2;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(10, 12, 16, 0.78);
  color: #fff;
  font-size: 13px;
  text-align: center;
  backdrop-filter: blur(12px);
}

.compact-error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.compact-error-action {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
}

.compact-error-action:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.compact-error-action:disabled {
  opacity: 0.62;
  cursor: wait;
}

@media (max-height: 360px) {
  .compact-player-overlay {
    top: 8px;
    max-width: min(560px, calc(100vw - 16px));
    padding: 6px 7px 6px 9px;
  }

  .compact-player-title {
    font-size: 12px;
  }

  .compact-detail-link {
    min-height: 24px;
    padding: 0 8px;
  }
}

.play-button {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  width: 70px;
  height: 70px;
  margin: auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--surface-strong);
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
  transition: transform 160ms ease, background 160ms ease;
}

.play-button:hover {
  background: #fff;
  transform: scale(1.04);
}

.play-button span {
  width: 0;
  height: 0;
  margin-left: 6px;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  border-left: 24px solid currentColor;
}

.play-button[hidden] {
  display: none;
}

.media-error {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 46px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(10, 12, 16, 0.74);
  color: #fff;
  font-size: 13px;
  backdrop-filter: blur(12px);
}

.media-error[hidden] {
  display: none;
}

#mediaErrorText {
  min-width: 0;
}

.media-retry-button {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.media-retry-button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.24);
}

.media-retry-button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.media-retry-button[hidden] {
  display: none;
}

.detail-panel,
.comments-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.detail-panel {
  display: flex;
  flex-direction: column;
  height: var(--detail-media-height);
  max-height: calc(100vh - 152px);
  min-height: 0;
  overflow: auto;
  padding: 12px;
  opacity: 0.9;
}

.detail-overview {
  display: grid;
  gap: 8px;
}

.detail-panel-heading {
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
  line-height: 1.3;
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 0;
}

.detail-stats div {
  min-width: 0;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.detail-stats div:last-child {
  border-bottom: 0;
}

.detail-stats dt {
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 560;
}

.detail-stats dd {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 580;
  overflow-wrap: anywhere;
  text-align: right;
}

.detail-stats-primary dd {
  color: var(--text);
  font-weight: 660;
}

.detail-data-section {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.detail-data-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 680;
  list-style: none;
}

.detail-data-section summary::-webkit-details-marker {
  display: none;
}

.detail-data-section summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 140ms ease;
}

.detail-data-section[open] summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.detail-data-section[open] .detail-stats-secondary {
  margin-top: 4px;
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.detail-side-section {
  flex: 0 0 auto;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.description-section {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}

.detail-segments-section {
  display: grid;
  gap: 8px;
}

.detail-segments-section[hidden] {
  display: none;
}

.detail-segments {
  display: grid;
  gap: 7px;
  max-height: clamp(90px, 18vh, 132px);
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.detail-segments::-webkit-scrollbar {
  width: 6px;
}

.detail-segments::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line-strong);
}

.detail-segment-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--field);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
}

.detail-segment-button::after {
  content: "播放";
  flex: 0 0 auto;
  margin-left: 8px;
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 680;
}

.detail-segment-button[aria-pressed="true"] {
  border-color: rgba(74, 138, 104, 0.3);
  background: rgba(74, 138, 104, 0.12);
  color: var(--good);
}

.detail-segment-button[aria-pressed="true"]::after {
  content: "当前";
  color: var(--good);
}

.detail-segment-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.detail-side-section h2 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  font-weight: 660;
}

.description-body {
  margin-top: 8px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.description-body::-webkit-scrollbar {
  width: 6px;
}

.description-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line-strong);
}

.detail-side-section p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.heiliao-article {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.heiliao-article-head {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.heiliao-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 620;
}

.heiliao-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: var(--field);
}

.heiliao-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.heiliao-chip-list a,
.heiliao-chip-list span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  text-decoration: none;
}

.heiliao-chip-list a:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.heiliao-segments {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.heiliao-segment-button,
.heiliao-video-jump {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--surface-solid);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.heiliao-segment-button[aria-pressed="true"],
.heiliao-video-jump:hover,
.heiliao-segment-button:hover {
  border-color: rgba(240, 68, 68, 0.42);
  background: var(--accent-soft);
  color: var(--accent);
}

.heiliao-content {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.heiliao-content h2 {
  margin: 8px 0 0;
  color: var(--text);
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.35;
  letter-spacing: 0;
}

.heiliao-content p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.78;
  white-space: pre-wrap;
}

.heiliao-content figure {
  display: grid;
  gap: 7px;
  margin: 0;
}

.heiliao-content img {
  display: block;
  width: 100%;
  max-height: 78vh;
  border-radius: 8px;
  object-fit: contain;
  background: #050505;
}

.heiliao-image-fallback {
  display: grid;
  min-height: 96px;
  place-items: center;
  border: 1px dashed color-mix(in srgb, var(--border) 74%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-muted) 84%, transparent);
  color: var(--muted-soft);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.heiliao-image-fallback[hidden] {
  display: none;
}

.heiliao-content figcaption {
  color: var(--muted-soft);
  font-size: 12px;
  text-align: center;
}

.heiliao-video-jump {
  justify-self: start;
  margin: 2px 0;
}

.heiliao-tags {
  padding: 0 16px 16px;
}

.comments-section {
  margin-top: clamp(56px, 14vh, 128px);
  padding: 15px 16px;
  opacity: 0.86;
}

.comments-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.comments-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.3;
  font-weight: 680;
}

.comments-heading span {
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 560;
}

.comments-list {
  display: grid;
  gap: 9px;
}

.comment-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--field);
}

.comment-item header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

.comment-item strong,
.comment-item a {
  color: var(--text);
  font-size: 13px;
  font-weight: 660;
}

.comment-item header span {
  overflow: hidden;
  color: var(--muted-soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-item p,
.comments-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.happy-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
}

.happy-settings-hover-zone {
  position: fixed;
  z-index: 20;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 8px;
}

.happy-settings-button {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.happy-settings-button {
  width: 42px;
  height: 42px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.34),
    0 12px 28px rgba(0, 0, 0, 0.28);
}

.happy-settings-button:hover {
  background: rgba(0, 0, 0, 0.82);
}

.happy-settings-button:focus-visible,
.happy-card-button:focus-visible,
.happy-panel-button:focus-visible,
.happy-count-stepper input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
}

.happy-settings-button svg,
.happy-card-button svg,
.happy-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.happy-settings-panel {
  position: relative;
  z-index: 21;
  display: grid;
  width: min(304px, calc(100vw - 28px));
  max-height: calc(100vh - 86px);
  gap: 12px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 14px;
  padding: 12px;
  background: rgba(10, 10, 10, 0.86);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.36),
    0 20px 48px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
}

.happy-settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}

.happy-settings-heading span:first-child {
  color: rgba(255, 255, 255, 0.94);
  font-size: 14px;
  font-weight: 780;
}

.happy-settings-heading span:last-child {
  color: rgba(255, 255, 255, 0.54);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.happy-count-block {
  display: grid;
  gap: 8px;
}

.happy-setting-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 0 2px;
}

.happy-setting-field span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 680;
}

.happy-setting-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 8px;
}

.happy-count-stepper input {
  width: 100%;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-align: center;
}

.happy-count-stepper .happy-panel-button {
  min-height: 38px;
  padding: 0;
}

.happy-count-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.happy-count-preset-button {
  min-height: 34px;
  padding: 0 8px;
}

.happy-count-preset-button[aria-pressed="true"] {
  border-color: rgba(224, 122, 85, 0.72);
  background: rgba(224, 122, 85, 0.72);
}

.happy-settings-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.happy-panel-button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 720;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.happy-panel-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.happy-panel-button:active:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateY(1px);
}

.happy-panel-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.happy-confirm-button {
  border-color: rgba(224, 122, 85, 0.72);
  background: rgba(224, 122, 85, 0.72);
}

.happy-confirm-button:hover:not(:disabled) {
  background: rgba(224, 122, 85, 0.9);
}

.happy-exit-button {
  width: 100%;
  min-height: 40px;
  background: rgba(184, 79, 56, 0.72);
}

.happy-exit-button:hover {
  background: rgba(184, 79, 56, 0.9);
}

.happy-captcha-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 30;
  display: grid;
  width: min(640px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  grid-template-columns: minmax(0, 0.85fr) minmax(240px, 1.15fr);
  gap: 16px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 12px;
  padding: 16px;
  background: rgba(10, 10, 10, 0.9);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 24px 80px rgba(0, 0, 0, 0.68);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(20px);
}

.happy-captcha-panel[hidden] {
  display: none;
}

.happy-captcha-panel .captcha-copy h2 {
  color: #fff;
}

.happy-captcha-panel .captcha-copy p,
.happy-captcha-panel .captcha-field span {
  color: rgba(255, 255, 255, 0.68);
}

.happy-captcha-panel .captcha-field input {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.happy-captcha-panel .captcha-error {
  color: #ff9b7a;
}

.happy-actions {
  align-items: center;
}

.happy-control-button svg {
  width: 17px;
  height: 17px;
}

.happy-grid {
  display: grid;
  width: 100vw;
  height: 100vh;
  grid-template-columns: repeat(var(--happy-columns, 4), minmax(0, 1fr));
  grid-template-rows: repeat(var(--happy-rows, 2), minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: #050505;
}

.happy-grid.is-speaker-mode {
  grid-template-columns: minmax(0, 1fr) minmax(128px, clamp(150px, 17vw, 230px));
  grid-template-rows: repeat(var(--happy-side-count, 1), minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
}

.happy-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.34);
}

.happy-card.is-expanded {
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.72),
    0 24px 80px rgba(0, 0, 0, 0.82);
}

.happy-grid.is-speaker-mode .happy-card {
  grid-column: 2;
  border-radius: 7px;
  opacity: 0.78;
}

.happy-grid.is-speaker-mode .happy-card.is-expanded {
  grid-column: 1;
  grid-row: 1 / -1;
  z-index: 2;
  opacity: 1;
}

.happy-media {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background: #000;
}

.happy-card-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: flex;
  gap: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.happy-card.is-controllable:hover .happy-card-controls,
.happy-card.is-controllable:focus-within .happy-card-controls,
.happy-card.is-error .happy-card-controls,
.happy-card.is-expanded .happy-card-controls {
  opacity: 1;
  pointer-events: auto;
}

.happy-grid.is-speaker-mode .happy-card:not(.is-expanded) .happy-card-controls {
  top: 6px;
  right: 6px;
  gap: 4px;
}

.happy-grid.is-speaker-mode .happy-card:not(.is-expanded) .happy-card-button {
  min-width: 28px;
  width: auto;
  height: 28px;
  padding: 0 6px;
  font-size: 10px;
}

.happy-grid.is-speaker-mode .happy-card:not(.is-expanded) .happy-card-sound-button,
.happy-grid.is-speaker-mode .happy-card:not(.is-expanded) .happy-card-random-button {
  min-width: 34px;
}

.happy-grid.is-speaker-mode .happy-card:not(.is-expanded) .happy-card-speed-button {
  min-width: 34px;
  padding: 0 6px;
}

.happy-card.is-controllable .happy-media {
  cursor: pointer;
}

.happy-card.is-controllable .happy-card-controls {
  cursor: default;
}

.happy-card-button {
  display: grid;
  min-width: 36px;
  width: auto;
  height: 36px;
  padding: 0 8px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.34),
    0 10px 24px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(14px);
  transition: background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.happy-card-button:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(0, 0, 0, 0.82);
}

.happy-card-button:active:not(:disabled) {
  background: var(--overlay-control-active);
  color: #fff;
}

.happy-card-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.happy-card-button.is-busy {
  cursor: progress;
  opacity: 0.74;
}

.happy-download-button:disabled,
.happy-card-sound-button:disabled,
.happy-card-speed-button:disabled {
  display: none;
}

.happy-card-random-button {
  min-width: 36px;
  width: 36px;
  padding: 0;
}

.happy-card-favorite-button.is-favorite {
  border-color: rgba(224, 122, 85, 0.72);
  background: rgba(224, 122, 85, 0.82);
}

.happy-card-speed-button {
  min-width: 42px;
  width: auto;
  padding: 0 9px;
}

.happy-media::after {
  content: none;
}

.happy-player,
.happy-poster,
.happy-loader {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.happy-player,
.happy-poster {
  display: block;
  object-fit: contain;
  background: #000;
}

.happy-player {
  z-index: 2;
  opacity: 0;
  transition: opacity 140ms ease;
}

.happy-poster {
  z-index: 1;
}

.happy-card.is-ready .happy-player {
  opacity: 1;
}

.happy-loader {
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.34));
  transition: opacity 140ms ease;
}

.happy-loader::before {
  content: "";
  width: clamp(24px, 7vmin, 42px);
  height: clamp(24px, 7vmin, 42px);
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  animation: happy-loader-spin 760ms linear infinite;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.34);
}

.happy-card.is-loading .happy-loader,
.happy-card.is-buffering .happy-loader {
  opacity: 1;
}

.happy-card.is-playback-queued .happy-loader {
  opacity: 0;
}

.happy-card.is-ready:not(.is-buffering) .happy-loader,
.happy-card.is-error .happy-loader {
  opacity: 0;
}

.happy-card-status {
  position: absolute;
  left: 50%;
  bottom: clamp(38px, 8vmin, 56px);
  z-index: 5;
  max-width: min(72%, 180px);
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(9, 10, 12, 0.64);
  color: rgba(255, 255, 255, 0.92);
  font-size: clamp(11px, 1.9vmin, 13px);
  font-weight: 760;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.happy-card-status[hidden] {
  display: none;
}

.happy-card.is-error,
.happy-card.is-error .happy-card-status {
  cursor: pointer;
}

.happy-player[hidden],
.happy-poster[hidden] {
  display: none;
}

@keyframes happy-loader-spin {
  to {
    transform: rotate(360deg);
  }
}

.happy-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.88);
  font-size: 10px;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.happy-duration {
  z-index: 3;
}

.happy-body {
  padding: 10px 11px 11px;
}

.happy-card .title-row h2 {
  -webkit-line-clamp: 2;
}

.happy-card-error {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 12px;
  line-height: 1.45;
}

.happy-card.is-error .happy-media {
  background:
    linear-gradient(135deg, rgba(184, 79, 56, 0.22), transparent),
    #111;
}

.ai-source-shell {
  width: min(1120px, calc(100% - 32px));
}

.ai-source-workbench,
.ai-source-result {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.ai-source-workbench {
  padding: 16px;
}

.ai-source-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 12px;
  align-items: end;
}

.ai-source-field {
  grid-template-columns: 120px minmax(0, 1fr);
  min-height: 72px;
}

.settings-select-field.ai-source-field {
  grid-template-columns: 64px minmax(0, 1fr);
}

.ai-source-field input,
.ai-source-field textarea {
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.ai-source-field-wide {
  grid-column: 1 / -1;
}

.ai-source-json-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.ai-source-json-field {
  min-height: 58px;
}

.ai-source-json-field textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: var(--surface-solid);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
  outline: none;
}

.ai-source-json-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ai-source-paste-json-button {
  width: 42px;
  min-width: 42px;
  height: 38px;
  padding: 0;
  white-space: nowrap;
}

.ai-source-paste-json-button span {
  display: none;
}

.ai-source-key-field {
  min-width: 0;
}

.ai-source-key-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}

.ai-source-key-button {
  height: 38px;
  min-width: 72px;
  padding: 0 10px;
  white-space: nowrap;
}

.ai-source-model-field {
  min-width: 0;
}

.ai-source-model-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.ai-source-fetch-models-button {
  height: 38px;
  margin-bottom: 0;
  white-space: nowrap;
}

.ai-source-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
}

.ai-source-actions #analyzeButton {
  height: 64px;
  min-width: 220px;
  padding: 0 36px;
  font-size: 18px;
  font-weight: 780;
}

.ai-source-actions #analyzeButton svg {
  width: 22px;
  height: 22px;
}

.ai-source-cancel-button {
  min-height: 42px;
  padding: 0 14px;
  white-space: nowrap;
}

.settings-status[data-tone="success"] {
  color: var(--good);
}

.settings-status[data-tone="error"] {
  color: var(--accent);
}

.settings-status[data-tone="loading"] {
  color: var(--muted);
}

.settings-status[data-tone="warning"],
.source-settings-status[data-tone="warning"] {
  color: var(--warning, #b9772e);
}

.ai-source-result {
  display: grid;
  gap: 16px;
  margin-top: 16px;
  padding: 18px;
}

.source-settings-ai-result {
  margin: 16px 0 12px;
}

.ai-source-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.ai-source-result-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 760;
  letter-spacing: 0;
}

.ai-source-result-head h2[data-level="not_recommended"] {
  color: var(--accent);
}

.ai-source-result-head h2[data-level="suggested"] {
  color: var(--good);
}

.ai-source-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ai-source-save-slot {
  display: grid;
  gap: 12px;
}

.ai-source-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--field);
}

.ai-source-panel-wide {
  grid-column: 1 / -1;
}

.ai-source-panel h3,
.ai-source-subsection h4 {
  margin: 0;
  color: var(--text);
  font-weight: 750;
  letter-spacing: 0;
}

.ai-source-panel h3 {
  font-size: 16px;
}

.ai-source-subsection h4 {
  font-size: 13px;
}

.ai-source-definition-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.ai-source-definition-list dt {
  color: var(--muted-soft);
  font-weight: 720;
}

.ai-source-definition-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.ai-source-stack,
.ai-source-subsection {
  display: grid;
  gap: 10px;
}

.ai-source-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.ai-source-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
  overflow-wrap: anywhere;
}

.ai-source-link-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ai-source-link-list a {
  overflow-wrap: anywhere;
  color: var(--text);
}

.ai-source-muted,
.ai-source-error {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ai-source-error {
  color: var(--accent);
}

.ai-source-json {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ai-source-json-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.025);
  overflow: hidden;
}

.ai-source-json-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px 0 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.ai-source-json-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-source-json-copy {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.ai-source-json-block .ai-source-json {
  max-height: 330px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

:root[data-theme="dark"] .ai-source-json {
  background: rgba(255, 255, 255, 0.035);
}

:root[data-theme="dark"] .ai-source-json-block {
  background: rgba(255, 255, 255, 0.026);
}

.ai-source-draft-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ai-source-draft-summary strong,
.ai-source-draft-summary span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.ai-source-draft-summary strong {
  color: var(--text);
}

.ai-source-save {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.ai-source-save-grid {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) 72px auto;
  gap: 10px;
  align-items: end;
}

.ai-source-save-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.ai-source-save-field span {
  color: var(--muted-soft);
  font-size: 12px;
  font-weight: 720;
}

.ai-source-save-field input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.ai-source-save-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ai-source-save-button {
  height: 38px;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .interface-source-form {
    grid-template-columns: minmax(120px, 0.8fr) minmax(150px, 0.9fr) minmax(220px, 1.5fr) 64px 108px 70px;
    gap: 8px;
  }

  .source-settings-list-header,
  .source-settings-row {
    grid-template-columns: 112px minmax(108px, 0.72fr) 126px 76px 62px;
    gap: 7px;
  }

  .source-settings-row {
    padding: 9px 10px;
  }

  .source-settings-badge {
    display: inline-flex;
  }

  .source-settings-actions {
    gap: 5px;
  }

  .source-settings-button {
    padding: 0 5px;
  }

  .controls {
    grid-template-columns: minmax(220px, 1fr) 170px;
  }

  .home-controls {
    grid-template-columns: 168px minmax(0, 1fr) 154px;
  }

  .sort-field {
    grid-column: 1 / -1;
  }

  .video-grid {
    --video-grid-columns: 5;
    --video-grid-row-gap: 16px;
    --video-grid-column-gap: 10px;
  }

  .video-grid[data-card-size="large"] {
    --video-grid-columns: 3;
    --video-grid-row-gap: 18px;
    --video-grid-column-gap: 12px;
  }

  .video-grid[data-card-size="small"] {
    --video-grid-columns: 6;
    --video-grid-row-gap: 14px;
    --video-grid-column-gap: 8px;
  }

  .happy-grid {
    grid-template-columns: repeat(var(--happy-columns, 4), minmax(0, 1fr));
  }

  .ai-source-form,
  .ai-source-result-grid {
    grid-template-columns: 1fr;
  }

  .ai-source-panel-wide {
    grid-column: auto;
  }
}

@media (max-width: 860px) {
  .interface-source-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 68px 112px 70px;
    grid-template-areas:
      "heading heading adult button cancel"
      "name api api api api";
    align-items: stretch;
  }

  .interface-source-heading {
    grid-area: heading;
  }

  .interface-source-field:first-of-type {
    grid-area: name;
  }

  .interface-source-api-field {
    grid-area: api;
  }

  .interface-source-adult-check {
    grid-area: adult;
  }

  #saveInterfaceSourceButton {
    grid-area: button;
    align-self: end;
  }

  .interface-source-cancel-button {
    grid-area: cancel;
    align-self: end;
  }

  .source-settings-row {
    align-items: stretch;
  }

  .source-settings-list-header {
    display: none;
  }

  .source-settings-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 88px;
    grid-template-areas:
      "source status check"
      "endpoints endpoints endpoints"
      "actions actions actions";
    gap: 8px 10px;
    min-height: 0;
    padding: 12px;
  }

  .source-settings-source {
    grid-area: source;
  }

  .source-settings-endpoints {
    grid-area: endpoints;
  }

  .source-settings-field input {
    height: 36px;
    font-size: 12px;
  }

  .source-settings-actions {
    grid-area: actions;
    grid-template-columns: repeat(3, minmax(64px, max-content));
    justify-content: start;
  }

  .source-settings-actions .source-settings-button {
    min-width: 64px;
    padding: 0 8px;
  }

  .source-settings-row > [data-source-action="check"] {
    min-width: 64px;
    padding: 0 8px;
  }

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

  .source-settings-connectivity-status {
    grid-area: status;
    align-self: center;
    justify-self: end;
    text-align: right;
  }

  .source-settings-row > [data-source-action="check"] {
    grid-area: check;
    align-self: center;
  }

  .source-settings-toolbar-actions {
    display: flex;
    width: auto;
  }

  .source-settings-log-header {
    align-items: stretch;
    flex-direction: column;
  }

  .source-settings-log-header .source-settings-toolbar-actions {
    flex-wrap: wrap;
    justify-content: start;
  }

  .source-settings-log-entry-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .source-settings-log-entry time {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 520px);
    padding-top: 20px;
  }

  .source-settings-toast {
    top: auto;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    width: auto;
    min-width: 0;
    transform: translateY(10px);
  }

  .source-settings-toast.is-visible {
    transform: translateY(0);
  }

  .source-settings-toolbar {
    position: static;
    display: flex;
    align-items: stretch;
  }

  #sourceSettingsSummary {
    flex: 1 0 100%;
    min-width: 0;
  }

  .source-settings-search {
    flex: 1 0 100%;
    min-width: 0;
  }

  .source-settings-toolbar > .source-settings-toolbar-actions {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .source-settings-toolbar > .source-settings-toolbar-actions > * {
    flex: 0 0 auto;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .home-brand-image {
    width: min(260px, 100%);
  }

  .detail-shell #detailTitle {
    font-size: 24px;
  }

  .topbar-title {
    gap: 9px;
  }

  .topbar p {
    font-size: 12px;
  }

  .source-pill {
    width: fit-content;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    padding: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
    scrollbar-width: none;
  }

  .topbar-actions::-webkit-scrollbar {
    display: none;
  }

  .topbar-actions > * {
    flex: 0 0 auto;
  }

  .detail-shell .topbar-actions {
    box-shadow: var(--shadow);
  }

  .home-settings {
    position: sticky;
    left: 0;
    z-index: 5;
    order: -1;
    margin-left: 0;
  }

  .settings-panel {
    position: fixed;
    top: 76px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100vh - 96px);
    overflow: auto;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .settings-panel .settings-heading {
    position: sticky;
    top: -12px;
    z-index: 2;
    margin: -12px -12px 0;
    padding: 12px 12px 10px;
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--surface-solid) 92%, transparent), color-mix(in srgb, var(--surface-solid) 82%, transparent)),
      var(--surface-solid);
    backdrop-filter: blur(18px);
  }

  .interface-source-form {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "heading"
      "name"
      "api"
      "adult"
      "button"
      "cancel";
  }

  .source-settings-interface-header {
    align-items: stretch;
    flex-direction: column;
  }

  .source-settings-interface-dialog .interface-source-form {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "name"
      "api"
      "adult"
      "button"
      "cancel"
      "status";
    align-items: stretch;
  }

  .source-settings-interface-dialog .interface-source-adult-check {
    justify-content: flex-start;
  }

  .source-settings-interface-dialog #saveInterfaceSourceButton {
    width: 100%;
  }

  .source-settings-interface-dialog .interface-source-cancel-button {
    width: 100%;
  }

  .controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .home-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  body.is-mobile-filter-open {
    overflow: hidden;
  }

  .mobile-filter-button:not([hidden]) {
    position: fixed;
    right: auto;
    bottom: calc(env(safe-area-inset-bottom) + 14px);
    left: calc(env(safe-area-inset-left) + 14px);
    z-index: 72;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 96px;
    min-height: 46px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 0 16px;
    background: var(--accent);
    color: var(--accent-contrast);
    box-shadow: var(--shadow);
    font: inherit;
    font-size: 14px;
    font-weight: 780;
    cursor: pointer;
  }

  .mobile-filter-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
  }

  .mobile-filter-button:focus-visible {
    outline: none;
    box-shadow: var(--shadow), 0 0 0 3px var(--accent-soft);
  }

  .mobile-filter-backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 78;
    display: block;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(8px);
  }

  .mobile-filter-sheet:not([hidden]) {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 79;
    display: grid;
    gap: 12px;
    max-height: min(82vh, 640px);
    border: 1px solid var(--line-strong);
    border-radius: 20px 20px 0 0;
    padding: 14px 14px calc(env(safe-area-inset-bottom) + 16px);
    background: var(--surface-solid);
    box-shadow: var(--shadow);
    overflow: auto;
  }

  .mobile-filter-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-filter-sheet-head h2 {
    margin: 0;
    color: var(--text);
    font-size: 18px;
    line-height: 1.2;
  }

  .mobile-filter-summary {
    margin: -4px 0 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 10px;
    background: var(--field);
    color: var(--muted);
    font-size: 12px;
    font-weight: 720;
    line-height: 1.4;
  }

  .mobile-filter-slot {
    min-width: 0;
  }

  .mobile-filter-slot .home-controls {
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .mobile-filter-slot .home-controls .search-box {
    width: 100%;
  }

  .search-box,
  .sort-field {
    grid-column: 1 / -1;
  }

  .home-controls .search-box,
  .home-controls .source-select-box,
  .home-controls .sort-select,
  .home-controls .category-panel,
  .home-controls .search-source-tabs {
    grid-column: 1 / -1;
  }

  .controls > .select-box {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .sort-field {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    grid-row: 3;
  }

  .sort-buttons {
    gap: 7px;
  }

  .sort-button {
    min-width: 54px;
    height: 32px;
    padding: 0 11px;
    font-size: 12px;
  }

  .category-tabs {
    gap: 7px;
  }

  .category-chip {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .summary-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    margin: 14px 0 14px;
  }

  .captcha-card {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .captcha-copy h2 {
    font-size: 21px;
  }

  .api-actions,
  .api-link {
    max-width: 100%;
  }

  .video-grid {
    --video-grid-columns: 3;
    --video-grid-row-gap: 14px;
    --video-grid-column-gap: 8px;
  }

  .video-grid[data-card-size="large"] {
    --video-grid-columns: 2;
    --video-grid-row-gap: 16px;
    --video-grid-column-gap: 10px;
  }

  .video-grid[data-card-size="small"] {
    --video-grid-columns: 4;
    --video-grid-row-gap: 12px;
    --video-grid-column-gap: 7px;
  }

  .search-source-tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 10px 2px;
    scrollbar-width: thin;
  }

  .search-source-tabs.has-overflow {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 18px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 18px), transparent);
  }

  .search-source-tabs-label {
    flex: 0 0 auto;
    align-self: center;
  }

  .search-source-tab {
    flex: 0 0 auto;
    min-width: 86px;
  }

  .back-to-top-button {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    width: 52px;
    min-width: 52px;
    height: 52px;
    border-radius: 14px;
    padding: 0;
  }

  .happy-shell {
    width: 100vw;
    height: 100vh;
  }

  .happy-grid {
    grid-template-columns: repeat(var(--happy-columns, 4), minmax(0, 1fr));
    gap: 2px;
  }

  .happy-grid.is-speaker-mode {
    grid-template-columns: minmax(0, 1fr) minmax(86px, 22vw);
    gap: 3px;
    padding: 4px;
  }

  .happy-grid.is-speaker-mode .happy-card:not(.is-expanded) .happy-card-controls {
    display: none;
  }

  .happy-captcha-panel {
    grid-template-columns: 1fr;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-shell {
    --detail-media-height: min(52vh, 420px);
  }

  .media-toolbar {
    top: auto;
    right: 12px;
    bottom: 12px;
  }

  .media-notice {
    top: 12px;
    right: 12px;
    left: 12px;
    max-width: none;
  }

  .download-status {
    right: 12px;
    bottom: 60px;
    left: 12px;
    max-width: none;
  }

  .detail-panel {
    height: auto;
    max-height: none;
  }

  .detail-stats {
    grid-template-columns: 1fr;
  }

  .comment-item header {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .comment-item header span {
    white-space: normal;
  }

  .ai-source-shell {
    width: min(100% - 24px, 560px);
  }

  .favorite-sync-shell {
    width: min(100% - 24px, 560px);
  }

  .favorite-sync-panel {
    padding: 12px;
  }

  .favorite-sync-field,
  .settings-select-field.favorite-sync-field,
  .favorite-sync-row,
  .favorite-sync-target-head {
    grid-template-columns: 1fr;
  }

  .favorite-sync-check {
    justify-content: flex-start;
  }

  .favorite-sync-main-button,
  .favorite-sync-action-button,
  .favorite-sync-danger-button,
  .favorite-sync-small-button {
    width: 100%;
  }

  .ai-source-result-head {
    flex-direction: column;
  }

  .ai-source-workbench,
  .ai-source-result {
    padding: 12px;
  }

  .ai-source-definition-list {
    grid-template-columns: 1fr;
  }

  .ai-source-field,
  .settings-select-field.ai-source-field,
  .ai-source-json-control,
  .ai-source-key-control,
  .ai-source-model-control {
    grid-template-columns: 1fr;
  }

  .ai-source-save-grid {
    grid-template-columns: 1fr;
  }

  .ai-source-save-button {
    width: 100%;
  }

  .ai-source-key-button {
    width: 100%;
  }

  .ai-source-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-source-actions #analyzeButton {
    width: 100%;
  }

  .ai-source-cancel-button {
    width: 100%;
  }
}

/* 69Video full interface redesign: projection desk */
:root {
  color-scheme: light;
  --font-body: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-display: "DIN Condensed", "Avenir Next Condensed", "PingFang SC", "Microsoft YaHei", sans-serif;
  --bg: #e9e5dc;
  --surface: rgba(251, 248, 239, 0.86);
  --surface-solid: #fbf8ef;
  --surface-strong: #11120f;
  --field: rgba(255, 253, 246, 0.88);
  --text: #171813;
  --muted: #69695e;
  --muted-soft: #8a897d;
  --line: rgba(24, 25, 19, 0.13);
  --line-strong: rgba(24, 25, 19, 0.25);
  --accent: #d64b2a;
  --accent-soft: rgba(214, 75, 42, 0.14);
  --cyan: #1f9aa6;
  --cyan-soft: rgba(31, 154, 166, 0.14);
  --amber: #b77912;
  --amber-soft: rgba(183, 121, 18, 0.14);
  --ink: #11120f;
  --paper: #fbf8ef;
  --good: #237656;
  --danger: #b93a2c;
  --sort-active-bg: #11120f;
  --sort-active-text: #fffaf0;
  --sort-active-pressed-bg: #2a2b24;
  --sort-active-pressed-text: #fffaf0;
  --sort-idle-bg: rgba(255, 253, 246, 0.62);
  --sort-idle-text: #69695e;
  --control-active: rgba(17, 18, 15, 0.08);
  --overlay-control-active: rgba(0, 0, 0, 0.76);
  --control-hover: rgba(255, 253, 246, 0.96);
  --shadow: 0 20px 50px rgba(17, 18, 15, 0.16);
  --shadow-soft: 0 10px 28px rgba(17, 18, 15, 0.08);
  --image-shadow: 0 18px 42px rgba(17, 18, 15, 0.22);
  --disabled: #9ea29d;
  --radius: 8px;
  --rail-width: 12px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10110e;
  --surface: rgba(25, 25, 21, 0.88);
  --surface-solid: #1a1a16;
  --surface-strong: #050605;
  --field: rgba(12, 13, 11, 0.86);
  --text: #f5f0e4;
  --muted: #b7b09d;
  --muted-soft: #898575;
  --line: rgba(245, 240, 228, 0.11);
  --line-strong: rgba(245, 240, 228, 0.24);
  --accent: #ff6845;
  --accent-soft: rgba(255, 104, 69, 0.17);
  --cyan: #42c2cc;
  --cyan-soft: rgba(66, 194, 204, 0.15);
  --amber: #e0a42c;
  --amber-soft: rgba(224, 164, 44, 0.16);
  --ink: #050605;
  --paper: #f5f0e4;
  --good: #6ec496;
  --danger: #ff7864;
  --sort-active-bg: #f5f0e4;
  --sort-active-text: #10110e;
  --sort-active-pressed-bg: #ded6c6;
  --sort-active-pressed-text: #10110e;
  --sort-idle-bg: rgba(255, 255, 255, 0.08);
  --sort-idle-text: #b7b09d;
  --control-active: rgba(245, 240, 228, 0.12);
  --control-hover: rgba(245, 240, 228, 0.11);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 14px 36px rgba(0, 0, 0, 0.3);
  --image-shadow: 0 22px 54px rgba(0, 0, 0, 0.58);
  --disabled: #666b68;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #10110e;
    --surface: rgba(25, 25, 21, 0.88);
    --surface-solid: #1a1a16;
    --surface-strong: #050605;
    --field: rgba(12, 13, 11, 0.86);
    --text: #f5f0e4;
    --muted: #b7b09d;
    --muted-soft: #898575;
    --line: rgba(245, 240, 228, 0.11);
    --line-strong: rgba(245, 240, 228, 0.24);
    --accent: #ff6845;
    --accent-soft: rgba(255, 104, 69, 0.17);
    --cyan: #42c2cc;
    --cyan-soft: rgba(66, 194, 204, 0.15);
    --amber: #e0a42c;
    --amber-soft: rgba(224, 164, 44, 0.16);
    --ink: #050605;
    --paper: #f5f0e4;
    --good: #6ec496;
    --danger: #ff7864;
    --sort-active-bg: #f5f0e4;
    --sort-active-text: #10110e;
    --sort-active-pressed-bg: #ded6c6;
    --sort-active-pressed-text: #10110e;
    --sort-idle-bg: rgba(255, 255, 255, 0.08);
    --sort-idle-text: #b7b09d;
    --control-active: rgba(245, 240, 228, 0.12);
    --control-hover: rgba(245, 240, 228, 0.11);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    --shadow-soft: 0 14px 36px rgba(0, 0, 0, 0.3);
    --image-shadow: 0 22px 54px rgba(0, 0, 0, 0.58);
    --disabled: #666b68;
  }
}

body {
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(17, 18, 15, 0.06) 0 var(--rail-width), transparent var(--rail-width)),
    repeating-linear-gradient(90deg, transparent 0 32px, rgba(17, 18, 15, 0.035) 32px 33px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0) 320px),
    var(--bg);
  font-family: var(--font-body);
  letter-spacing: 0;
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(90deg, rgba(245, 240, 228, 0.08) 0 var(--rail-width), transparent var(--rail-width)),
    repeating-linear-gradient(90deg, transparent 0 32px, rgba(245, 240, 228, 0.028) 32px 33px),
    linear-gradient(180deg, rgba(255, 104, 69, 0.09), rgba(255, 104, 69, 0) 320px),
    var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body {
    background:
      linear-gradient(90deg, rgba(245, 240, 228, 0.08) 0 var(--rail-width), transparent var(--rail-width)),
      repeating-linear-gradient(90deg, transparent 0 32px, rgba(245, 240, 228, 0.028) 32px 33px),
      linear-gradient(180deg, rgba(255, 104, 69, 0.09), rgba(255, 104, 69, 0) 320px),
      var(--bg);
  }
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(17, 18, 15, 0.045) 0 1px, transparent 1px 7px),
    linear-gradient(120deg, transparent 0 58%, rgba(31, 154, 166, 0.08) 58% 59%, transparent 59%),
    linear-gradient(68deg, transparent 0 72%, rgba(214, 75, 42, 0.1) 72% 73%, transparent 73%);
  mix-blend-mode: multiply;
}

:root[data-theme="dark"] body::before {
  background:
    repeating-linear-gradient(0deg, rgba(245, 240, 228, 0.035) 0 1px, transparent 1px 7px),
    linear-gradient(120deg, transparent 0 58%, rgba(66, 194, 204, 0.09) 58% 59%, transparent 59%),
    linear-gradient(68deg, transparent 0 72%, rgba(255, 104, 69, 0.11) 72% 73%, transparent 73%);
  mix-blend-mode: screen;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::before {
    background:
      repeating-linear-gradient(0deg, rgba(245, 240, 228, 0.035) 0 1px, transparent 1px 7px),
      linear-gradient(120deg, transparent 0 58%, rgba(66, 194, 204, 0.09) 58% 59%, transparent 59%),
      linear-gradient(68deg, transparent 0 72%, rgba(255, 104, 69, 0.11) 72% 73%, transparent 73%);
    mix-blend-mode: screen;
  }
}

.app-shell {
  width: min(1380px, calc(100% - 40px));
  padding: 32px 0 64px;
}

.topbar {
  position: relative;
  z-index: 160;
  align-items: stretch;
  gap: 18px;
  min-height: 118px;
  margin-bottom: 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 18px 18px 16px 22px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 16%, transparent), transparent 28%),
    linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--surface-solid) 68%, transparent));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 10px;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--cyan) 52%, var(--amber));
}

.topbar > :first-child,
.topbar-title {
  align-content: center;
  min-width: 0;
  padding-left: 4px;
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 800;
  line-height: 0.98;
  text-transform: uppercase;
}

.detail-shell #detailTitle {
  font-family: var(--font-body);
  font-size: 28px;
  font-weight: 780;
  line-height: 1.16;
}

.topbar p {
  max-width: 700px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.title-meta,
.detail-status-strip {
  gap: 8px;
}

.detail-status-group {
  gap: 8px;
}

.topbar-actions {
  align-items: flex-start;
  align-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(620px, 48vw);
  padding-top: 2px;
}

.source-pill,
.version-pill,
.detail-status-chip,
.poster-source-badge,
.duration,
.happy-badge {
  border-radius: 999px;
  font-weight: 780;
  letter-spacing: 0;
}

.source-pill,
.version-pill,
.detail-status-chip {
  min-height: 34px;
  border-color: var(--line-strong);
  padding: 8px 12px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--field) 92%, transparent), color-mix(in srgb, var(--surface) 82%, transparent));
  color: var(--muted);
  box-shadow: none;
}

.version-pill {
  color: var(--accent);
}

.back-link {
  min-height: 34px;
  border-color: var(--line-strong);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--field);
  color: var(--muted);
  font-weight: 780;
}

.controls,
.source-settings-toolbar,
.summary-row,
.favorite-sync-panel,
.ai-source-workbench,
.ai-source-result {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-solid) 70%, transparent), color-mix(in srgb, var(--surface) 92%, transparent)),
    var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.controls,
.source-settings-toolbar {
  margin-bottom: 16px;
  padding: 14px;
}

.home-controls {
  grid-template-columns: minmax(150px, 0.85fr) minmax(280px, 1.7fr) minmax(128px, 0.72fr);
  gap: 12px;
}

.summary-row {
  min-height: 46px;
  margin: 0 0 18px;
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 680;
}

.summary-row::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--cyan);
  box-shadow: 0 0 0 4px var(--cyan-soft);
}

.select-box,
.sort-select,
.search-box,
.settings-field,
.source-settings-search,
.source-settings-field,
.ai-source-field,
.favorite-sync-check,
.favorite-sync-field,
.settings-select-field.favorite-sync-field {
  border-color: var(--line);
  border-radius: var(--radius);
  background: var(--field);
}

.select-box > span,
.sort-select > span,
.search-field label span,
.search-box label span,
.settings-field > span,
.settings-field > label,
.source-settings-field > span,
.source-settings-field > label,
.source-settings-search span,
.ai-source-field span,
.favorite-sync-check span {
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 820;
}

input,
select,
textarea,
.source-settings-search input,
.source-settings-field input,
.settings-field input,
.settings-field select,
.ai-source-field input,
.ai-source-field textarea,
.ai-source-field select {
  color: var(--text);
  caret-color: var(--accent);
}

input:focus,
select:focus,
textarea:focus,
.source-settings-search input:focus,
.source-settings-field input:focus {
  border-color: color-mix(in srgb, var(--cyan) 52%, var(--line-strong));
  box-shadow: 0 0 0 3px var(--cyan-soft);
}

.random-button,
.favorite-nav-button,
.theme-toggle,
.settings-button,
.icon-button,
.summary-action-button,
.empty-action-button,
.source-settings-button,
.happy-panel-button,
.media-toolbar button,
.detail-icon-button,
.detail-link,
.sort-button,
.category-chip,
.search-source-tab,
.detail-segment-button {
  border-radius: var(--radius);
  font-weight: 820;
  letter-spacing: 0;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease,
    opacity 150ms ease;
}

.random-button,
.source-settings-primary-button,
.happy-confirm-button,
.favorite-sync-main-button {
  border-color: transparent;
  background:
    linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 72%, var(--amber)));
  color: #fffaf0;
  box-shadow: 0 12px 28px color-mix(in srgb, var(--accent) 24%, transparent);
}

.random-button:hover:not(:disabled),
.source-settings-primary-button:hover:not(:disabled),
.happy-confirm-button:hover:not(:disabled),
.favorite-sync-main-button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.favorite-nav-button,
.theme-toggle,
.settings-button,
.icon-button,
.source-settings-button,
.summary-action-button,
.empty-action-button,
.sort-button,
.detail-icon-button,
.happy-panel-button,
.media-toolbar button {
  border-color: var(--line-strong);
  background: var(--field);
  color: var(--text);
}

.favorite-nav-button:hover:not(:disabled),
.theme-toggle:hover,
.settings-button:hover,
.icon-button:hover:not(:disabled),
.source-settings-button:hover:not(:disabled),
.summary-action-button:hover:not(:disabled),
.empty-action-button:hover:not(:disabled),
.sort-button:hover:not(:disabled),
.detail-icon-button:hover:not(:disabled),
.happy-panel-button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--cyan) 42%, var(--line-strong));
  background: var(--control-hover);
  transform: translateY(-1px);
}

.favorite-nav-button svg,
.random-button svg,
.settings-button svg,
.theme-toggle svg,
.icon-button svg,
.source-settings-button svg,
.detail-icon-button svg {
  stroke-width: 2.1;
}

.category-panel {
  grid-column: 1 / -1;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 0 0;
  background: transparent;
}

.category-heading {
  margin-bottom: 10px;
  color: var(--muted);
}

.category-tabs,
.search-source-tabs {
  gap: 7px;
}

.category-chip,
.search-source-tab,
.sort-button {
  min-height: 36px;
  border-color: var(--line);
  background: color-mix(in srgb, var(--field) 74%, transparent);
  color: var(--muted);
}

.category-chip.is-active,
.category-chip[aria-pressed="true"],
.search-source-tab.is-active,
.sort-button.is-active,
.sort-button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--sort-active-bg);
  color: var(--sort-active-text);
  box-shadow: 0 10px 22px rgba(17, 18, 15, 0.16);
}

.video-grid {
  --video-grid-columns: 5;
  --video-grid-row-gap: 24px;
  --video-grid-column-gap: 18px;
  align-items: start;
}

.video-grid[data-card-size="large"] {
  --video-grid-columns: 4;
  --video-grid-row-gap: 26px;
  --video-grid-column-gap: 20px;
}

.video-grid[data-card-size="small"] {
  --video-grid-columns: 7;
  --video-grid-row-gap: 20px;
  --video-grid-column-gap: 14px;
}

.video-card {
  position: relative;
  border-radius: var(--radius);
  padding: 0;
}

.video-card::before {
  content: "";
  position: absolute;
  inset: -6px -6px auto;
  height: calc(100% + 12px);
  border: 1px solid transparent;
  border-radius: var(--radius);
  pointer-events: none;
  transition: border-color 150ms ease, background 150ms ease;
}

.video-card:hover::before,
.video-card:focus-within::before {
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface-solid) 42%, transparent);
}

.poster {
  border-color: color-mix(in srgb, var(--paper) 34%, transparent);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 36%),
    linear-gradient(135deg, #161712 0%, #070807 56%, #40352a 100%);
}

.poster::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 24%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.62), transparent 52%);
}

.poster::after {
  inset: 7px;
  border-radius: 5px;
  border-color: color-mix(in srgb, var(--paper) 18%, transparent);
}

.video-card:hover .poster,
.video-card:focus-within .poster {
  box-shadow: 0 26px 56px rgba(17, 18, 15, 0.3);
  transform: translateY(-4px);
}

.poster-id {
  left: 10px;
  right: 66px;
  bottom: 9px;
  color: rgba(255, 250, 240, 0.72);
  font-family: var(--font-display);
  font-size: 11px;
}

.poster-source-badge,
.duration,
.happy-badge {
  border-color: rgba(255, 250, 240, 0.18);
  background: rgba(0, 0, 0, 0.56);
  color: rgba(255, 250, 240, 0.92);
}

.duration {
  min-width: 44px;
}

.card-body {
  position: relative;
  padding: 10px 2px 0;
}

.title-row h2 {
  font-size: 13px;
  line-height: 1.38;
  font-weight: 760;
}

.meta-grid {
  gap: 4px 9px;
}

.meta-grid dt,
.meta-grid dd,
.rank,
.score,
.detail-link,
.card-favorite-button {
  font-size: 11px;
}

.actions {
  opacity: 0.72;
}

.pagination {
  margin-top: 28px;
}

.pagination button,
.back-to-top-button,
.mobile-filter-button {
  border-radius: var(--radius);
}

.back-to-top-button,
.mobile-filter-button {
  background: var(--ink);
  color: var(--paper);
}

.settings-panel,
.source-settings-ai-panel,
.source-settings-sync-dialog-panel,
.source-settings-interface-panel,
.source-settings-edit-panel,
.source-settings-confirm-panel,
.source-settings-log-panel,
.mobile-filter-sheet,
.search-history-panel {
  border-color: var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-solid) 74%, transparent), var(--surface)),
    var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.settings-panel {
  z-index: 180;
}

.settings-heading,
.source-settings-ai-header,
.source-settings-sync-header,
.source-settings-interface-header,
.source-settings-edit-header,
.source-settings-log-header {
  border-bottom-color: var(--line);
}

.settings-switch {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--muted) 16%, var(--field));
}

.settings-toggle input:checked + .settings-switch {
  background: var(--accent);
}

.settings-action-button,
.source-settings-button,
.favorite-sync-small-button,
.favorite-sync-action-button {
  min-height: 38px;
}

.source-settings-shell,
.ai-source-shell,
.favorite-sync-shell {
  width: min(1260px, calc(100% - 40px));
}

.source-settings-toolbar {
  position: sticky;
  top: 12px;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.1fr) minmax(180px, 0.7fr);
  grid-template-areas:
    "summary search clear"
    "actions actions actions";
  align-items: stretch;
  gap: 14px;
}

.source-settings-toolbar > #sourceSettingsSummary {
  grid-area: summary;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(18px, 1.8vw, 22px);
  font-weight: 800;
  line-height: 1.18;
}

.source-settings-toolbar > .source-settings-search {
  grid-area: search;
}

.source-settings-toolbar > .source-settings-clear-search-button {
  grid-area: clear;
  justify-self: start;
  width: fit-content;
  min-width: 118px;
  max-width: 100%;
  padding-inline: 14px;
}

.source-settings-toolbar > .source-settings-toolbar-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(6, minmax(38px, 1fr));
  gap: 8px;
  justify-content: end;
  min-width: 0;
}

.source-settings-toolbar > .source-settings-toolbar-actions .source-settings-button {
  min-width: 38px;
}

.source-settings-list {
  border-color: var(--line-strong);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  box-shadow: var(--shadow-soft);
}

.source-settings-list-header,
.source-settings-row {
  grid-template-columns: minmax(210px, 1.16fr) minmax(130px, 0.62fr) minmax(138px, 0.72fr) minmax(180px, 0.78fr) 54px;
  gap: 10px;
}

.source-settings-list-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--ink);
  color: var(--paper);
}

.source-settings-row {
  background: var(--surface);
  min-height: 72px;
}

.source-settings-row:hover {
  background: color-mix(in srgb, var(--cyan-soft) 55%, var(--surface));
}

.source-settings-row.is-selected {
  background: color-mix(in srgb, var(--accent-soft) 72%, var(--surface));
}

.source-settings-row.is-recently-saved {
  background: color-mix(in srgb, var(--accent-soft) 82%, var(--surface));
  box-shadow: inset 3px 0 0 var(--accent), 0 0 0 1px color-mix(in srgb, var(--accent) 38%, transparent);
}

.source-settings-row > [data-source-action="check"] {
  justify-self: center;
  width: 38px;
  min-width: 38px;
}

.source-settings-actions {
  grid-template-columns: repeat(3, minmax(34px, 38px));
  justify-content: start;
}

.source-settings-badge {
  border-radius: 999px;
  font-weight: 820;
}

.source-settings-badge[data-source-badge="parser"] {
  background: var(--cyan-soft);
  color: var(--cyan);
}

.source-settings-badge[data-source-badge="interface"],
.source-settings-row.is-interface-source .source-settings-badge {
  background: var(--amber-soft);
  color: var(--amber);
}

.source-settings-status[data-tone="good"],
.source-settings-row[data-status="ok"] .source-settings-connectivity-status {
  background: color-mix(in srgb, var(--good) 15%, transparent);
  color: var(--good);
}

.source-settings-status[data-tone="danger"],
.source-settings-row[data-status="blocked"] .source-settings-connectivity-status,
.source-settings-row[data-status="error"] .source-settings-connectivity-status {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
}

.detail-shell {
  width: min(100% - 16px, 1680px);
  max-width: none;
  padding-top: 10px;
  --detail-media-height: clamp(420px, calc(100svh - 108px), 940px);
}

.detail-layout {
  grid-template-columns: minmax(0, 1.72fr) minmax(300px, 0.58fr);
  gap: 18px;
}

.detail-media {
  border-color: rgba(255, 250, 240, 0.18);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(90deg, #050605 0 16px, #090a08 16px 18px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
}

.detail-media.is-plyr-enabled {
  --plyr-color-main: var(--accent);
  --plyr-control-radius: 8px;
}

.compact-player-shell.is-plyr-enabled {
  --plyr-color-main: var(--accent);
}

.detail-panel,
.comments-section,
.captcha-card,
.heiliao-article {
  border-color: var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-solid) 72%, transparent), var(--surface)),
    var(--surface);
  box-shadow: var(--shadow-soft);
}

.detail-panel {
  padding: 14px;
  opacity: 1;
}

.detail-layout,
.detail-layout.is-heiliao-detail {
  grid-template-columns: minmax(0, 1fr);
}

.detail-layout.is-panel-open {
  grid-template-columns: minmax(0, 1.72fr) minmax(300px, 0.58fr);
}

.detail-panel[hidden] {
  display: none;
}

.detail-info-toggle {
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
}

.detail-info-glyph {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1.8px solid currentColor;
  border-radius: 999px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 840;
  line-height: 1;
}

.detail-info-toggle.is-active {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  background: color-mix(in srgb, var(--accent) 13%, var(--surface));
  color: var(--accent);
}

@media (max-width: 920px) {
  .detail-layout.is-panel-open {
    grid-template-columns: minmax(0, 1fr);
  }
}

.detail-panel-heading,
.comments-heading h2,
.detail-side-section h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
}

.detail-stats div {
  grid-template-columns: 76px minmax(0, 1fr);
  padding: 9px 0;
}

.detail-stats dt {
  font-size: 12px;
  font-weight: 760;
}

.detail-stats dd {
  font-size: 13px;
}

.detail-segment-button {
  border-color: var(--line);
  background: var(--field);
}

.detail-segment-button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--cyan) 48%, var(--line));
  background: var(--cyan-soft);
  color: var(--cyan);
}

.media-toolbar {
  opacity: 0.9;
}

.media-toolbar button {
  border-color: rgba(255, 250, 240, 0.2);
  background: rgba(0, 0, 0, 0.58);
  color: #fffaf0;
}

.play-button {
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  color: var(--accent);
}

.favorite-undo-toast {
  border-color: var(--line-strong);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
}

.happy-shell {
  background:
    repeating-linear-gradient(90deg, #050605 0 34px, #090a08 34px 36px),
    #050605;
}

.happy-grid {
  gap: 6px;
  padding: 6px;
  background: transparent;
}

.happy-card {
  border-color: rgba(255, 250, 240, 0.16);
  border-radius: var(--radius);
  background: #000;
}

.happy-card.is-expanded {
  border-color: rgba(66, 194, 204, 0.5);
  box-shadow: 0 26px 86px rgba(0, 0, 0, 0.88);
}

.happy-settings-button,
.happy-settings-panel,
.happy-captcha-panel,
.happy-card-button {
  border-color: rgba(255, 250, 240, 0.22);
  background: rgba(8, 9, 7, 0.82);
  color: #fffaf0;
}

.happy-settings-button,
.happy-card-button {
  border-radius: 999px;
}

.happy-settings-panel,
.happy-captcha-panel {
  border-radius: var(--radius);
}

.happy-count-preset-button[aria-pressed="true"],
.happy-card-favorite-button.is-favorite {
  border-color: var(--accent);
  background: var(--accent);
}

.happy-exit-button {
  background: color-mix(in srgb, var(--danger) 82%, #000);
}

.compact-error {
  border: 1px solid rgba(255, 250, 240, 0.18);
  border-radius: var(--radius);
  background: rgba(8, 9, 7, 0.84);
}

.ai-source-result-state,
.source-settings-empty,
.empty {
  border-color: var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--amber-soft) 62%, transparent), transparent 40%),
    var(--surface);
}

.ai-source-json,
.source-settings-log-detail,
.source-settings-log-url {
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--ink) 92%, var(--surface));
  color: var(--paper);
}

@media (max-width: 1100px) {
  .app-shell,
  .source-settings-shell,
  .ai-source-shell,
  .favorite-sync-shell {
    width: min(100% - 28px, 1040px);
  }

  .detail-shell {
    width: min(100% - 16px, 1080px);
    --detail-media-height: clamp(420px, calc(100svh - 112px), 820px);
  }

  .home-controls {
    grid-template-columns: 1fr 1fr;
  }

  .source-settings-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "summary summary"
      "search clear"
      "actions actions";
  }

  .search-box,
  .source-settings-toolbar-actions,
  .category-panel,
  .search-source-tabs {
    grid-column: 1 / -1;
  }

  .source-settings-toolbar > .source-settings-toolbar-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }

  .source-settings-toolbar > .source-settings-toolbar-actions > * {
    min-width: 0;
    width: 100%;
  }

  .video-grid {
    --video-grid-columns: 4;
  }

  .video-grid[data-card-size="large"] {
    --video-grid-columns: 3;
  }

  .video-grid[data-card-size="small"] {
    --video-grid-columns: 5;
  }
}

@media (max-width: 860px) {
  .source-settings-list-header {
    display: none;
  }

  .source-settings-row {
    grid-template-columns: minmax(0, 1fr) auto minmax(72px, auto);
    grid-template-areas:
      "source status check"
      "endpoints endpoints endpoints"
      "actions actions actions";
    align-items: stretch;
    gap: 8px 10px;
    min-height: 0;
    padding: 12px;
  }

  .source-settings-source {
    grid-area: source;
  }

  .source-settings-endpoints {
    grid-area: endpoints;
  }

  .source-settings-actions {
    grid-area: actions;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
  }

  .source-settings-actions .source-settings-button,
  .source-settings-row > [data-source-action="check"] {
    min-width: 0;
    padding: 0 8px;
  }

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

  .source-settings-connectivity-status {
    grid-area: status;
    align-self: center;
    justify-self: end;
    text-align: right;
  }

  .source-settings-row > [data-source-action="check"] {
    grid-area: check;
    align-self: center;
    justify-self: end;
    width: auto;
  }
}

@media (max-width: 760px) {
  body {
    background:
      linear-gradient(90deg, rgba(17, 18, 15, 0.06) 0 8px, transparent 8px),
      var(--bg);
  }

  .app-shell,
  .source-settings-shell,
  .ai-source-shell,
  .favorite-sync-shell {
    width: min(100% - 20px, 620px);
    padding-top: 16px;
  }

  .topbar {
    min-height: 0;
    padding: 14px;
  }

  .topbar h1 {
    font-size: 34px;
  }

  .detail-shell #detailTitle {
    font-size: 23px;
  }

  .topbar-actions {
    max-width: 100%;
    flex-wrap: wrap;
    overflow: visible;
    backdrop-filter: none;
  }

  .home-controls,
  .favorites-controls {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .source-settings-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "summary summary"
      "search clear"
      "actions actions";
    padding: 12px;
  }

  .video-grid {
    --video-grid-columns: 2;
    --video-grid-row-gap: 18px;
    --video-grid-column-gap: 12px;
  }

  .video-grid[data-card-size="large"] {
    --video-grid-columns: 1;
  }

  .video-grid[data-card-size="small"] {
    --video-grid-columns: 3;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-shell {
    width: min(100% - 10px, 620px);
    padding-top: 8px;
    --detail-media-height: clamp(500px, calc(100svh - 160px), 720px);
  }

  .source-settings-list-header,
  .source-settings-row {
    grid-template-columns: 1fr;
  }

  .source-settings-row {
    grid-template-areas:
      "source"
      "endpoints"
      "status"
      "actions"
      "check";
  }

  .source-settings-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .source-settings-connectivity-status {
    justify-self: start;
    text-align: left;
  }

  .source-settings-row > [data-source-action="check"] {
    justify-self: start;
    width: auto;
    min-width: 0;
  }

  .happy-grid {
    gap: 4px;
    padding: 4px;
  }

  .settings-panel {
    position: fixed;
    z-index: 1000;
  }
}

/* Home density tuning: keep the list visually dominant. */
#sourcePill {
  display: none !important;
}

.app-shell {
  padding-top: 18px;
}

.home-topbar {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(12px, 1fr) max-content;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  margin-bottom: 10px;
  padding: 11px 16px 11px 20px;
}

.favorites-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  margin-bottom: 10px;
  padding: 11px 16px 11px 20px;
}

.favorites-topbar::before {
  inset: 10px auto 10px 9px;
  width: 3px;
}

.favorites-topbar .topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 42px;
  padding-left: 2px;
}

.favorites-topbar .back-link {
  flex: 0 0 auto;
  min-height: 34px;
  margin: 0;
  padding: 0 11px 0 9px;
  font-size: 12.5px;
}

.favorites-topbar .back-link::before {
  font-size: 21px;
}

.favorites-topbar h1 {
  display: block;
  min-width: 0;
  overflow: visible;
  padding-block: 2px;
  font-size: 30px;
  line-height: 1.16;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  -webkit-line-clamp: unset;
}

.favorites-topbar .title-meta {
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.favorites-topbar .source-pill {
  min-height: 26px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  line-height: 1;
  box-shadow: none;
}

.favorites-topbar .topbar-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: flex-end;
  min-height: 42px;
  max-width: none;
  padding-top: 0;
}

.favorites-topbar .topbar-actions > * {
  align-self: flex-end;
}

.favorites-topbar .favorite-nav-button,
.favorites-topbar .theme-toggle {
  height: 34px;
  min-height: 34px;
}

.favorites-topbar .favorite-nav-button {
  padding: 0 11px;
  font-size: 12.5px;
}

.favorites-topbar .theme-toggle {
  width: 34px;
  min-width: 34px;
}

.utility-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  margin-bottom: 10px;
  padding: 11px 16px 11px 20px;
}

.utility-topbar::before {
  inset: 10px auto 10px 9px;
  width: 3px;
}

.utility-topbar .topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 42px;
  padding-left: 2px;
}

.utility-topbar .back-link {
  flex: 0 0 auto;
  min-height: 34px;
  margin: 0;
  padding: 0 11px 0 9px;
  font-size: 12.5px;
}

.utility-topbar .back-link::before {
  font-size: 21px;
}

.utility-topbar h1 {
  display: block;
  min-width: 0;
  overflow: visible;
  padding-block: 2px;
  font-size: 28px;
  line-height: 1.16;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  -webkit-line-clamp: unset;
}

.utility-topbar .title-meta {
  flex: 0 0 auto;
  flex-wrap: nowrap;
}

.utility-topbar .source-pill {
  min-height: 26px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  line-height: 1;
  box-shadow: none;
}

.utility-topbar .topbar-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: flex-end;
  min-height: 42px;
  max-width: none;
  padding-top: 0;
}

.utility-topbar .topbar-actions > * {
  align-self: flex-end;
}

.utility-topbar .theme-toggle {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
}

.home-topbar::before {
  inset: 10px auto 10px 9px;
  width: 3px;
}

.home-topbar .topbar-title {
  display: flex;
  grid-column: 1;
  flex: 0 1 auto;
  align-items: center;
  align-self: center;
  gap: 12px;
  height: 42px;
  min-width: 0;
  padding-left: 2px;
}

.home-topbar h1 {
  display: block;
  flex: 0 0 auto;
  min-width: 0;
  font-size: 32px;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  transform: translateY(5px);
  -webkit-line-clamp: unset;
}

.home-topbar .title-meta {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-self: end;
  gap: 0;
  padding-bottom: 2px;
}

.home-topbar .topbar-actions {
  display: flex;
  grid-column: 3;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: flex-end;
  align-self: center;
  gap: 8px;
  min-height: 42px;
  margin-left: auto;
  max-width: none;
  padding-top: 0;
  overflow: visible;
}

.home-topbar .home-settings {
  align-items: center;
  align-self: center;
  height: 34px;
  margin-left: 0;
}

.home-topbar .favorite-nav-button,
.home-topbar .random-button {
  height: 34px;
  min-height: 34px;
  padding: 0 11px;
  gap: 7px;
  font-size: 12.5px;
}

.home-topbar .favorite-nav-button svg,
.home-topbar .random-button svg {
  width: 16px;
  height: 16px;
}

.home-topbar .favorite-nav-button strong {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
}

.home-topbar .theme-toggle,
.home-topbar .settings-button,
.home-topbar .detail-icon-button {
  height: 34px;
  align-self: center;
}

.home-topbar .theme-toggle {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.home-topbar .settings-button,
.home-topbar .detail-icon-button {
  width: 34px;
}

.home-topbar .topbar-actions > * {
  align-self: flex-end;
}

.home-topbar .theme-toggle svg,
.home-topbar .settings-button svg,
.home-topbar .detail-icon-button svg,
.home-topbar .favorite-nav-button svg,
.home-topbar .random-button svg {
  display: block;
}

.home-topbar .version-pill {
  min-height: 26px;
  border-radius: 9px;
  border-color: color-mix(in srgb, var(--line-strong) 62%, transparent);
  padding: 4px 8px;
  background: color-mix(in srgb, var(--surface-solid) 46%, transparent);
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  line-height: 1;
  box-shadow: none;
}

.source-pill,
.version-pill,
.detail-status-chip {
  min-height: 28px;
  padding: 5px 9px;
}

.detail-status-strip {
  display: grid;
  grid-template-columns: 1fr;
}

.detail-status-group {
  display: flex;
}

.detail-shell .topbar {
  position: sticky;
  top: 8px;
  z-index: 300;
  align-items: flex-end;
  min-height: 0;
  margin-bottom: 8px;
  padding: 8px 10px 8px 12px;
}

.detail-shell .topbar > :first-child {
  display: grid;
  grid-template-columns: auto minmax(180px, max-content) minmax(0, 1fr);
  gap: 5px 10px;
  align-items: center;
  padding-left: 2px;
}

.detail-shell .back-link {
  grid-column: 1;
  grid-row: 1;
  min-height: 30px;
  margin: 0;
  padding: 0 11px 0 9px;
  font-size: 13px;
}

.detail-shell .back-link::before {
  font-size: 21px;
}

.detail-shell #detailTitle {
  grid-column: 2 / -1;
  grid-row: 1;
  display: block;
  min-width: 0;
  font-size: 23px;
  line-height: 1.08;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-line-clamp: unset;
}

.detail-shell #detailSubtitle {
  grid-column: 1 / 3;
  grid-row: 2;
  margin: 0;
  max-width: none;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-shell .detail-status-strip {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin-top: 0;
}

.detail-shell .detail-status-group {
  gap: 6px;
}

.detail-shell .detail-status-chip {
  min-height: 20px;
  border: 0;
  border-radius: 6px;
  padding: 3px 7px;
  gap: 5px;
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  box-shadow: none;
  font-size: 11.5px;
  font-weight: 720;
  line-height: 1;
}

.detail-shell .detail-status-chip::before {
  content: "";
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.72;
}

.detail-shell .detail-status-chip[data-tone="good"] {
  background: color-mix(in srgb, var(--good) 12%, transparent);
}

.detail-shell .detail-status-chip[data-tone="warn"],
.detail-shell .detail-status-chip[data-tone="info"] {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.detail-shell .detail-status-chip[data-tone="danger"] {
  background: color-mix(in srgb, var(--danger) 13%, transparent);
}

.detail-shell .detail-status-chip[data-tone="time"] {
  background: color-mix(in srgb, var(--text) 9%, transparent);
  color: var(--muted);
}

.detail-shell .topbar-actions {
  align-items: flex-end;
  align-self: flex-end;
  gap: 7px;
  padding-top: 0;
}

.detail-shell .topbar-actions > * {
  align-self: flex-end;
}

.detail-shell .detail-icon-button,
.detail-shell .theme-toggle,
.detail-shell .settings-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  place-items: center;
  place-content: center;
}

.detail-shell .source-pill {
  display: inline-grid;
  place-items: center;
  height: 32px;
  min-height: 32px;
  padding: 0 10px;
  line-height: 1;
}

.detail-shell .topbar-actions .detail-icon-button svg,
.detail-shell .topbar-actions .theme-toggle svg,
.detail-shell .topbar-actions .settings-button svg {
  width: 18px;
  height: 18px;
}

.detail-shell .topbar-actions .theme-toggle-icon {
  transform: none !important;
}

.home-controls {
  grid-template-columns: minmax(148px, 0.78fr) minmax(260px, 1.72fr) minmax(118px, 0.58fr);
  gap: 8px;
  margin-bottom: 8px;
  padding: 9px 10px;
}

.home-controls .search-box {
  width: min(100%, 520px);
}

.home-controls .search-box,
.home-controls .select-box,
.home-controls .sort-select {
  gap: 4px;
}

.home-controls .search-box input,
.home-controls .select-box select,
.home-controls .sort-select select {
  height: 34px;
}

.home-controls .icon-button {
  width: 34px;
  height: 34px;
}

.home-controls .category-panel {
  gap: 5px;
  padding-top: 6px;
}

.home-controls .category-heading {
  margin-bottom: 0;
}

.home-controls .category-chip,
.home-controls .search-source-tab {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.home-controls .category-tabs,
.home-controls .search-source-tabs {
  gap: 6px;
}

.summary-row {
  min-height: 36px;
  margin-bottom: 12px;
  padding: 7px 10px;
  gap: 10px;
  font-size: 12px;
}

.summary-row::before {
  width: 7px;
  height: 7px;
  box-shadow: 0 0 0 3px var(--cyan-soft);
}

.api-link {
  font-size: 12px;
}

.video-grid {
  --video-grid-row-gap: 18px;
  --video-grid-column-gap: 16px;
}

@media (max-width: 1100px) {
  .home-topbar {
    gap: 10px;
    min-height: 58px;
    padding: 9px 12px 9px 18px;
  }

  .home-topbar h1 {
    font-size: 29px;
  }

  .favorites-topbar {
    gap: 10px;
    min-height: 58px;
    padding: 9px 12px 9px 18px;
  }

  .favorites-topbar h1 {
    font-size: 27px;
  }

  .utility-topbar {
    gap: 10px;
    min-height: 58px;
    padding: 9px 12px 9px 18px;
  }

  .utility-topbar h1 {
    font-size: 25px;
  }

  .home-controls {
    gap: 8px;
    padding: 8px;
  }
}

@media (max-width: 760px) {
  .detail-shell .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 8px 10px 8px 12px;
  }

  .detail-shell .topbar > :first-child {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 7px 10px;
    width: 100%;
  }

  .detail-shell #detailTitle {
    grid-column: 2;
    min-width: 0;
    font-size: 20px;
  }

  .detail-shell #detailSubtitle {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .detail-shell .detail-status-strip {
    grid-column: 1 / -1;
    grid-row: auto;
    max-width: 100%;
  }

  .detail-shell .detail-status-chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .detail-shell .topbar-actions {
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
  }

  .app-shell,
  .source-settings-shell,
  .ai-source-shell,
  .favorite-sync-shell {
    padding-top: 10px;
  }

  .home-topbar {
    grid-template-columns: minmax(0, auto) minmax(8px, 1fr) max-content;
    align-items: center;
    gap: 8px;
    min-height: 54px;
    padding: 8px 10px 8px 16px;
  }

  .home-topbar h1 {
    font-size: 26px;
  }

  .favorites-topbar {
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 8px;
    min-height: 52px;
    padding: 8px 10px 8px 16px;
  }

  .favorites-topbar .topbar-title {
    gap: 7px;
    height: 36px;
  }

  .favorites-topbar .back-link {
    min-height: 32px;
    padding: 0 8px 0 7px;
    font-size: 0;
  }

  .favorites-topbar .back-link::before {
    font-size: 20px;
  }

  .favorites-topbar h1 {
    font-size: 25px;
  }

  .utility-topbar {
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 8px;
    min-height: 52px;
    padding: 8px 10px 8px 16px;
  }

  .utility-topbar .topbar-title {
    gap: 7px;
    height: 36px;
  }

  .utility-topbar .back-link {
    min-height: 32px;
    padding: 0 8px 0 7px;
    font-size: 0;
  }

  .utility-topbar .back-link::before {
    font-size: 20px;
  }

  .utility-topbar h1 {
    font-size: 23px;
  }

  .utility-topbar .title-meta {
    display: none;
  }

  .utility-topbar .topbar-actions {
    width: auto;
    justify-content: flex-end;
    border: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .utility-topbar .theme-toggle {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
  }

  .favorites-topbar .title-meta {
    display: none;
  }

  .favorites-topbar .topbar-actions {
    width: auto;
    justify-content: flex-end;
    border: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .favorites-topbar .favorite-nav-button,
  .favorites-topbar .theme-toggle {
    height: 32px;
    min-height: 32px;
  }

  .favorites-topbar .favorite-nav-button {
    width: 32px;
    padding: 0;
  }

  .favorites-topbar .favorite-nav-button span {
    display: none;
  }

  .favorites-topbar .theme-toggle {
    width: 32px;
    min-width: 32px;
  }

  .home-topbar .topbar-title {
    gap: 8px;
    height: 36px;
  }

  .home-topbar h1 {
    transform: translateY(4px);
  }

  .home-topbar .version-pill {
    min-height: 24px;
    padding: 4px 7px;
    font-size: 10.5px;
  }

  .home-topbar .title-meta {
    padding-bottom: 1px;
  }

  .home-topbar .topbar-actions {
    width: auto;
    justify-content: flex-end;
    border: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .home-topbar .favorite-nav-button,
  .home-topbar .random-button {
    height: 32px;
    min-height: 32px;
    padding: 0 8px;
  }

  .home-topbar .theme-toggle,
  .home-topbar .settings-button,
  .home-topbar .detail-icon-button {
    height: 32px;
  }

  .home-topbar .theme-toggle {
    width: 32px;
    min-width: 32px;
    grid-template-columns: 18px;
    column-gap: 0;
    padding: 0;
  }

  .home-topbar .theme-toggle-label {
    display: none;
  }

  .home-topbar .settings-button,
  .home-topbar .detail-icon-button {
    width: 32px;
  }

  .home-topbar .favorite-nav-button span,
  .home-topbar .random-button span {
    display: none;
  }

  .home-topbar .home-settings {
    position: static;
    order: 0;
  }

  .home-controls,
  .source-settings-toolbar,
  .favorites-controls {
    padding: 9px;
  }

  .home-controls {
    grid-template-columns: minmax(0, 1fr);
  }
}
