*[hidden] {
  display: none !important;
}

html {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Settings button (top-right) */
#sourcesSettingsBtn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: #007bff;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}

#simpleSourceLink {
  position: static;
  padding: 0.6em 1em;
  border-radius: 10px;
  background: #1f1f1f;
  color: #f1f1f1;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid #2a2a2a;
  box-shadow: 0 4px 10px rgba(0,0,0,0.35);
  transition: background 0.15s ease, transform 0.1s ease;
}
.sources-footer {
  width: min(1200px, 90%);
  margin: 1rem auto 2rem;
  display: flex;
  justify-content: flex-start;
}
#simpleSourceLink:hover {
  background: #252525;
}
#simpleSourceLink:active {
  transform: translateY(1px);
}
/* Settings overlay */
#sourcesSettingsOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#sourcesSettingsPanel {
  background: #1a1a1a;
  color: #f1f1f1;
  border: 1px solid #333;
  border-radius: 12px;
  width: 380px;
  max-width: calc(100vw - 40px);
  padding: 12px 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
}
#sourcesSettingsPanel h3 { margin: 0 0 8px 0; font-size: 0.98rem; }
#sourcesSettingsPanel .section { margin-top: 12px; padding-top: 10px; border-top: 1px solid #2a2a2a; }
.settings-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; flex-wrap: wrap; }
.settings-actions { margin-top: 14px; display: flex; gap: 8px; justify-content: flex-end; }
.settings-actions button { padding: 7px 10px; border: none; border-radius: 8px; cursor: pointer; font-size: 0.92rem; }
.btn-primary { background: #007bff; color:#fff; }
.btn-ghost { background: #2a2a2a; color:#f1f1f1; }
.settings-radio { display: flex; gap: 10px; flex-wrap: wrap; }
.settings-radio label { display: flex; align-items: center; gap: 6px; }
.settings-select-row {
  justify-content: space-between;
  flex-wrap: nowrap;
}
#sourcesSettingsPanel select {
  min-width: 170px;
  padding: 0.55rem 2.1rem 0.55rem 0.75rem;
  border: 1px solid #3a3a3a;
  border-radius: 9px;
  background: #242424;
  color: #f1f1f1;
  font: inherit;
  cursor: pointer;
}
#sourcesSettingsPanel select:focus-visible {
  outline: 2px solid #4b9cff;
  outline-offset: 2px;
}

.storage-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  width: 100%;
  align-items: stretch;
  justify-items: stretch;
}
.storage-actions-grid button {
  margin: 0;
  width: 100%;
  padding: 0.5em 0.75em;
  border: none;
  border-radius: 6px;
  background: #007bff;
  color: #fff;
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
  transition: background 0.2s, transform 0.1s;
}
.storage-actions-grid button:hover {
  background: #0056b3;
}
.storage-actions-grid button:active {
  transform: scale(0.98);
}
.storage-actions-grid button .icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex: 0 0 auto;
}

/* Storage menu (shared with main app) */
.storage-menu { position: relative; display: inline-flex; align-items: center; }
#storageMenuBtn { margin: 0; }
.storage-menu-panel {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  flex-direction: column;
  align-items: stretch;
  padding: 0.4rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  min-width: 10rem;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
  z-index: 10100;
}
.storage-menu-panel.open { display: flex; }
.storage-menu-item {
  margin: 0;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.6rem;
  font-size: 0.92rem;
  border: 1px solid #333;
  background: #222;
  color: #f1f1f1;
  border-radius: 8px;
  cursor: pointer;
}
.storage-menu-item + .storage-menu-item { margin-top: 0.25rem; }
.storage-menu-item:hover { background: #2a2a2a; }
.storage-actions-grid .danger-button { background: #d9534f; color: #fff; }
.storage-actions-grid .danger-button:hover { background: #c13f3b; }

/* Account overlay (shared with main app) */
#accountSyncOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  align-items: center;
  justify-content: center;
  z-index: 10065;
}
#accountSyncPanel {
  background: #1a1a1a;
  color: #f1f1f1;
  border: 1px solid #333;
  padding: 1.15rem 1.05rem 1.05rem;
  border-radius: 12px;
  width: min(380px, 90%);
  max-width: 90%;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,0.65);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#accountSyncPanel button:not(.account-sync-warning):not(.overlay-close) {
  font-size: 0.95rem;
  padding: 0.55em 1.05em;
  margin: 0.35em;
}
#accountSyncPanel .account-sync-header { display: flex; align-items: center; justify-content: center; }
#accountSyncPanel .account-sync-header h3 { margin: 0; }
#accountSyncCloseBtn.overlay-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  background: #2a2a2a;
  color: #fff;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#accountSyncPanel .account-sync-warning-wrap {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
