:root {
  color-scheme: dark;
  font-family: "Manrope", Inter, "Segoe UI", sans-serif;
  font-synthesis: none;
  --bg: #090b12;
  --panel: #111522;
  --panel-soft: #171c2b;
  --text: #f6f7fb;
  --muted: #9ca5ba;
  --accent: #9b7cff;
  --accent-2: #38dfbd;
  --line: #293149;
  --focus: #d7ccff;
  --sidebar: 258px;
}

.subtitle-batch-job { border: 1px solid #343b50; border-radius: 14px; padding: 20px; margin-top: 20px; }
.subtitle-batch-job progress { width: 100%; height: 12px; accent-color: var(--accent); }
.subtitle-batch-rows { max-height: 580px; overflow-y: auto; margin: 16px 0; }
.subtitle-batch-row { padding: 16px 0; border-top: 1px solid #343b50; }
.subtitle-batch-row > .pill { margin-left: 12px; }
.subtitle-batch-row select { max-width: 100%; white-space: normal; }
.subtitle-batch-source { margin: 8px 0; overflow-wrap: anywhere; }
.subtitle-batch-source summary { cursor: pointer; padding: 8px 0; }
.subtitle-batch-controls { padding: 16px 0; border-bottom: 1px solid #343b50; margin-bottom: 18px; }
.subtitle-batch-controls select { min-width: 100px; max-width: 100%; background: #171c2b; color: var(--text); padding: 12px; border: 1px solid #343b50; border-radius: 10px; }

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 720px;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

summary[data-focusable] {
  min-height: 44px;
}

::selection {
  background: #8263e8;
  color: #ffffff;
}

input,
textarea {
  caret-color: var(--accent-2);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  width: 100%;
  height: 100%;
  background: var(--bg);
}

.sidebar {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  padding: 32px 20px 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  background: #0c0f19;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 13px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, #a78bfa, #6d4aff);
  box-shadow: 0 12px 30px rgba(109, 74, 255, 0.35);
  font-size: 26px;
  font-weight: 900;
}

.brand-copy {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.05;
}

.nav-list {
  display: grid;
  gap: 10px;
  margin-top: 52px;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 55px;
  gap: 14px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 15px;
  background: transparent;
  color: #aeb6ca;
  font-size: 16px;
  font-weight: 650;
  text-align: left;
}

.nav-item.is-active {
  background: #211d35;
  color: #d7ccff;
}

.nav-icon {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 18px 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-footer strong,
.sidebar-footer small {
  display: block;
}

.sidebar-footer strong {
  font-size: 14px;
}

.sidebar-footer small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.family-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(56, 223, 189, 0.4);
  border-radius: 50%;
  background: rgba(56, 223, 189, 0.12);
  color: #66efd2;
  font-weight: 800;
}

.main-content {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: #4f466d #111522;
  scrollbar-width: thin;
}

.main-content::-webkit-scrollbar,
.card-rail::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.main-content::-webkit-scrollbar-thumb,
.card-rail::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #4f466d;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 34px 52px 22px;
}

.eyebrow {
  display: none;
}

.topbar h1 {
  margin: 0;
  font-size: 29px;
  letter-spacing: -0.035em;
}

.topbar-context {
  margin: 7px 0 0;
  color: #aeb6ca;
  font-size: 13px;
}

.source-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: #b7bfd2;
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f4b942;
  box-shadow: 0 0 0 4px rgba(244, 185, 66, 0.12);
}

.source-status.is-online .status-dot {
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(56, 223, 189, 0.12);
}

.source-status.is-error .status-dot {
  background: #ff6e87;
  box-shadow: 0 0 0 4px rgba(255, 110, 135, 0.12);
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.hero {
  position: relative;
  min-height: 405px;
  margin: 0 52px 34px;
  overflow: hidden;
  border: 0;
  border-radius: 28px;
  background:
    linear-gradient(90deg, rgba(13, 15, 25, 0.98) 0%, rgba(13, 15, 25, 0.82) 42%, rgba(13, 15, 25, 0.18) 75%),
    var(--hero-image, linear-gradient(135deg, #201938, #101928));
  background-position: center;
  background-size: cover;
  box-shadow: 0 28px 70px rgba(2, 4, 12, 0.34);
}

.hero-shade {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background:
    radial-gradient(circle at 78% 30%, transparent 0 20%, rgba(9, 11, 18, 0.12) 56%),
    linear-gradient(0deg, rgba(9, 11, 18, 0.45), transparent 45%);
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(630px, 56%);
  padding: 49px 0 45px 52px;
}

.hero-tags,
.hero-meta,
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hero-tags span {
  padding: 6px 9px;
  border-radius: 7px;
  background: rgba(155, 124, 255, 0.17);
  color: #cabcff;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.11em;
}

.hero-content h2 {
  margin: 19px 0 13px;
  font-size: clamp(35px, 3.2vw, 53px);
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.hero-content > p {
  display: -webkit-box;
  max-width: 580px;
  min-height: 42px;
  margin: 0;
  overflow: hidden;
  color: #b5bdce;
  font-size: 15px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.hero-actions {
  display: flex;
  gap: 13px;
}

.hero-meta {
  margin: 16px 0 24px;
  color: #d4d9e4;
  font-size: 12px;
}

.hero-meta span:not(:last-child)::after,
.detail-meta span:not(:last-child)::after {
  margin-left: 8px;
  color: #596176;
  content: "•";
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
}

.primary-button {
  border: 1px solid transparent;
  background: linear-gradient(135deg, #9e83ff, #7454ee);
  box-shadow: 0 12px 28px rgba(111, 75, 238, 0.25);
}

.primary-button span {
  margin-left: 9px;
  font-size: 20px;
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.07);
}

button:disabled {
  opacity: 0.45;
}

[data-focusable]:focus {
  outline: none;
}

a[data-focusable] {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

[data-focusable].tv-focus,
[data-focusable]:focus {
  border-color: var(--focus) !important;
  box-shadow:
    0 0 0 4px rgba(155, 124, 255, 0.42),
    0 16px 36px rgba(2, 4, 12, 0.4) !important;
  transform: scale(1.025);
}

.nav-item.tv-focus,
.nav-item:focus {
  transform: translateX(7px);
}

.rail-section {
  margin: 0 0 36px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 52px 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.025em;
}

.section-heading span {
  color: #a3acc1;
  font-size: 11px;
}

.card-rail {
  display: flex;
  gap: 17px;
  padding: 8px 52px 28px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.anime-card {
  position: relative;
  flex: 0 0 184px;
  width: 184px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  transition: transform 160ms cubic-bezier(.2,.8,.2,1), box-shadow 160ms cubic-bezier(.2,.8,.2,1);
}

.card-art {
  position: relative;
  width: 100%;
  height: 276px;
  overflow: hidden;
  border-radius: 17px;
  background:
    radial-gradient(circle at 70% 25%, rgba(255, 255, 255, 0.18), transparent 28%),
    linear-gradient(145deg, var(--card-color, #7654e8), #161a2b 75%);
}

.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-fallback {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.78);
  font-size: 45px;
  font-weight: 900;
}

.metadata-language-control { display: flex; align-items: center; gap: 16px; margin: 20px 0 12px; color: #c4c8d6; }
.metadata-language-control select { min-width: 170px; padding: 10px 14px; color: #f5f4ff; background: #1c2131; border: 1px solid #454d64; border-radius: 10px; }
.detail-alt-titles { color: #b6aacd; font-size: 14px; line-height: 1.8; white-space: pre-line; overflow-wrap: anywhere; }
.metadata-source { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; }
.metadata-source a { color: #c5b5ff; text-decoration: underline; }
.hero-metadata-source { display: inline-block; margin: 4px 0 12px; font-size: 13px; color: #c5b5ff; text-decoration: underline; }

.card-score {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  background: rgba(8, 10, 16, 0.78);
  backdrop-filter: blur(8px);
  font-size: 10px;
  font-weight: 800;
}

.card-saved {
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  min-width: 27px;
  min-height: 27px;
  padding: 5px 8px;
  place-items: center;
  border-radius: 999px;
  background: #38dfbd;
  color: #07130f;
  font-size: 13px;
  font-weight: 900;
}

.card-progress-track {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.card-progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #9b7cff;
}

.anime-card h3 {
  margin: 11px 1px 5px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anime-card p {
  margin: 0 1px;
  color: #a3acc1;
  font-size: 11px;
}

.empty-view,
.search-view,
.settings-view {
  margin: 25px 52px;
  padding: 48px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  background: rgba(17, 21, 34, 0.72);
}

.empty-view {
  min-height: 510px;
  text-align: center;
}

.empty-view.is-visible {
  display: grid;
  justify-items: center;
  align-content: center;
}

.empty-view h2,
.search-view h2,
.settings-view h2 {
  margin: 0 0 12px;
  font-size: 34px;
}

.empty-view > p:not(.eyebrow) {
  max-width: 620px;
  margin: 0 0 27px;
  color: var(--muted);
  line-height: 1.65;
}

.empty-icon {
  display: grid;
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 24px;
  background: rgba(155, 124, 255, 0.14);
  color: #b6a4ff;
  font-size: 36px;
}
.empty-icon svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.search-box {
  display: flex;
  align-items: center;
  width: min(760px, 100%);
  min-height: 66px;
  gap: 15px;
  margin-top: 27px;
  padding: 0 20px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 17px;
  background: #111624;
}

.search-box > svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: #aeb6ca;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-box input {
  align-self: stretch;
  flex: 1;
  min-height: 44px;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 20px;
}

.search-box:focus-within {
  border-color: white;
  box-shadow: 0 0 0 4px rgba(155, 124, 255, 0.48);
}

.search-input.tv-focus {
  transform: none;
}

.search-hint {
  color: #a3acc1;
  font-size: 13px;
  line-height: 1.5;
}

.search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 22px;
  margin-top: 32px;
}

.search-results .anime-card {
  width: 100%;
}

.search-intro {
  max-width: 70ch;
  margin: 0;
  color: #b6bfd2;
  line-height: 1.6;
}

.media-kind-switch {
  display: flex;
  width: max-content;
  max-width: calc(100% - 104px);
  gap: 6px;
  margin: 0 52px 24px;
  padding: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #111522;
}

.media-kind-switch::-webkit-scrollbar {
  display: none;
}

.media-kind-switch button {
  min-width: 104px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #aeb6ca;
  font-weight: 750;
  white-space: nowrap;
}

.media-kind-switch button.is-active {
  background: #302653;
  color: #ffffff;
}

.search-kind-switch {
  margin: 24px 0 0;
  max-width: 100%;
}

.general-discovery .section-heading > div {
  min-width: 0;
}

.general-discovery .section-heading p {
  margin: 7px 0 0;
  color: #a3acc1;
  font-size: 12px;
}

.discovery-empty {
  display: grid;
  min-height: 220px;
  margin: 0 52px 34px;
  justify-items: start;
  align-content: center;
  gap: 10px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #111522;
}

.discovery-empty strong {
  font-size: 20px;
}

.discovery-empty span {
  max-width: 65ch;
  color: #b6bfd2;
  line-height: 1.55;
}

.discovery-empty .primary-button {
  margin-top: 10px;
}

.settings-view {
  max-width: 950px;
}

.collection-view {
  margin: 25px 52px 80px;
}

#search-view {
  border: 0;
  background: transparent;
  padding: 20px 0;
}

.collection-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
}

.collection-header h2 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.035em;
}

.collection-header > span {
  color: var(--muted);
  font-size: 12px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 26px 19px;
}

.media-grid .anime-card {
  width: 100%;
}

.source-gate {
  display: grid;
  min-height: 560px;
  justify-items: center;
  align-content: center;
  padding: 50px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 30%, rgba(155, 124, 255, 0.12), transparent 34%),
    rgba(17, 21, 34, 0.72);
  text-align: center;
}

.source-gate h2 {
  margin: 0 0 13px;
  font-size: 34px;
}

.source-gate > p:not(.eyebrow) {
  max-width: 650px;
  margin: 0 0 27px;
  color: var(--muted);
  line-height: 1.65;
}

.inline-empty {
  padding: 42px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
}

.settings-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 89px;
  margin-top: 16px;
  padding: 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 17px;
  background: #0d101a;
}

.settings-panel {
  margin-top: 19px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 19px;
  background: #0d101a;
}

.settings-panel-heading,
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-panel-heading strong,
.settings-panel-heading small {
  display: block;
}

.settings-panel-heading strong {
  margin-bottom: 7px;
  font-size: 16px;
}

.settings-panel-heading small {
  color: var(--muted);
  font-size: 12px;
}

.settings-input,
.pin-field,
.auth-field,
.server-details label {
  display: grid;
  gap: 8px;
}

.settings-input {
  margin: 23px 0 18px;
}

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

.settings-grid .settings-wide {
  grid-column: 1 / -1;
}

.settings-input > span,
.pin-field > span,
.auth-field > span,
.server-details label > span {
  color: #aeb6c7;
  font-size: 12px;
  font-weight: 700;
}

.settings-input input,
.pin-field input,
.auth-field input,
.settings-input select,
.server-details input {
  width: 100%;
  min-height: 53px;
  padding: 0 15px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 13px;
  outline: none;
  background: #090c14;
  color: white;
}

.settings-input select {
  padding: 0 15px;
}

.settings-actions {
  justify-content: flex-start;
}

.settings-message {
  min-height: 18px;
  margin: 15px 0 0;
  color: #8993a8;
  font-size: 12px;
}

.text-button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #b8c0d1;
  font-size: 13px;
  font-weight: 700;
}

.text-button.danger {
  color: #ff8397;
}

.settings-card strong,
.settings-card small {
  display: block;
}

.settings-card strong {
  margin-bottom: 7px;
  font-size: 15px;
}

.settings-card small {
  color: #818ba1;
  font-size: 12px;
}

.pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(56, 223, 189, 0.12);
  color: #70ead1;
  font-size: 10px;
  font-weight: 800;
}

.pill.is-muted {
  background: rgba(255, 255, 255, 0.07);
  color: #9ba4b6;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(3, 5, 10, 0.82);
  backdrop-filter: blur(18px);
}

.detail-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  width: min(1180px, 94vw);
  max-height: 92vh;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  background: #111521;
  box-shadow: 0 45px 100px rgba(0, 0, 0, 0.58);
}

.detail-cover {
  min-height: 460px;
  background:
    radial-gradient(circle at 72% 24%, rgba(255, 255, 255, 0.18), transparent 26%),
    linear-gradient(145deg, var(--detail-color, #7654e8), #121624 75%);
  background-position: center;
  background-size: cover;
}

.detail-copy {
  padding: 28px 30px 32px;
  min-height: 0;
  max-height: 92vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.detail-copy h2 {
  margin: 0 38px 10px 0;
  font-size: 27px;
  line-height: 1.22;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}

.detail-meta {
  color: #aeb6c7;
  font-size: 12px;
}

.detail-description {
  margin: 14px 0;
  color: #aeb6c7;
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
}

.detail-overview { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; color: #adb7ca; font-size: 12px; }
.detail-message { margin: 10px 0; color: #c2afef; font-size: 13px; line-height: 1.5; }
.detail-message:empty { display: none; }
.detail-source-loading { margin: 16px 0 20px; padding: 20px; border: 1px solid #494063; border-radius: 14px; background: linear-gradient(120deg, #211b34, #171d2c); }
.detail-loading-heading { display: flex; align-items: center; gap: 14px; }
.detail-loading-heading strong { display: block; color: #f3edff; font-size: 16px; }
.detail-loading-heading p { margin: 7px 0 0; color: #bcb2d0; font-size: 13px; line-height: 1.6; }
.detail-loading-spinner { width: 24px; height: 24px; flex-shrink: 0; border: 3px solid #46365f; border-top-color: #b798ff; border-right-color: #b798ff; border-radius: 50%; animation: detail-loading-spin .85s linear infinite; }
.detail-loading-skeleton { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.detail-loading-skeleton span { height: 54px; border-radius: 10px; background: linear-gradient(100deg, #28233a 20%, #3b3052 50%, #28233a 80%); background-size: 250% 100%; animation: detail-loading-shimmer 1.6s ease-in-out infinite; }
@keyframes detail-loading-spin { to { transform: rotate(360deg); } }
@keyframes detail-loading-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .detail-loading-spinner, .detail-loading-skeleton span { animation: none; } }
@media (max-width: 650px) { .detail-source-loading { padding: 16px; } .detail-loading-skeleton { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.detail-episode-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 15px 0 10px; }
.detail-episode-heading label { display: flex; align-items: center; gap: 10px; color: #aeb6c7; font-size: 13px; }
.detail-episode-heading select { min-width: 145px; padding: 9px 12px; color: #f4f5ff; border: 1px solid #40475c; border-radius: 10px; background: #1b2031; }
.detail-copy .episode-section { margin-top: 0; }
.detail-copy .episode-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; max-height: 182px; overflow-y: auto; padding: 5px; margin: 0 -5px; }
.detail-episode { min-height: 57px; padding: 9px; border: 1px solid #343c51; border-radius: 10px; background: #1b2031; color: #c1c8db; text-align: left; cursor: pointer; }
.detail-episode strong, .detail-episode small { display: block; }
.detail-episode small { font-size: 10px; margin-top: 5px; line-height: 1.3; }
.detail-episode[aria-pressed="true"] { border-color: #aa8cff; background: #392b5b; color: #fff; box-shadow: inset 0 0 0 1px #aa8cff; }
.detail-episode.is-ready small, .detail-state.is-ready { color: #62e9ba; }
.detail-episode.is-working small, .detail-state.is-working { color: #d4bdff; }
.detail-episode.is-warning small, .detail-state.is-warning { color: #ffcd83; }
.detail-watch { position: relative; margin-top: 15px; padding: 17px; border: 1px solid #343c51; border-radius: 14px; background: #171d2c; }
.detail-watch h3 { margin: 0 0 8px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.detail-state { display: inline-block; font-size: 13px; color: #bac3d5; margin-bottom: 13px; }
.ready-section { margin-top: 0; padding: 20px 0; }
.ready-rail .anime-card { width: 185px; flex: 0 0 185px; }
.ready-rail .card-art { height: 116px; }
.card-availability { display: block; margin-top: 7px; font-size: 11px; line-height: 1.4; color: #a6aec3; }
.card-availability.is-ready { color: #62e9ba; }
.card-source-prefetch { display: block; margin-top: 6px; color: #aab2c7; font-size: 11px; line-height: 1.45; white-space: normal; }
.card-source-prefetch[hidden] { display: none; }
.card-source-prefetch[data-state="ready"] { color: #c9b7ff; }
.card-source-prefetch[data-state="queued"], .card-source-prefetch[data-state="searching"], .card-source-prefetch[data-state="preparing"] { color: #c5c9dc; }
.card-source-prefetch[data-state="searching"]::before, .card-source-prefetch[data-state="preparing"]::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border: 1px solid #635878; border-top-color: #c9b7ff; border-radius: 50%; animation: source-prefetch-spin 1s linear infinite; }
@keyframes source-prefetch-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .card-source-prefetch::before { animation: none !important; } }
#detail-advanced { margin-bottom: 16px; }
#detail-advanced > summary { padding-bottom: 14px; }
#detail-episodes-empty { padding: 18px; font-size: 13px; line-height: 1.65; }
#detail-find-subtitle { color: #d1bdff; }
.detail-watch progress { width: 100%; height: 7px; display: block; }
.detail-watch > small { display: block; margin: 7px 0 14px; color: #abb4c8; font-size: 11px; }
.download-info { display: grid; grid-template-columns: minmax(100px, .8fr) minmax(0, 2fr); gap: 7px 12px; font-size: 12px; line-height: 1.45; margin: 0 0 14px; }
.download-info dt { color: #a8b3ca; }
.download-info dd { margin: 0; color: #e1e7f4; overflow-wrap: anywhere; }
.detail-storage { margin: 14px 0; padding: 12px 14px; border: 1px solid #343c51; border-radius: 10px; background: #151a28; }
.detail-storage summary { cursor: pointer; color: #c8d3e5; font-size: 13px; }
.detail-storage .download-info { margin-top: 14px; }
.detail-watch #detail-download-info { max-height: none; }
.storage-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-top: 16px; }
.storage-form label { display: grid; gap: 7px; color: #b8c4d9; font-size: 12px; }
.storage-form label:nth-child(2) { flex: 1; min-width: 180px; }
.storage-form input, .storage-form select { width: 100%; min-height: 40px; background: #0d1220; color: #eef2ff; border: 1px solid #59647d; border-radius: 7px; padding: 8px; }
.storage-form p { flex-basis: 100%; margin: 0; }
.season-confirm { margin: 10px 0; padding: 14px; border: 1px solid #74619e; border-radius: 10px; background: #24203b; font-size: 13px; line-height: 1.6; }
.season-actions { margin: 16px 0 0; flex-wrap: wrap; }
#detail-season-download { margin: 0 0 12px; }
.player-track { position: relative; }
#player-seek { position: absolute; top: -12px; right: 0; bottom: -12px; left: 0; width: 100%; height: 28px; margin: 0; opacity: .01; cursor: pointer; }
#player-seek:focus { opacity: .8; }
#player-quality { font-size: 12px; color: #d2d8e6; white-space: nowrap; }
#player-toggle, #player-fullscreen { width: auto; min-width: 64px; min-height: 44px; padding: 0 14px; border-radius: 8px; font-size: 12px; font-weight: 800; }
.player-modal.hud-hidden { cursor: none; }
.player-topbar, .player-controls, .player-gradient { transition: opacity .2s; }
.player-modal.hud-hidden .player-topbar, .player-modal.hud-hidden .player-controls, .player-modal.hud-hidden .player-gradient { opacity: 0; visibility: hidden; pointer-events: none; }
.playback-options { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.playback-options label { display: grid; gap: 5px; flex: 1; min-width: 110px; color: #d7e0ef; font-size: 12px; }
.playback-options select { min-height: 36px; max-width: 100%; padding: 6px; border: 1px solid #65718a; border-radius: 7px; background: #192232; color: #f3f5ff; }
.playback-options small { flex-basis: 100%; color: #b8c4d9; font-size: 11px; line-height: 1.5; }
#player-options { position: absolute; right: 0; bottom: 58px; max-width: 660px; padding: 12px; background: rgba(8, 13, 22, .82); border-radius: 10px; }
@media (max-width: 700px) { #player-options { left: 0; right: 0; bottom: 58px; } .playback-options label { min-width: 85px; } }
.detail-watch progress:indeterminate { opacity: .7; }
.detail-watch .playback-note { margin-top: 10px; font-size: 12px; line-height: 1.5; }
.detail-watch button:disabled { opacity: .45; cursor: not-allowed; }
.detail-secondary-actions { display: flex; flex-wrap: wrap; gap: 14px; margin: 15px 0; }
.detail-secondary-actions button { font-size: 12px; text-align: left; }
.detail-information, .detail-match { border-top: 1px solid #30374a; padding-top: 14px; }
.detail-information summary, .detail-match summary { cursor: pointer; color: #d8dbee; font-size: 14px; }
.detail-match { margin: 14px 0; }
.detail-match label { display: block; font-size: 12px; margin: 12px 0 8px; }
.detail-match form > div { display: flex; gap: 8px; }
.detail-match input { width: 100%; min-width: 0; border: 1px solid #41495e; border-radius: 9px; padding: 10px; background: #1b2031; color: #fff; }
.detail-candidates { max-height: 210px; overflow-y: auto; display: grid; gap: 8px; margin-top: 10px; padding: 4px; }
.detail-candidate { text-align: left; color: #e0e5f3; background: #1b2031; border: 1px solid #41495e; border-radius: 10px; padding: 12px; cursor: pointer; }
.detail-candidate strong, .detail-candidate small { display: block; }
.detail-candidate small { margin-top: 6px; color: #b5a4e1; }
.managed-card.is-interactive { cursor: pointer; }

@media (max-width: 620px) {
  .detail-panel .detail-cover { display: none; }
  .modal .detail-panel { grid-template-columns: minmax(0, 1fr); }
  .detail-copy .detail-actions { flex-direction: row; gap: 8px; }
  .detail-copy .detail-actions > button { min-height: 44px; padding: 10px 15px; }
  .detail-copy .detail-watch { position: static; }
}

.playback-note {
  min-height: 18px;
  margin: 16px 0 0;
  color: #7f889c;
  font-size: 11px;
}

.legal-sources {
  margin-top: 21px;
}

.legal-sources > strong {
  display: block;
  margin: 15px 0 10px;
  color: #c4cbda;
  font-size: 12px;
}

.legal-sources > div {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.legal-sources a {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: #cabfff;
  font-size: 11px;
  text-decoration: none;
}

.legal-sources a.is-exact {
  border-color: rgba(67, 220, 175, 0.38);
  background: rgba(30, 171, 130, 0.12);
  color: #78efcd;
}

.legal-sources a.is-suggested {
  border-color: rgba(249, 188, 85, 0.35);
  color: #f4cf8d;
}

.official-source-message {
  color: #8e97aa;
  font-size: 11px;
  line-height: 1.5;
}

.legal-sources-note {
  margin: 11px 0 0;
  color: #7f889c;
  font-size: 11px;
  line-height: 1.5;
}

.episode-section {
  margin-top: 22px;
}

.episode-section > strong {
  display: block;
  margin-bottom: 10px;
  color: #c4cbda;
  font-size: 12px;
}

.episode-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.episode-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 53px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  text-align: left;
}

.episode-button span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.episode-button small {
  overflow: hidden;
  color: #c8cede;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  position: absolute;
  z-index: 5;
  top: 20px;
  right: 20px;
  width: 45px;
  height: 45px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  background: rgba(7, 9, 15, 0.7);
}
.modal-close svg, .player-back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 36px;
  max-width: 720px;
  padding: 14px 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  background: rgba(20, 24, 37, 0.97);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  color: #e6e8ee;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.auth-screen {
  position: fixed;
  z-index: 50;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 40px;
  background:
    radial-gradient(circle at 75% 20%, rgba(109, 74, 255, 0.25), transparent 35%),
    radial-gradient(circle at 20% 80%, rgba(56, 223, 189, 0.12), transparent 30%),
    #080a11;
}

.auth-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: rgba(133, 95, 255, 0.16);
  filter: blur(120px);
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(520px, 92vw);
  padding: 42px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 28px;
  background: rgba(17, 21, 34, 0.94);
  box-shadow: 0 50px 100px rgba(0, 0, 0, 0.42);
  text-align: center;
}

.auth-copy {
  margin: -13px auto 22px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.auth-field {
  margin-bottom: 14px;
  text-align: left;
}

.auth-switches {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-top: 9px;
}

.auth-logo {
  display: grid;
  width: 68px;
  height: 68px;
  margin: 0 auto 25px;
  place-items: center;
  border-radius: 21px;
  background: linear-gradient(135deg, #b4a0ff, #6d4aff);
  box-shadow: 0 18px 40px rgba(109, 74, 255, 0.36);
  font-size: 37px;
  font-weight: 900;
}

.auth-card h1 {
  margin: 0 0 26px;
  font-size: 32px;
  letter-spacing: -0.04em;
}

.profile-picker {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 23px;
}

.profile-choice {
  display: grid;
  min-width: 110px;
  gap: 8px;
  justify-items: center;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.profile-choice > span {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: rgba(56, 223, 189, 0.14);
  color: var(--profile-color);
  font-size: 22px;
  font-weight: 850;
}

.profile-choice.is-selected {
  border-color: var(--profile-color);
  background: rgba(255, 255, 255, 0.08);
}

.pin-field {
  margin-bottom: 16px;
  text-align: left;
}

.pin-field input {
  text-align: center;
  font-size: 25px;
  letter-spacing: 0.32em;
}

.auth-submit {
  width: 100%;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 25px;
}

.media-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.media-tool-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 15px;
  background: #090c14;
}

.media-tool-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.media-tool-heading h3 { margin: 0; font-size: 20px; }
.media-tool-badge { color: var(--accent-2); font-size: 10px; }
.media-tool-purpose { color: var(--muted); font-size: 13px; min-height: 34px; }
.media-tool-endpoint { color: var(--muted); overflow-wrap: anywhere; margin: 4px 0 12px; }
.media-tool-card .settings-input { margin: 0 0 13px; }
.media-tool-card .settings-actions { flex-wrap: wrap; gap: 9px; }
.media-tool-card .text-button { font-size: 12px; }
.media-tool-message { margin-top: 14px; overflow-wrap: anywhere; }

@media (max-width: 600px) {
  .media-tools-grid { grid-template-columns: minmax(0, 1fr); }
}

.admin-stats > div {
  display: grid;
  gap: 4px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 17px;
  background: #0d101a;
}

.admin-stats strong {
  color: var(--accent-2);
  font-size: 28px;
}

.admin-stats span,
.admin-identity small,
.audit-row small {
  color: var(--muted);
  font-size: 11px;
}

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 145px 145px auto auto;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 13px;
  background: #090c14;
}

.admin-row select {
  min-height: 44px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  background: #111624;
  color: white;
}

.admin-identity {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.admin-identity strong,
.admin-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invite-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.audit-row {
  display: grid;
  gap: 5px;
  padding: 11px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.small-button {
  min-height: 44px;
  padding: 0 13px;
}

.secret-result {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 17px;
  padding: 13px;
  border: 1px solid rgba(56, 223, 189, 0.24);
  border-radius: 12px;
  background: rgba(56, 223, 189, 0.07);
}

.secret-result code {
  flex: 1;
  overflow-wrap: anywhere;
  color: #8cf4de;
}

.registration-options .is-selected {
  border-color: var(--accent-2);
  background: rgba(56, 223, 189, 0.12);
}

.auth-status {
  min-height: 18px;
  margin: 15px 0 0;
  color: #7f8aa0;
  font-size: 11px;
}

.auth-status.is-error {
  color: #ff8295;
}

.server-details {
  margin-top: 20px;
  color: #7e8799;
  font-size: 11px;
  text-align: left;
}

.server-details label {
  margin-top: 15px;
}

.player-modal {
  position: fixed;
  z-index: 40;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #030407;
}

.player-modal video {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player-gradient {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.68), transparent 20%, transparent 72%, rgba(0, 0, 0, 0.85));
}

.player-topbar {
  position: absolute;
  z-index: 2;
  top: 34px;
  right: 42px;
  left: 42px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.player-topbar strong,
.player-topbar small {
  display: block;
}

.player-topbar small {
  margin-top: 4px;
  color: #a5adbd;
}

.player-back,
.player-controls button {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(12, 14, 22, 0.75);
  font-size: 19px;
}

.player-gate {
  position: relative;
  z-index: 2;
  display: grid;
  width: min(620px, 86vw);
  justify-items: center;
  padding: 45px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 27px;
  background: rgba(15, 18, 29, 0.94);
  text-align: center;
}

.player-gate h2 {
  margin: 0 0 12px;
  font-size: 34px;
}

.player-gate > p:not(.eyebrow) {
  max-width: 470px;
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.player-controls {
  position: absolute;
  z-index: 2;
  right: 50px;
  bottom: 35px;
  left: 50px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.player-controls > span {
  min-width: 120px;
  font-size: 12px;
}

.player-track {
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
}

.player-progress {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #9b7cff;
}

@media (max-height: 800px) {
  .topbar {
    padding-top: 24px;
  }

  .hero {
    min-height: 350px;
  }

  .hero-content {
    padding-top: 36px;
  }

  .anime-card {
    flex-basis: 160px;
    width: 160px;
  }

  .card-art {
    height: 240px;
  }
}

@media (max-width: 900px) {
  body {
    min-height: 100%;
    overflow: auto;
  }

  .app-shell {
    display: block;
    min-height: 100%;
  }

  .sidebar {
    position: fixed;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    height: 74px;
    padding: 7px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .brand,
  .sidebar-footer {
    display: none;
  }

  .nav-list {
    display: grid;
    grid-auto-columns: minmax(72px, 1fr);
    grid-auto-flow: column;
    gap: 2px;
    margin: 0;
    min-width: max-content;
  }

  .nav-item {
    display: grid;
    min-height: 58px;
    justify-items: center;
    gap: 2px;
    padding: 4px;
    font-size: 9px;
    text-align: center;
  }

  .nav-icon {
    width: 21px;
    height: 21px;
  }

  .main-content {
    min-height: 100vh;
    padding-bottom: 90px;
  }

  .topbar {
    padding: 24px 20px 18px;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .topbar-context {
    font-size: 12px;
  }

  .media-kind-switch {
    max-width: calc(100% - 40px);
    margin: 0 20px 20px;
  }

  .media-kind-switch button {
    min-width: 92px;
  }

  .search-kind-switch {
    max-width: 100%;
    margin: 22px 0 0;
  }

  .discovery-empty {
    margin: 0 20px 28px;
    padding: 24px;
  }

  .source-status {
    display: none;
  }

  .hero {
    min-height: 470px;
    margin: 0 20px 28px;
    background-position: 62% center;
  }

  .hero-content {
    width: 100%;
    padding: 190px 25px 30px;
  }

  .hero-content h2 {
    font-size: 34px;
  }

  .section-heading {
    padding: 0 20px 12px;
  }

  .card-rail {
    padding: 8px 20px 26px;
  }

  .anime-card {
    flex-basis: 150px;
    width: 150px;
  }

  .card-art {
    height: 225px;
  }

  .collection-view,
  .search-view,
  .settings-view {
    margin: 15px 20px 90px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .media-grid .card-art {
    height: 245px;
  }

  .source-gate {
    min-height: 520px;
    padding: 26px;
  }

  .detail-panel {
    grid-template-columns: 88px minmax(0, 1fr);
    width: 92vw;
    max-height: 88vh;
    overflow: hidden;
  }

  .detail-cover {
    min-height: 0;
    background-position: center;
  }

  .detail-copy {
    padding: 20px 16px 28px;
    max-height: 88vh;
  }

  .detail-copy h2 {
    font-size: 21px;
  }

  .detail-actions,
  .settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-grid,
  .episode-list {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }

  .admin-row {
    grid-template-columns: 1fr 1fr;
  }

  .admin-identity {
    grid-column: 1 / -1;
  }

  .settings-grid .settings-wide {
    grid-column: auto;
  }

  .auth-screen {
    padding: 18px;
  }

  .auth-card {
    padding: 30px 22px;
  }
}
/* On-demand downloads: one readable working surface for phone, desktop and remote. */
.release-search-form { display: grid; grid-template-columns: minmax(180px, 1fr) 140px 210px auto; gap: 16px; align-items: end; margin: 26px 0 12px; }
.release-search-form.is-automatic { grid-template-columns: minmax(180px, 1fr) 160px auto; }
.managed-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.managed-card { display: flex; padding: 16px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 16px; background: var(--panel); }
.managed-poster { width: 86px; height: 128px; object-fit: cover; border-radius: 8px; margin-right: 16px; flex-shrink: 0; }
.managed-card-detail { display: flex; flex-direction: column; min-width: 0; }
.managed-card-detail strong { font-size: 18px; overflow-wrap: anywhere; }
.managed-card-detail small { color: var(--muted); margin: 8px 0 12px; }
.managed-card-detail button { margin-top: auto; }
.managed-selection { margin: 20px 0; }
.managed-selection h3 { margin-top: 0; }
.managed-selection .settings-actions { align-items: end; }
.managed-selection select { max-width: 520px; }
@media (max-width: 1250px) { .managed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 650px) { .managed-grid { grid-template-columns: 1fr; } .managed-selection .settings-actions { display: grid; } }
.release-filter-row { display: flex; gap: 18px; margin: 16px 0; }
.release-filter-row .settings-input { min-width: 190px; }
.download-list { display: grid; gap: 12px; }
.download-row { display: flex; gap: 22px; justify-content: space-between; align-items: center; padding: 20px; border: 1px solid rgba(255,255,255,.10); border-radius: 14px; background: rgba(255,255,255,.035); }
.download-detail { min-width: 0; flex: 1; }
.download-detail strong { display: block; overflow-wrap: anywhere; line-height: 1.5; }
.download-detail small { display: block; margin-top: 7px; color: #a5aec1; line-height: 1.5; }
.download-row button { flex-shrink: 0; }
.download-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.delivery-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding: 0; list-style-position: inside; line-height: 1.6; }
.delivery-steps li { padding: 18px; border: 1px solid rgba(155, 124, 255, .3); border-radius: 12px; background: var(--panel); }
#delivery-title { overflow-wrap: anywhere; }
@media (max-width: 900px) { .delivery-steps { grid-template-columns: 1fr; } }
.download-detail progress { display: block; width: 100%; height: 8px; margin-top: 13px; }
.download-queue-panel { margin-top: 32px; }
.request-row { margin-top: 12px; }
.release-confirm { border-color: #39d9b6; }
.release-confirm p { overflow-wrap: anywhere; line-height: 1.6; }
.source-presets-panel summary { cursor: pointer; font-size: 20px; padding: 8px 0; }
.source-status-list { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.source-warning { color: #ffcd8a; border-color: rgba(255, 205, 138, .4); }
.subtitle-title-field { flex: 1; min-width: 0; }
#subtitles-view select { max-width: 100%; }
#subtitles-view .settings-actions { align-items: end; }
#subtitle-detail > .settings-input { display: block; margin: 22px 0 14px; }
#subtitle-detail h3 { margin-top: 0; }
#subtitle-results { margin: 22px 0; }
#subtitle-confirm { border-color: var(--mint, #38dfbd); }
.subtitle-replace-label { display: flex; align-items: center; gap: 12px; min-height: 44px; line-height: 1.6; margin: 18px 0; }
.subtitle-replace-label input { width: 24px; height: 24px; flex-shrink: 0; accent-color: #9b7cff; }
.subtitle-file-status .settings-message { overflow-wrap: anywhere; }
.source-preset strong, .source-preset small { display: block; }
.source-preset small { color: #a5aec1; margin-top: 8px; }
@media (max-width: 1050px) {
  .release-search-form, .release-search-form.is-automatic { grid-template-columns: minmax(0, 1fr) 160px; }
  .release-search-form > button { grid-column: 1 / -1; }
  .download-row { align-items: stretch; flex-direction: column; gap: 14px; }
}
@media (max-width: 620px) {
  .release-search-form, .release-search-form.is-automatic { grid-template-columns: 1fr; }
  .release-filter-row { flex-direction: column; }
  .download-row { padding: 15px; }
  .source-presets-panel summary { font-size: 17px; }
}
.subtitle-preview { margin-top: 16px; padding: 16px; border: 1px solid #3a4154; border-radius: 12px; background: #121624; }
.subtitle-preview p { display: grid; gap: 5px; margin: 14px 0 0; }
.subtitle-preview p span { white-space: pre-wrap; line-height: 1.55; color: #f4f5fa; overflow-wrap: anywhere; }
.subtitle-preview small { color: #aeb8ca; }
/* Original-site viewing is intentionally distinct from local, verified playback. */
.external-watch { margin: 20px 0 26px; padding: 20px; border: 1px solid #565077; border-radius: 18px; background: #19182a; }
.external-watch-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.external-watch .detail-actions { align-items: center; flex-wrap: wrap; }
.external-watch a { color: #d1c2ff; text-decoration: none; }
.external-watch a.secondary-button { display: inline-flex; align-items: center; }
.external-watch-warning { color: #ccbda3; font-size: .84rem; line-height: 1.6; }
.external-watch summary { margin-top: 16px; cursor: pointer; }
.external-watch form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.external-watch form > label:first-child { flex-basis: 100%; font-size: .9rem; }
.external-watch input:not([type=checkbox]) { flex: 1 1 250px; min-width: 0; padding: 12px; border: 1px solid #565077; border-radius: 10px; color: #fff; background: #101220; }
.avs-confirm { display: flex; gap: 10px; align-items: center; min-height: 44px; font-size: .85rem; width: 100%; }
.avs-loading { display:flex; align-items:center; gap:10px; margin:16px 0; color:#d1c2ff; }
.avs-spinner { display:inline-block; width:18px; height:18px; border:2px solid #565077; border-top-color:#ba9aff; border-radius:50%; animation:avs-spin .8s linear infinite; }
@keyframes avs-spin { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion:reduce) { .avs-spinner { animation:none; } }
.avs-candidates { display:grid; gap:8px; margin:12px 0; }
.avs-candidate { display:flex; flex-direction:column; gap:6px; padding:12px; border:1px solid #565077; border-radius:10px; }
.avs-candidate span { font-size:.8rem; color:#aca7b8; }
.avs-loading[hidden],.avs-candidates[hidden] { display:none; }
.clean-guide { max-width: 900px; margin: 40px auto; padding: 24px; line-height: 1.7; }
.clean-guide h1 { font-size: 2rem; line-height: 1.2; }
.clean-guide a { color: #c7b4ff; }
.clean-guide .settings-panel { margin: 24px 0; }
.clean-guide code { overflow-wrap: anywhere; }
.clean-guide li { margin: 12px 0; }
.discovery-filters { display: flex; align-items: end; flex-wrap: wrap; gap: 14px; margin: 16px 0; }
.discovery-filters label { display: grid; gap: 7px; color: #c8cce0; font-size: .85rem; }
.discovery-filters select, .discovery-filters input { min-height: 44px; border: 1px solid #434963; border-radius: 10px; padding: 8px 12px; color: #f6f4ff; background: #1b2032; }
.discovery-filters input { width: 110px; }
.card-airing { display: block; font-size: .72rem; color: #c7b6ff; line-height: 1.5; margin-top: 6px; white-space: normal; }
.audio-controls { display: flex; flex-basis: 100%; align-items: center; gap: 10px; }
.audio-controls button { padding: 7px 10px; border: 1px solid #65718a; border-radius: 7px; background: #192232; color: #fff; font-size: 12px; }
.audio-controls input { width: 100%; min-width: 60px; }
#player-options { max-height: 65vh; overflow-y: auto; }
#telegram-panel code { color: #d4c3ff; }
@media (prefers-reduced-motion: no-preference) { #season-results[aria-busy=true] { opacity: .6; transition: opacity .2s; } }
@media (prefers-reduced-motion: reduce) {
  .card-rail { scroll-behavior: auto; }
  .anime-card, .player-topbar, .player-controls, .player-gradient { transition: none; }
  [data-focusable].tv-focus, [data-focusable]:focus { transform: none; }
}

/* Phone layout: readable, thumb-first and fully discoverable without horizontal menu hunting. */
@media (max-width: 640px) {
  html,
  body {
    min-height: 100%;
  }

  .sidebar {
    height: auto;
    padding:
      7px max(8px, env(safe-area-inset-right))
      max(7px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    overflow: visible;
    background: #0c0f19;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-flow: row;
    grid-auto-columns: auto;
    width: 100%;
    min-width: 0;
    gap: 3px;
  }

  .nav-item {
    min-width: 0;
    min-height: 52px;
    gap: 3px;
    padding: 5px 3px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.1;
  }

  .nav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
  }

  .nav-item.tv-focus,
  .nav-item:focus {
    transform: none;
  }

  .main-content {
    padding-bottom: calc(126px + env(safe-area-inset-bottom));
  }

  .topbar {
    position: sticky;
    z-index: 4;
    top: 0;
    padding:
      max(15px, env(safe-area-inset-top))
      16px 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(9, 11, 18, 0.96);
  }

  .topbar h1 {
    font-size: 24px;
    line-height: 1.15;
  }

  .topbar-context {
    display: none;
  }

  .media-kind-switch,
  .search-kind-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: auto;
    max-width: none;
    gap: 6px;
    margin: 14px 16px 22px;
  }

  .search-kind-switch {
    margin: 20px 0 0;
  }

  .media-kind-switch button {
    width: 100%;
    min-width: 0;
    padding: 0 10px;
    font-size: 14px;
  }

  .ready-section {
    padding-top: 4px;
  }

  .section-heading {
    align-items: flex-end;
    gap: 12px;
    padding: 0 16px 11px;
  }

  .section-heading h2 {
    font-size: 20px;
    line-height: 1.2;
  }

  .section-heading span {
    flex-shrink: 0;
    font-size: 12px;
  }

  .card-rail {
    gap: 12px;
    padding: 7px 16px 23px;
    scroll-padding-inline: 16px;
  }

  .ready-rail .anime-card {
    flex-basis: min(74vw, 280px);
    width: min(74vw, 280px);
  }

  .ready-rail .card-art {
    height: 164px;
    border-radius: 14px;
  }

  .anime-card {
    flex-basis: 44vw;
    width: 44vw;
  }

  .card-art {
    height: 66vw;
    max-height: 258px;
    border-radius: 14px;
  }

  .anime-card h3 {
    margin-top: 10px;
    font-size: 15px;
    line-height: 1.35;
  }

  .anime-card p,
  .card-availability,
  .card-source-prefetch {
    font-size: 12px;
    line-height: 1.45;
  }

  .hero {
    min-height: 390px;
    margin: 0 16px 30px;
    border-radius: 20px;
    background-position: 66% center;
  }

  .hero-shade {
    background:
      linear-gradient(0deg, rgba(9, 11, 18, 0.98) 0%, rgba(9, 11, 18, 0.74) 48%, rgba(9, 11, 18, 0.08) 78%),
      linear-gradient(90deg, rgba(9, 11, 18, 0.72), transparent 74%);
  }

  .hero-content {
    width: 100%;
    padding: 148px 18px 22px;
  }

  .hero-content h2 {
    margin: 13px 0 9px;
    font-size: 30px;
    line-height: 1.08;
  }

  .hero-content > p {
    min-height: 0;
    font-size: 14px;
    -webkit-line-clamp: 3;
  }

  .hero-meta {
    margin: 12px 0 16px;
    font-size: 12px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .hero-actions > * {
    width: 100%;
    min-width: 0;
    padding: 0 11px;
  }

  .collection-view,
  .search-view,
  .settings-view {
    margin: 10px 14px calc(140px + env(safe-area-inset-bottom));
  }

  .collection-header {
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 20px;
  }

  .collection-header h2,
  .empty-view h2,
  .search-view h2,
  .settings-view h2 {
    font-size: 28px;
    line-height: 1.15;
  }

  .collection-header > span {
    padding-top: 7px;
    font-size: 12px;
  }

  .media-grid,
  .search-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 11px;
  }

  .media-grid .card-art,
  .search-results .card-art {
    height: 58vw;
    max-height: 232px;
  }

  .search-box {
    min-height: 56px;
    margin-top: 20px;
    padding: 0 14px;
    border-radius: 14px;
  }

  .search-box input,
  .settings-input input,
  .settings-input select,
  .server-details input {
    font-size: 16px;
  }

  .search-hint,
  .search-intro,
  .settings-message,
  .settings-panel-heading small {
    font-size: 13px;
    line-height: 1.55;
  }

  .settings-panel {
    margin-top: 14px;
    padding: 17px 15px;
    border-radius: 16px;
  }

  .settings-panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .settings-panel-heading strong {
    font-size: 17px;
    line-height: 1.35;
  }

  .settings-input {
    margin: 17px 0 13px;
  }

  .settings-input > span,
  .pin-field > span,
  .auth-field > span,
  .server-details label > span {
    font-size: 13px;
  }

  .settings-actions {
    gap: 8px;
  }

  .settings-actions > button,
  .settings-actions > a {
    width: 100%;
  }

  .admin-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 15px;
  }

  .admin-identity {
    grid-column: auto;
  }

  .managed-card {
    padding: 14px;
  }

  .managed-poster {
    width: 72px;
    height: 108px;
    margin-right: 12px;
  }

  .modal {
    place-items: end stretch;
  }

  .modal-backdrop {
    display: none;
  }

  .modal .detail-panel {
    grid-template-columns: minmax(0, 1fr);
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .detail-panel .detail-cover {
    display: none;
  }

  .detail-copy {
    max-height: 100vh;
    padding:
      max(62px, calc(env(safe-area-inset-top) + 48px))
      16px
      max(28px, env(safe-area-inset-bottom));
  }

  .detail-copy h2 {
    margin-right: 46px;
    font-size: 26px;
    line-height: 1.18;
  }

  .modal-close {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
  }

  .detail-copy .episode-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    gap: 8px;
  }

  .detail-copy .detail-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .detail-copy .detail-actions > button {
    width: 100%;
    min-width: 0;
  }

  .detail-secondary-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .inline-empty {
    padding: 28px 18px;
    font-size: 14px;
    line-height: 1.55;
  }

  .discovery-empty {
    margin: 0 16px 26px;
    padding: 20px;
  }
}
