:root {
  color-scheme: dark;
  --bg: #101113;
  --surface: #181a1f;
  --surface-2: #202329;
  --text: #f5f5f5;
  --muted: #a9adb7;
  --line: #30343c;
  --accent: #e21f2d;
  --accent-2: #f4c542;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 17, 19, 0.94);
  backdrop-filter: blur(14px);
}

.header-inner,
.footer-inner,
.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.header-icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.header-icon-button span:first-child {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-2);
  color: #121212;
  font-size: 1.05rem;
  line-height: 1;
}

.header-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.search-box span,
.language-box span,
.panel-head span,
.video-meta p,
.footer-inner span {
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(36vw, 360px);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.language-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-box span,
.language-box span {
  font-size: 0.84rem;
  font-weight: 700;
}

.search-box input,
.language-box select {
  width: 100%;
  min-width: 120px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.language-box select {
  min-width: 116px;
  cursor: pointer;
}

.language-box option {
  background: var(--surface);
  color: var(--text);
}

.search-box input::placeholder {
  color: #777d89;
}

.app-shell {
  padding: 20px 0 34px;
}

.video-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.playlist-panel,
.watch-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.playlist-panel {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 116px);
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head strong {
  display: block;
  margin-top: 2px;
}

#video-count {
  min-width: 42px;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  text-align: center;
  font-weight: 800;
}

.playlist {
  overflow: auto;
  padding: 8px;
}

.empty-state {
  margin: 0;
  padding: 18px 12px;
  color: var(--muted);
  text-align: center;
}

.video-item {
  display: grid;
  width: 100%;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.video-item:hover,
.video-item.is-active {
  background: var(--surface-2);
}

.video-item.is-active {
  outline: 1px solid rgba(226, 31, 45, 0.65);
}

.thumb {
  width: 64px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  object-fit: cover;
  background: #090a0c;
}

.item-title {
  display: -webkit-box;
  margin: 0 0 4px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-weight: 700;
  line-height: 1.25;
}

.item-date {
  color: var(--muted);
  font-size: 0.82rem;
}

.item-ranking {
  display: inline-flex;
  width: fit-content;
  margin-top: 6px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(244, 197, 66, 0.14);
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 800;
}

.item-seo-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-decoration: none;
}

.item-seo-link:hover {
  color: var(--text);
}

.player-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #050506;
}

.player-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-meta {
  padding: 18px 20px 22px;
}

.rank-button,
.ads-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(244, 197, 66, 0.38);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-2);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.rank-button {
  min-width: 76px;
}

.ads-button {
  min-width: 58px;
  min-height: 42px;
  border-color: rgba(226, 31, 45, 0.52);
  color: #fff;
  font-size: 0.82rem;
  letter-spacing: 0;
}

.ads-button:not(:disabled):hover,
.rank-button:not(:disabled):hover {
  filter: brightness(1.14);
}

.rank-button.is-starred {
  background: rgba(244, 197, 66, 0.16);
  border-color: rgba(244, 197, 66, 0.74);
}

.rank-button:disabled,
.ads-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.rank-star {
  font-size: 1.25rem;
  line-height: 1;
}

.video-meta p,
.video-meta h2 {
  margin: 0;
}

.ad-strip {
  display: flex;
  align-items: stretch;
  margin: 0 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}

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

.ad-link {
  display: grid;
  flex: 1;
  gap: 3px;
  min-width: 0;
  padding: 10px 14px;
  color: #fff;
  text-decoration: none;
}

.ad-label {
  width: fit-content;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
}

.ad-link strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.ad-close,
.ad-nav {
  width: 38px;
  border: 0;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.ad-close,
.ad-nav:first-of-type {
  border-right: 1px solid rgba(255, 255, 255, 0.14);
}

.ad-nav:last-child {
  border-left: 1px solid rgba(255, 255, 255, 0.14);
}

.ad-nav {
  font-size: 1.45rem;
  line-height: 1;
}

.ad-nav:hover,
.ad-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.68);
}

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