#accountSyncPanel button.account-sync-warning {
  border: 1px solid #ff4a4a;
  background: #b00000;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-weight: 800;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
}
#accountSyncPanel .account-sync-warning-tooltip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  width: min(320px, 78vw);
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(20, 20, 20, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 34px -12px rgba(0,0,0,0.8);
  color: #f1f1f1;
  font-size: 0.85rem;
  z-index: 2;
  display: none;
}
#accountSyncPanel .account-sync-warning-wrap:hover .account-sync-warning-tooltip,
#accountSyncPanel .account-sync-warning-wrap:focus-within .account-sync-warning-tooltip { display: block; }
#accountSyncPanel .account-sync-status { margin-top: 0.5rem; opacity: 0.85; font-size: 0.95em; white-space: pre-line; }
#accountSyncPanel .account-sync-footer { margin-top: auto; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }
#accountSyncPanel .account-sync-syncrow { width: min(260px, 100%); display: flex; gap: 0.5rem; align-items: center; }
#accountSyncPanel .account-sync-syncrow button { flex: 1; }
#accountSyncPanel input.account-sync-interval { width: 74px; padding: 0.35rem 0.5rem; }
#accountSyncPanel input[type="text"],
#accountSyncPanel input[type="password"] {
  margin: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.setting-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.1em 0.55em;
  border-radius: 999px;
  font-size: 0.7em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-left: 0.45em;
}
.setting-tag--dev { background: rgba(59,130,246,0.18); color:#60a5fa; }
.setting-tag--unstable { background: rgba(239,68,68,0.18); color:#f87171; }
.setting-tag--beta { background: rgba(250,204,21,0.2); color:#facc15; }
.source-time { font-size: 0.8em; opacity: 0.85; }
body {
  -ms-overflow-style: none;
  scrollbar-width: none;
  background: #121212;
  color: #f1f1f1;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
}

.sources-main-toolbar {
  position: sticky;
  top: 0;
  z-index: 1001;
  min-height: 68px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  padding: 0.55rem clamp(1rem, 3vw, 2rem);
  background: rgba(17, 17, 17, 0.96);
  border-bottom: 1px solid #242424;
  backdrop-filter: blur(14px);
}

.sources-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  color: #f1f1f1;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sources-brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.sources-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.sources-nav-button {
  width: 42px;
  height: 42px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #007bff;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.sources-nav-button svg,
.custom-view-close svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.sources-nav-button:hover {
  background: #0056b3;
}

.sources-nav-button:active {
  transform: scale(0.98);
}

.sources-nav-button.is-active {
  background: #f1f1f1;
  color: #111;
}

.sources-nav-button--secondary {
  background: transparent;
  border: 1px solid #333;
}

.sources-nav-button--secondary:hover {
  background: #222;
}

.sources-toolbar-actions {
  display: flex;
  justify-content: flex-end;
}

.sources-toolbar-actions #sourcesSettingsBtn {
  position: static;
  width: 42px;
  height: 42px;
  box-shadow: none;
}

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

.sources-search {
  width: 90%;
  max-width: 560px;
  margin: 1.5rem auto 0;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.continue-watching-section {
  width: min(1200px, 90%);
  margin: 1.5rem auto 0;
}

.continue-watching-section[hidden] {
  display: none;
}

.continue-watching-section h2 {
  margin: 0 0 0.75rem;
  color: #f1f1f1;
  font-size: 1.25rem;
}

.continue-watching-grid {
  display: flex;
  gap: 0.9rem;
  overflow-x: auto;
  padding: 0.2rem 0 0.75rem;
  scrollbar-width: thin;
}

.continue-watching-card {
  position: relative;
  flex: 0 0 180px;
  height: 270px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #333;
  border-radius: 12px;
  background: #1a1a1a;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.continue-watching-card:hover,
.continue-watching-card:focus-visible {
  transform: translateY(-2px);
  border-color: #777;
}

.continue-watching-card:focus-visible {
  outline: 3px solid #4b9cff;
  outline-offset: 3px;
}

.continue-watching-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.continue-watching-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.72), transparent 30%, transparent 60%, rgba(0,0,0,0.82));
  pointer-events: none;
}

.continue-watching-card-title,
.continue-watching-card-detail {
  position: absolute;
  z-index: 1;
  left: 0.65rem;
  right: 0.65rem;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 2px 8px #000;
}

.continue-watching-card-title {
  top: 0.6rem;
  font-weight: 800;
}

.continue-watching-card-detail {
  bottom: 0.6rem;
  font-weight: 700;
  font-size: 0.88rem;
}

@media (max-width: 720px) {
  .continue-watching-card {
    flex-basis: 145px;
    height: 218px;
  }
}

#sourcesSearchInput {
  flex: 1;
  padding: 0.85em 1.1em;
  border-radius: 999px;
  border: 1px solid #2a2a2a;
  background: #1c1c1c;
  color: inherit;
  font: inherit;
}

