:root {
  color-scheme: dark;
  --bg: #090b0e;
  --panel: #11151a;
  --panel-2: #171c23;
  --panel-3: #1d242c;
  --ink: #f5f2ea;
  --muted: #a9adad;
  --soft: #777f82;
  --line: #29313a;
  --accent: #68e0a4;
  --accent-ink: #07140d;
  --warn: #f0b45c;
  --blue: #7ab7ff;
  --danger: #ff9f8d;
  --radius: 8px;
  --max: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", Verdana, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
input,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

.brand {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(104, 224, 164, 0.6);
  border-radius: 50%;
  background: #0d1712;
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 950;
  text-decoration: none;
}

.label {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-line,
.muted {
  color: var(--muted);
  line-height: 1.45;
}

.tv-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(360px, 28vw) minmax(0, 1fr);
}

.pair-panel {
  display: grid;
  align-content: start;
  gap: 24px;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 28px;
}

.brand-row,
.remote-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.mode-pill,
.small-code {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--muted);
  font-weight: 900;
}

.pair-code {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(3rem, 4vw, 3.9rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.pair-url {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.4;
}

.screen-panel {
  display: grid;
  min-width: 0;
  background: #000;
}

.player-box {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: #000;
}

.player-box video,
.player-box iframe {
  display: block;
  width: 100%;
  min-height: calc(100vh - 54px);
  border: 0;
  background: #000;
}

.open-link {
  justify-self: start;
  min-height: 42px;
  margin: 0 0 12px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--accent);
  font-weight: 900;
  text-decoration: none;
}

.empty-state {
  display: grid;
  max-width: 360px;
  place-items: center;
  gap: 16px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-weight: 950;
}

.remote-join,
.auth-shell,
.remote-shell {
  width: min(var(--max), calc(100vw - 24px));
  margin-inline: auto;
}

.auth-shell,
.remote-join {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.auth-card,
.remote-card {
  display: grid;
  width: min(100%, 420px);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 22px;
}

.remote-card h1,
.auth-card h1,
.remote-head h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 6vw, 2.35rem);
  line-height: 1;
}

.remote-shell {
  display: grid;
  gap: 12px;
  padding-block: 12px 116px;
}