.ads-modal {
  width: min(460px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ads-modal-head,
.ads-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ads-modal label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.ads-modal input,
.ads-modal select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  padding: 0 10px;
}

.ads-modal .check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ads-modal .check-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.sponsor-note {
  margin: 12px 0 0;
  padding: 10px;
  border: 1px solid rgba(244, 197, 66, 0.38);
  border-radius: 8px;
  background: rgba(244, 197, 66, 0.08);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.sponsor-note a {
  color: var(--accent-2);
  font-weight: 800;
}

.info-modal {
  display: grid;
  gap: 14px;
}

.info-modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.source-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.source-list a {
  color: var(--accent-2);
  font-weight: 800;
}

.ads-modal-actions {
  margin-top: 16px;
}

.ads-modal-actions output {
  color: var(--muted);
  font-size: 0.88rem;
}

.icon-button,
.save-ad-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.icon-button {
  width: 38px;
  background: var(--surface-2);
}

.save-ad-button {
  padding: 0 16px;
  background: var(--accent);
}

.save-ad-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.video-meta h2 {
  margin-top: 6px;
  font-size: clamp(1.25rem, 2vw, 2rem);
  line-height: 1.16;
  letter-spacing: 0;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: #0c0d0f;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  font-size: 0.95rem;
}

.seo-video-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.seo-video-links strong {
  width: 100%;
}

.seo-video-links a {
  max-width: 260px;
  overflow: hidden;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seo-video-page {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.seo-video-article {
  display: grid;
  gap: 18px;
}

.seo-video-article h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1.08;
}

.seo-video-article p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.seo-video-article a {
  color: var(--accent-2);
}

.seo-kicker {
  font-weight: 800;
  text-transform: uppercase;
}

.admin-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.admin-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-head p,
.admin-head h1 {
  margin: 0;
}

.admin-head p {
  color: var(--muted);
  font-weight: 800;
}

.admin-head h1 {
  margin-top: 4px;
  font-size: clamp(1.6rem, 3vw, 2.7rem);
}

.admin-secondary-link {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.admin-head-actions {
  display: inline-flex;
  gap: 8px;
}

.admin-login {
  margin: 42px auto;
}

.admin-message,
.admin-error {
  padding: 12px;
  border-radius: 8px;
}

.admin-message {
  border: 1px solid rgba(244, 197, 66, 0.35);
  background: rgba(244, 197, 66, 0.1);
}

.admin-error {
  border: 1px solid rgba(226, 31, 45, 0.48);
  background: rgba(226, 31, 45, 0.1);
}

.admin-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.admin-table td strong,
.admin-table td small,
.admin-table td a,
.admin-table td span {
  display: block;
}

.admin-table td a,
.admin-table td small {
  margin-top: 5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.admin-pill {
  width: fit-content;
  margin: 0 0 6px;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.admin-pill.is-ok {
  color: #77e1a5;
}

.admin-pill.is-waiting,
.admin-pill.is-sponsored {
  color: var(--accent-2);
}

.admin-actions {
  display: grid;
  gap: 8px;
}

.admin-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.admin-actions button.danger {
  border-color: rgba(226, 31, 45, 0.56);
  color: #ff9ca4;
}

@media (max-width: 900px) {
  .video-layout {
    grid-template-columns: 1fr;
  }

  .playlist-panel {
    position: static;
    max-height: 420px;
    order: 2;
  }

  .watch-panel {
    order: 1;
  }
}

@media (max-width: 640px) {
  .header-inner {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
    padding: 10px 0;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding: 14px 0;
  }

  .brand,
  .header-actions,
  .language-box {
    grid-column: 1 / -1;
  }

  #about-button {
    grid-column: 1;
  }

  #compare-button {
    grid-column: 2;
  }

  #index-button {
    grid-column: 3;
  }

  .header-tools {
    display: contents;
  }

  #rank-button {
    grid-column: 4;
  }

  #ads-button {
    grid-column: 5;
  }

  .header-icon-button {
    justify-content: center;
    min-height: 36px;
    min-width: 0;
    padding: 0 4px;
    font-size: 0.72rem;
    gap: 4px;
  }

  .header-icon-button span:first-child {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    font-size: 0.82rem;
  }

  .rank-button,
  .ads-button {
    min-width: 0;
    width: 100%;
    min-height: 36px;
    padding: 0 4px;
    font-size: 0.72rem;
    gap: 4px;
  }

  .rank-star {
    font-size: 1rem;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .search-box {
    min-width: 0;
    width: 100%;
  }

  .video-item {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .thumb {
    width: 84px;
  }
}