@media (max-width: 720px) {
  .sources-main-toolbar {
    gap: 0.45rem;
    padding-inline: 0.65rem;
  }

  .sources-brand span {
    display: none;
  }

  .sources-brand img {
    width: 32px;
    height: 32px;
  }

  .sources-nav {
    gap: 0.25rem;
  }

  .sources-nav-button {
    width: 36px;
    height: 36px;
  }
}

.custom-view-overlay[hidden] {
  display: none;
}

.custom-view-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 1rem;
  box-sizing: border-box;
}

.custom-view-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(10px);
}

.custom-view-dialog {
  position: relative;
  z-index: 1;
  width: min(940px, calc(100vw - 2rem));
  height: min(610px, calc(100vh - 2rem));
  overflow: hidden;
  border: 1px solid #333;
  border-radius: 18px;
  background: #1a1a1a;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72);
}

.custom-view-close {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  background: #252525;
  color: #fff;
  cursor: pointer;
}

.custom-view-close:hover {
  background: #333;
}

#customViewFrame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #1a1a1a;
}

.custom-source-prompt {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 4.5rem 2rem 2rem;
  box-sizing: border-box;
}

.custom-source-prompt[hidden],
#customViewFrame[hidden] {
  display: none;
}

#customSourceForm {
  width: min(680px, 100%);
}

#customSourceForm label {
  display: block;
  margin-bottom: 0.75rem;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
}

.custom-source-row {
  display: flex;
  gap: 0.75rem;
}

#customSourceInput {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1rem;
  border: 1px solid #444;
  border-radius: 10px;
  background: #111;
  color: #fff;
}

#customSourceForm button {
  padding: 0.85rem 1.1rem;
  border: 0;
  border-radius: 10px;
  background: #fff;
  color: #111;
  font-weight: 800;
  cursor: pointer;
}

body.custom-view-open {
  overflow: hidden;
}

#sourcesSearchInput::placeholder {
  color: rgba(241, 241, 241, 0.75);
}