.remote-head,
.now-panel,
.remote-switcher,
.search-form,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.remote-head {
  position: sticky;
  top: 8px;
  z-index: 4;
  padding: 13px 14px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

.remote-title {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.remote-title .label {
  margin-bottom: 4px;
  color: var(--warn);
}

.remote-title h1 {
  font-size: 1.55rem;
}

.now-panel {
  display: grid;
  gap: 7px;
  border-color: rgba(104, 224, 164, 0.28);
  background: #0d151d;
  padding: 14px;
}

.now-panel strong {
  display: block;
  overflow: hidden;
  max-width: 100%;
  font-size: 1.2rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-copy {
  min-width: 0;
}

.remote-switcher {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 58px;
  align-items: stretch;
  gap: 8px;
  padding: 8px;
  background: #0d1116;
}

.nav-arrow {
  min-height: 54px;
  border: 1px solid rgba(122, 183, 255, 0.28);
  border-radius: var(--radius);
  background: #111923;
  color: var(--blue);
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 950;
}

.remote-switcher-copy {
  display: grid;
  align-content: center;
  min-width: 0;
  border: 1px solid rgba(104, 224, 164, 0.28);
  border-radius: var(--radius);
  background: #0b1711;
  padding: 8px 12px;
  text-align: center;
}

.remote-switcher-copy span {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.remote-switcher-copy strong {
  overflow: hidden;
  font-size: 1.08rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.scene-step {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d1116;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 8px;
  font-size: 0.8rem;
  font-weight: 950;
  text-align: center;
  text-transform: uppercase;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.scene-step b {
  display: block;
  color: var(--soft);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.scene-step.done {
  border-color: rgba(122, 183, 255, 0.35);
  color: var(--blue);
}

.scene-step.active {
  border-color: rgba(104, 224, 164, 0.62);
  background: #133321;
  color: var(--accent);
}

.scene-step.active b {
  color: var(--accent);
}

.primary:active,
.nav-arrow:active,
.scene-step:active,
.pad-button:active,
.ai-chip:active,
.anime-card:active,
.episode-button:active,
.source-button:active {
  transform: scale(0.98);
}

.search-form.pane-active,
.scene-panel.pane-active {
  border-color: rgba(104, 224, 164, 0.46);
  box-shadow: 0 0 0 1px rgba(104, 224, 164, 0.12) inset;
}

.source-list.pane-active {
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px rgba(104, 224, 164, 0.34);
}

.primary,
.episode-button,
.source-button,
.anime-card {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  cursor: pointer;
}

.primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 950;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 10px;
  padding: 12px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.vidrock-controls-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  padding: 12px;
}

.vidrock-settings.is-hidden {
  display: none;
}

.vidrock-lang-chips {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.vidrock-lang-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f141b;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
  cursor: pointer;
}

.vidrock-lang-chip.is-active {
  color: var(--accent);
  border-color: rgba(104, 224, 164, 0.62);
  background: #143421;
}

.vidrock-lang-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toggle-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #070a0d;
  padding: 0 12px;
}

.toggle-control span {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 850;
}

.toggle-control input[type="checkbox"] {
  width: 44px;
  height: 24px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.field span {
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field.is-disabled {
  opacity: 0.55;
}

.field.is-disabled :is(input, select) {
  cursor: not-allowed;
}

.field.is-disabled .vidrock-lang-chip {
  pointer-events: none;
  opacity: 0.45;
  cursor: not-allowed;
}

.field.is-disabled .toggle-control input {
  cursor: not-allowed;
}

input,
select {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: #070a0d;
  color: var(--ink);
  padding: 0 12px;
}

.remote-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(340px, 1.08fr);
  gap: 12px;
  align-items: start;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border-bottom: 1px solid var(--line);
}

.scene-number {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(240, 180, 92, 0.35);
  border-radius: 50%;
  background: #17140d;
  color: var(--warn);
  font-size: 0.85rem;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.section-head h2 {
  margin-bottom: 0;
  font-size: clamp(1.15rem, 4vw, 1.55rem);
  line-height: 1.05;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
  padding: 12px;
}

.ai-recommendation-block {
  display: grid;
  gap: 8px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
}

.ai-recommendation-block.title-ai {
  display: none;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.ai-recommendations {
  display: none;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0d1117;
  color: var(--ink);
  padding: 7px 12px;
  font-size: 0.84rem;
  min-height: 36px;
  cursor: pointer;
  text-transform: none;
}

.ai-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.anime-card {
  position: relative;
  display: grid;
  gap: 9px;
  min-width: 0;
  padding: 8px;
  text-align: left;
}

.anime-card.active,
.episode-button.active,
.source-button.active {
  border-color: var(--accent);
  background: #133321;
}

.anime-card.is-ai-best {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px rgba(122, 183, 255, 0.35) inset;
}

.anime-card.is-direct-video {
  border-color: rgba(104, 224, 164, 0.48);
}

.result-badge-row {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  max-width: calc(100% - 16px);
  pointer-events: none;
}

.result-badge {
  border: 1px solid rgba(122, 183, 255, 0.48);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(11, 20, 34, 0.88);
  color: var(--blue);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.direct-video-badge {
  border-color: rgba(104, 224, 164, 0.5);
  background: rgba(11, 27, 17, 0.9);
  color: var(--accent);
}

.poster-wrap {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  background: #20262c;
}

.poster-wrap::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--soft);
  content: "A1";
  font-size: 0.82rem;
  font-weight: 950;
}

.poster-wrap img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-wrap img[src=""] {
  display: none;
}

.anime-card-copy {
  display: grid;
  gap: 4px;
}

.anime-card strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 0.95rem;
  line-height: 1.16;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.anime-card small {
  color: var(--muted);
  font-size: 0.78rem;
}

.episode-zone {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.meta-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0c1014;
  padding: 12px;
}

.meta-card h3 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.chip-row,
.episode-list,
.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 7px 10px;
  font-size: 0.78rem;
}

.episode-button,
.source-button {
  padding-inline: 13px;
  font-weight: 850;
}

.source-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-color: rgba(104, 224, 164, 0.4);
  color: var(--accent);
}

.source-button small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.remote-pad {
  position: fixed;
  left: 50%;
  bottom: 10px;
  z-index: 6;
  display: grid;
  width: min(var(--max), calc(100vw - 24px));
  align-items: stretch;
  gap: 8px;
  transform: translateX(-50%);
  border: 1px solid rgba(104, 224, 164, 0.22);
  border-radius: var(--radius);
  background: rgba(10, 14, 18, 0.96);
  padding: 10px;
  box-shadow: 0 -16px 34px rgba(0, 0, 0, 0.42);
}

.remote-pad.is-nav-active {
  border-color: rgba(104, 224, 164, 0.62);
  box-shadow: 0 -18px 34px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(104, 224, 164, 0.18) inset;
}

.pad-row {
  display: grid;
  gap: 8px;
}

.seek-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.pad-button {
  min-height: 58px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-3);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.96rem;
  font-weight: 950;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.fullscreen-control {
  border-color: rgba(122, 183, 255, 0.48);
  color: var(--blue);
}

.play-control {
  border-color: rgba(104, 224, 164, 0.62);
  background: #143421;
  color: var(--accent);
}

.notice,
.error {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.error {
  border-color: #583029;
  color: var(--danger);
}

.is-loading {
  opacity: 0.72;
}

@media (max-width: 900px) {
  .tv-shell,
  .remote-grid,
  .search-form {
    grid-template-columns: 1fr;
  }

  .pair-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .player-box,
  .player-box video,
  .player-box iframe {
    min-height: 58vh;
  }
}

@media (max-width: 560px) {
  body {
    background: #090b0e;
  }

  .remote-shell {
    width: 100%;
    gap: 10px;
    padding: 0 10px 156px;
  }

  .remote-head {
    position: static;
    border-width: 0 0 1px;
    border-radius: 0;
    margin-inline: -10px;
    padding: 12px 14px;
    background: #0c1014;
  }

  .brand {
    width: 42px;
    height: 42px;
    font-size: 0.95rem;
  }

  .small-code {
    padding: 7px 10px;
    background: #171c23;
    font-size: 0.86rem;
  }

  .now-panel,
  .remote-switcher,
  .search-form,
  .scene-strip,
  .panel {
    border-radius: 8px;
  }

  .now-panel {
    margin-top: 2px;
    border-color: rgba(104, 224, 164, 0.36);
  }

  .now-panel .label {
    margin-bottom: 5px;
  }

  .now-panel strong {
    font-size: 1.08rem;
  }

  .now-panel .status-line {
    margin-bottom: 0;
    font-size: 0.92rem;
  }

  .scene-strip {
    overflow-x: auto;
    gap: 6px;
    grid-template-columns: repeat(5, minmax(58px, 1fr));
    scrollbar-width: none;
  }

  .scene-strip::-webkit-scrollbar {
    display: none;
  }

  .scene-step {
    padding: 8px 4px;
    font-size: 0.62rem;
  }

  .remote-switcher {
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    gap: 7px;
    padding: 7px;
  }

  .nav-arrow {
    min-height: 50px;
  }

  .remote-switcher-copy {
    padding-inline: 8px;
  }

  .remote-switcher-copy strong {
    font-size: 1rem;
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: end;
    gap: 8px;
  }

  .search-form .primary {
    min-height: 48px;
    grid-column: 1 / -1;
  }

  .vidrock-controls-grid {
    grid-template-columns: 1fr;
  }

  .vidrock-lang-chips {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .vidrock-lang-chip {
    min-height: 38px;
  }

  .results-grid {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .anime-card {
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    min-height: 66px;
    gap: 10px;
    padding: 8px;
  }

  .poster-wrap {
    width: 48px;
    height: 56px;
    aspect-ratio: auto;
  }

  .result-badge-row {
    position: static;
    grid-column: 2;
    justify-content: flex-start;
    max-width: 100%;
  }

  .result-badge {
    padding: 3px 7px;
    font-size: 0.62rem;
  }

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

  .meta-card .muted {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .episode-button {
    min-height: 42px;
    padding-inline: 6px;
    font-size: 0.86rem;
  }

  .source-list {
    display: grid;
    grid-template-columns: 1fr;
  }

  .source-button {
    min-height: 52px;
  }

  .remote-pad {
    bottom: 0;
    width: 100%;
    gap: 7px;
    border-width: 1px 0 0;
    border-radius: 8px 8px 0 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }

  .pad-row {
    gap: 7px;
  }

  .seek-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .transport-row {
    grid-template-columns: 1.15fr 1fr 0.9fr;
  }

  .pad-button {
    min-height: 54px;
    padding-inline: 4px;
    font-size: 0.92rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