.container {
  --cols: 3;
  --gap: 1.5em;
  width: 90%;
  max-width: 1200px;
  margin: 1.5em auto;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: var(--gap);
  justify-items: center;
  overflow-x: auto;
}
.source-card {
  box-sizing: border-box;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  width: min(360px, 100%);
  height: 260px; /* needed so the poster can use 90% height */
  padding: 1em;
  display: flex;
  flex-direction: row; /* image left, text right */
  align-items: center;
  gap: 1em;
  position: relative;
  overflow: hidden; /* prevent poster from pushing out of the card */
}
.source-card.is-interactive {
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.source-card.is-interactive:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: 0 14px 34px rgba(0,0,0,0.42);
}
.source-card.is-interactive:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.42);
  outline-offset: 3px;
}
.source-card.no-thumb {
  height: 260px;
  flex-direction: column;       /* revert to pre-image vertical stack */
  align-items: flex-start;
  gap: 0.5em;
}
.source-card.no-thumb .source-right {
  min-width: 0;                 /* allow full width */
  width: 100%;
}
.source-card h3 {
  margin: 0;
}
.source-title-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
  min-height: 48px;
}
.source-thumb {
  /* Size set dynamically in JS using naturalWidth/naturalHeight */
  border-radius: 10px;    /* curved corners */
  background: #2a2a2a;
  border: 1px solid #333;
  display: block;
  flex: 0 0 auto;
}
.source-right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.35em;
  flex: 1 1 auto;
  min-width: 40%; /* ensure space for text */
}
.source-right h3 { margin: 0; }
.source-card p {
  margin: 0.25em 0;
}
.pill-button {
  margin-top: auto;
  padding: 0.5em 1em;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  text-transform: uppercase;
  font-family: inherit;
  transition: background 0.2s, transform 0.1s;
}
.pill-button:hover { background: #0056b3; }

#serverStatusBox {
  position: fixed;
  top: 1rem;
  left: 1rem;
  background: #1a1a1a;
  color: #f1f1f1;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 0.6em 0.9em;
  font-size: 0.9rem;
  line-height: 1.2;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  z-index: 9999;
  white-space: pre-line;
}
/* Server check loading box */
#serverCheckBox {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1a1a1a;
  color: #f1f1f1;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 1em 1.25em;
  display: none; /* shown while checking */
  align-items: center;
  gap: 0.75em;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  z-index: 10000;
}
#serverCheckBox .serverCheckText {
  white-space: pre-line;
  font-weight: 600;
  line-height: 1.3;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: #5ab8ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex: 0 0 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
}

.storage-notice-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(2px);
  z-index: 11000;
  padding: clamp(1.5rem, 2vw, 3rem);
}
.storage-notice-overlay.is-visible {
  display: flex;
}
body.mm-notice-open {
  overflow: hidden;
}
.storage-notice-stack {
  width: min(420px, 90vw);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
}
.storage-notice {
  background: #1f1f1f;
  color: #f1f1f1;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 1.15rem 1.5rem 1.15rem 1.2rem;
  box-shadow: 0 24px 48px -22px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  position: relative;
}
.storage-notice::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border-left: 4px solid transparent;
  pointer-events: none;
}
.storage-notice--success::before { border-left-color: #22c55e; }
.storage-notice--error::before { border-left-color: #ef4444; }
.storage-notice--warning::before { border-left-color: #f59e0b; }
.storage-notice--info::before { border-left-color: #3b82f6; }
.storage-notice__title {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
}
.storage-notice__message {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.35;
}
.storage-notice__message p,
.storage-notice__message h1,
.storage-notice__message h2,
.storage-notice__message h3,
.storage-notice__message h4,
.storage-notice__message h5,
.storage-notice__message h6,
.storage-notice__message ul,
.storage-notice__message ol,
.storage-notice__message blockquote,
.storage-notice__message pre {
  margin: 0 0 0.65rem;
}
.storage-notice__message > :last-child {
  margin-bottom: 0;
}
.storage-notice__message img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin-top: 0.4rem;
}
.storage-notice__message a {
  color: inherit;
  text-decoration: underline;
}
.storage-notice__message pre {
  overflow-x: auto;
  padding: 0.55rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
}
.storage-notice__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.storage-notice__btn {
  background: transparent;
  color: inherit;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.storage-notice__btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.35);
}
.storage-notice__btn:focus-visible {
  outline: 2px solid #5ab8ff;
  outline-offset: 2px;
}
.storage-notice__btn--danger {
  border-color: rgba(239,68,68,0.45);
  color: #ef4444;
}
.storage-notice__btn--danger:hover { background: rgba(239,68,68,0.15); }
.storage-notice__btn--primary {
  border-color: rgba(59,130,246,0.45);
  color: #3b82f6;
}
.storage-notice__btn--primary:hover { background: rgba(59,130,246,0.15); }

@media (max-width: 900px) {
  .sources-search {
    width: calc(100% - 2rem);
  }
}

@media (max-width: 600px) {
  .sources-search {
    width: calc(100% - 1.5rem);
    margin-top: 4.5rem;
  }
  .container {
    width: calc(100% - 1.5rem);
    grid-template-columns: minmax(0, 1fr);
  }
  .source-card {
    width: 100%;
  }
}

/* 2026 motion + surface refresh */
:root {
  --sources-accent: #c8cdd6;
  --sources-accent-strong: #5f6672;
  --sources-surface: #191a1d;
  --sources-surface-raised: #202126;
  --sources-border: rgba(255, 255, 255, 0.09);
  --sources-muted: rgba(241, 241, 241, 0.66);
  --sources-ease-out: cubic-bezier(0.165, 0.84, 0.44, 1);
}

body {
  min-height: 100vh;
  background: #101113;
}

.sources-main-toolbar {
  min-height: 72px;
  background: rgba(15, 16, 18, 0.88);
  border-bottom-color: var(--sources-border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.22);
}

.sources-brand img {
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.3);
}

.sources-nav {
  gap: 0.25rem;
  padding: 0.28rem;
  border: 1px solid var(--sources-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
}

.sources-nav-button {
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: rgba(241, 241, 241, 0.7);
  transition:
    color 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    transform 120ms var(--sources-ease-out);
}

.sources-nav-button.is-active {
  border-color: rgba(255, 255, 255, 0.12);
  background: #f4f6fb;
  color: #111318;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
}

.sources-nav-button--secondary {
  border-color: transparent;
  background: transparent;
}

.sources-toolbar-actions #sourcesSettingsBtn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  color: #eef0f3;
  transition:
    color 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    transform 120ms var(--sources-ease-out);
}

.sources-nav-button:focus-visible,
.sources-toolbar-actions #sourcesSettingsBtn:focus-visible {
  outline: 2px solid var(--sources-accent);
  outline-offset: 3px;
}

.sources-nav-button:active,
.sources-toolbar-actions #sourcesSettingsBtn:active {
  transform: scale(0.96);
}

main {
  width: 100%;
}

.sources-search {
  position: relative;
  width: min(720px, 100%);
  max-width: none;
  margin: 1.5rem auto 0;
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 15px;
  background: rgba(8, 9, 11, 0.58);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.sources-search:focus-within {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(8, 9, 11, 0.75);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.045), 0 14px 34px rgba(0, 0, 0, 0.24);
}

.sources-search-icon {
  position: absolute;
  left: 1rem;
  width: 1.18rem;
  height: 1.18rem;
  fill: rgba(241, 241, 241, 0.52);
  pointer-events: none;
}

#sourcesSearchInput {
  width: 100%;
  min-width: 0;
  padding: 1rem 8.2rem 1rem 3rem;
  border: 0;
  border-radius: inherit;
  outline: 0;
  background: transparent;
  color: #f5f7fb;
  font: inherit;
}

#sourcesSearchInput::placeholder {
  color: rgba(241, 241, 241, 0.58);
}

.sources-result-count {
  position: absolute;
  right: 0.7rem;
  max-width: 7rem;
  padding: 0.32rem 0.58rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--sources-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.continue-watching-section {
  width: min(1200px, 90%);
  margin-top: 2rem;
}

.continue-watching-section h2 {
  margin-bottom: 0.9rem;
  font-size: clamp(1.18rem, 2vw, 1.4rem);
  letter-spacing: -0.025em;
}

.continue-watching-grid {
  gap: 1rem;
  padding: 0.25rem 0.2rem 0.85rem;
  scroll-snap-type: x mandatory;
}

.continue-watching-card {
  flex-basis: 164px;
  height: 246px;
  scroll-snap-align: start;
  border-color: var(--sources-border);
  border-radius: 18px;
  background: var(--sources-surface);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.3);
  transition: transform 160ms var(--sources-ease-out), border-color 160ms ease, box-shadow 160ms ease;
}

.continue-watching-card::after {
  background: linear-gradient(to bottom, rgba(4, 7, 12, 0.76), transparent 32%, transparent 52%, rgba(4, 7, 12, 0.94));
}

.continue-watching-card-title,
.continue-watching-card-detail {
  text-align: left;
}

.continue-watching-card-title {
  top: 0.75rem;
  left: 0.8rem;
  right: 0.8rem;
}

.continue-watching-card-play {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 2.8rem;
  height: 2.8rem;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  background: rgba(12, 14, 18, 0.76);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translate(-50%, -44%) scale(0.94);
  transition: opacity 160ms ease, transform 180ms var(--sources-ease-out);
}

.continue-watching-card-play svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: #fff;
}

.continue-watching-card-detail {
  bottom: 1.05rem;
  left: 0.8rem;
  right: 0.8rem;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.8rem;
}

.continue-watching-progress {
  position: absolute;
  z-index: 2;
  right: 0.8rem;
  bottom: 0.65rem;
  left: 0.8rem;
  height: 0.22rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.continue-watching-progress > span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #c8cdd6;
  transform: scaleX(var(--continue-progress, 0));
  transform-origin: left center;
}

.container {
  width: min(1200px, 90%);
  margin: 1.6rem auto 2.5rem;
  gap: clamp(0.9rem, 2vw, 1.35rem);
  overflow: visible;
}

.source-card {
  height: 268px;
  padding: 0.78rem;
  gap: 0.9rem;
  overflow: hidden;
  border-color: var(--sources-border);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 48%),
    var(--sources-surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.source-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.45), transparent);
  opacity: 0;
  transition: opacity 160ms ease;
}

.source-card.is-interactive {
  transition: transform 180ms var(--sources-ease-out), border-color 160ms ease, box-shadow 180ms ease;
}

.source-thumb {
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  background: #24262b;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

.source-right {
  align-self: stretch;
  justify-content: flex-start;
  gap: 0.58rem;
  padding: 0.2rem 0;
}

.source-right h3 {
  display: -webkit-box;
  overflow: hidden;
  color: #f7f8fb;
  font-size: clamp(1rem, 1.7vw, 1.12rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.source-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
}

.source-card .source-card-stats p {
  display: inline-flex;
  align-items: center;
  gap: 0.24rem;
  margin: 0;
  padding: 0.28rem 0.48rem;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--sources-muted);
  font-size: 0.74rem;
  line-height: 1;
}

.source-card .source-card-stats p[style*="display: none"] {
  display: none !important;
}

.source-card-stats strong {
  color: #e9effc;
  font-size: 0.78rem;
}

.source-time {
  margin: 0 !important;
  color: var(--sources-muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

.pill-button {
  min-height: 2.15rem;
  margin-top: auto;
  padding: 0.48rem 0.78rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #eef0f3;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: none;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, transform 120ms var(--sources-ease-out);
}

.pill-button::after {
  content: "\2192";
  display: inline-block;
  margin-left: 0.42rem;
  transition: transform 140ms var(--sources-ease-out);
}

.pill-button:focus-visible {
  outline: 2px solid var(--sources-accent);
  outline-offset: 3px;
}

.source-skeleton {
  position: relative;
  box-sizing: border-box;
  width: min(360px, 100%);
  height: 268px;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.78rem;
  overflow: hidden;
  border: 1px solid var(--sources-border);
  border-radius: 18px;
  background: var(--sources-surface);
}

.source-skeleton::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 52%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.075), transparent);
  transform: translateX(-130%);
  animation: sources-skeleton-sweep 1.35s ease-in-out infinite;
  animation-delay: calc(var(--skeleton-index, 0) * 70ms);
  will-change: transform;
}

.source-skeleton-poster {
  width: 42%;
  height: 90%;
  flex: 0 0 auto;
  border-radius: 13px;
  background: #24262b;
}

.source-skeleton-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  justify-content: center;
  gap: 0.62rem;
}

.source-skeleton-line {
  display: block;
  height: 0.68rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.075);
}

.source-skeleton-line--title { width: 92%; height: 1rem; }
.source-skeleton-line--short { width: 54%; }
.source-skeleton-line--medium { width: 72%; }
.source-skeleton-line--button { width: 48%; height: 2rem; margin-top: auto; border-radius: 10px; }

#sourcesContainer.is-revealing .source-card {
  animation: source-card-arrive 280ms var(--sources-ease-out) both;
  animation-delay: calc(var(--source-index, 0) * 42ms);
}

.sources-state-card {
  grid-column: 1 / -1;
  width: min(520px, 100%);
  margin: 1.5rem auto;
  padding: 2.25rem 1.5rem;
  box-sizing: border-box;
  border: 1px solid var(--sources-border);
  border-radius: 20px;
  background: rgba(25, 26, 29, 0.82);
  color: #f7f8fb;
  text-align: center;
}

.sources-state-icon {
  width: 2.8rem;
  height: 2.8rem;
  display: grid;
  place-items: center;
  margin: 0 auto 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #e7e9ed;
  font-size: 1.3rem;
  font-weight: 800;
}

.sources-state-card h2 {
  margin: 0;
  font-size: 1.18rem;
}

.sources-state-card p {
  margin: 0.55rem 0 0;
  color: var(--sources-muted);
  line-height: 1.5;
}

.sources-state-card button {
  margin-top: 1rem;
  padding: 0.65rem 0.95rem;
  border: 0;
  border-radius: 10px;
  background: var(--sources-accent-strong);
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.sources-state-card--error .sources-state-icon {
  border-color: rgba(255, 119, 119, 0.34);
  background: rgba(255, 96, 96, 0.11);
  color: #ff9a9a;
}

@media (hover: hover) and (pointer: fine) {
  .sources-nav-button:hover {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
  }

  .sources-nav-button.is-active:hover {
    background: #fff;
    color: #111318;
  }

  .sources-toolbar-actions #sourcesSettingsBtn:hover {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  .source-card.is-interactive:hover {
    border-color: rgba(255, 255, 255, 0.24);
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.34);
    transform: translateY(-4px);
  }

  .source-card.is-interactive:hover::before {
    opacity: 1;
  }

  .source-card.is-interactive:hover .pill-button {
    border-color: rgba(255, 255, 255, 0.34);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  .source-card.is-interactive:hover .pill-button::after {
    transform: translateX(2px);
  }

  .continue-watching-card:hover,
  .continue-watching-card:focus-visible {
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.4);
    transform: translateY(-4px);
  }

  .continue-watching-card:hover .continue-watching-card-play,
  .continue-watching-card:focus-visible .continue-watching-card-play {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes sources-skeleton-sweep {
  to { transform: translateX(255%); }
}

@keyframes source-card-arrive {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 720px) {
  .sources-search {
    width: calc(100% - 1.5rem);
    margin: 1.25rem auto 0;
  }

  .continue-watching-section,
  .container {
    width: calc(100% - 1.5rem);
  }

  .continue-watching-card {
    flex-basis: 154px;
    height: 231px;
  }
}

@media (max-width: 480px) {
  .sources-main-toolbar {
    min-height: 64px;
  }

  #sourcesSearchInput {
    padding-right: 3rem;
  }

  .sources-result-count {
    display: none;
  }

  .source-card,
  .source-skeleton {
    height: 244px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sources-nav-button,
  .sources-toolbar-actions #sourcesSettingsBtn,
  .sources-search,
  .continue-watching-card,
  .continue-watching-card-play,
  .source-card,
  .source-card::before,
  .pill-button,
  .pill-button::after {
    transition: none;
  }

  .source-skeleton::after,
  #sourcesContainer.is-revealing .source-card {
    animation: none;
  }

  .source-card.is-interactive:hover,
  .continue-watching-card:hover,
  .continue-watching-card:focus-visible {
    transform: none;
  }
}
