:root {
  --bg: #ffffff;
  --surface: #f6f5f1;
  --surface-2: #edebe5;
  --text: #121212;
  --text-2: #3f3f3f;
  --muted: #6f6f6f;
  --border: #e1dfd8;
  --accent: #b1151a;
  --accent-ink: #ffffff;
  --img-bg: #e7e5df;
  --shadow: 0 1px 2px rgba(18, 18, 18, .06), 0 8px 24px rgba(18, 18, 18, .06);

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
  --display: "Playfair Display", Georgia, serif;

  --container: 1320px;
  --gutter: 16px;
  --topbar: 56px;
}

[data-theme="dark"] {
  --bg: #111213;
  --surface: #191a1c;
  --surface-2: #222326;
  --text: #ebeae6;
  --text-2: #c2c1bc;
  --muted: #8f8e89;
  --border: #2d2e31;
  --accent: #ef5a5f;
  --accent-ink: #111213;
  --img-bg: #222326;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  z-index: 50;
  padding: 8px 12px;
  background: var(--text);
  color: var(--bg);
}
.skip-link:focus { top: 12px; }

.kicker {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 96px 0;
  color: var(--muted);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: var(--text-2); }
.btn--solid { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn--solid:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--block { width: 100%; height: 48px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.is-loading { position: relative; color: transparent; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid currentColor;
  border-color: var(--bg) var(--bg) var(--bg) transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
}
.pill-btn:hover { background: var(--border); }
.pill-btn span { display: none; }

[data-theme="light"] .icon-sun,
[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar);
}
.topbar__end { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.brand__mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px; height: 20px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
}
.brand__name {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search {
  display: none;
  align-items: center;
  gap: 8px;
  flex: 1;
  height: 40px;
  padding: 0 4px 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}
.search:focus-within { border-color: var(--text-2); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}
.search input::-webkit-search-cancel-button { display: none; }
.search__icon { display: inline-flex; }
.search-open { margin-left: auto; }
.search-open + .topbar__end { margin-left: 0; }

/* On phones the search takes over the bar while it's open. */
.topbar.is-searching .brand,
.topbar.is-searching .search-open,
.topbar.is-searching .topbar__end { display: none; }
.topbar.is-searching .search { display: flex; }

/* ---------- Category chips ---------- */
.chips {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  padding-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  scroll-snap-align: start;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:has(.chip__avatar) { padding-left: 4px; }
.chip:hover { border-color: var(--text-2); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip__avatar { width: 26px; height: 26px; }

/* ---------- Avatars ---------- */
.avatar, .chip__avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
}
.avatar img, .chip__avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--text, .chip__avatar--text {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
}
.chip__avatar--text { font-size: 10px; }
.avatar--lg { width: 44px; height: 44px; }

/* ---------- Video grid ---------- */
.feed { padding-bottom: 48px; }
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px 16px;
}

.card { display: block; min-width: 0; }
.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: var(--img-bg);
}
/* A blurred copy fills the frame so portrait or odd-sized thumbnails don't leave bars. */
.thumb__fill {
  position: absolute;
  inset: -12px;
  width: calc(100% + 24px);
  height: calc(100% + 24px);
  object-fit: cover;
  filter: blur(18px) brightness(.8);
}
.thumb__img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .35s ease;
}
.card:hover .thumb__img { transform: scale(1.03); }
.thumb__empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
}
.thumb__time {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.card__body {
  display: flex;
  gap: 12px;
  padding: 12px 2px 0;
}
.card__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card__title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
}
.card:hover .card__title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .14em; }
.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 0;
  font-size: 13px;
  color: var(--muted);
}
.card__meta span + span::before { content: "·"; margin: 0 6px; }

.empty, .notice {
  padding: 72px 0;
  text-align: center;
  color: var(--muted);
}
.notice h1 {
  margin-bottom: 8px;
  font-family: var(--display);
  font-size: 28px;
  color: var(--text);
}
.notice p { max-width: 460px; margin: 0 auto 20px; }

/* ---------- Captcha gate ---------- */
.gate {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--topbar) - 1px);
  padding-top: 32px;
  padding-bottom: 48px;
}
.gate__card {
  width: min(420px, 100%);
  padding: 32px 24px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  box-shadow: var(--shadow);
  text-align: center;
}
.gate__icon {
  display: inline-grid;
  place-items: center;
  width: 52px; height: 52px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
}
.gate__title {
  margin: 6px 0 8px;
  font-family: var(--display);
  font-size: 30px;
  line-height: 1.1;
}
.gate__text {
  margin-bottom: 22px;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--text-2);
}

.captcha {
  display: grid;
  place-items: center;
  min-height: 70px;
  margin-bottom: 14px;
}
.form-error {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 500;
}

/* ---------- Watch page ---------- */
.watch {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
  padding-top: 0;
  padding-bottom: 56px;
}

/* Phones get an edge-to-edge poster, like a video app. */
.watch__poster {
  position: relative;
  display: block;
  width: calc(100% + var(--gutter) * 2);
  margin: 0 calc(var(--gutter) * -1);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.watch__poster .thumb { border-radius: 0; }
.watch__play {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 68px; height: 68px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  transform: translate(-50%, -50%);
  transition: transform .2s, background .2s;
}
.watch__play svg { margin-left: 4px; }
.watch__poster:hover .watch__play { background: var(--accent); transform: translate(-50%, -50%) scale(1.06); }

.watch__title {
  margin-top: 16px;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.005em;
}
.watch__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--muted);
}
.watch__meta span + span::before { content: "·"; margin: 0 7px; }
.watch__free { color: var(--accent); font-weight: 600; }

.channel {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 6px 16px 6px 6px;
  border-radius: 999px;
  background: var(--surface);
}
.channel:hover { background: var(--surface-2); }
.channel__name { font-weight: 700; }

.description {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
}
.description__text {
  max-height: 6.4em;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.description__text.is-open { max-height: none; }
.description__toggle {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
}

.unlock {
  margin-top: 24px;
  padding: 22px 18px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: var(--shadow);
  scroll-margin-top: calc(var(--topbar) + 16px);
}
.unlock.is-flash { animation: flash 1s ease; }
@keyframes flash {
  0%, 100% { box-shadow: var(--shadow); }
  30% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }
}
.unlock__title {
  margin-top: 4px;
  font-family: var(--display);
  font-size: 22px;
  line-height: 1.2;
}
.unlock__hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 16px 0 18px;
  counter-reset: step;
}
.steps li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}
.steps li span {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  font-size: 12.5px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}
.steps li + li::before {
  content: "";
  position: absolute;
  top: 14px;
  right: 50%;
  width: 100%;
  height: 1.5px;
  background: var(--border);
}
.steps li.is-current { color: var(--text); }
.steps li.is-current span { border-color: var(--accent); background: var(--accent); color: #fff; }

.block-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-top: 10px;
  border-top: 2px solid var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.related + .related { margin-top: 32px; }

/* ---------- Larger screens ---------- */
@media (min-width: 560px) {
  :root { --gutter: 24px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pill-btn span { display: inline; }
  .gate__card { padding: 40px 36px; }
  .unlock { padding: 26px 28px; }
  .watch__poster { width: 100%; margin: 0; }
  .watch__poster .thumb { border-radius: 16px; }
  .watch { padding-top: 20px; }
}

@media (min-width: 760px) {
  .search { display: flex; max-width: 520px; margin: 0 auto; }
  .search-open, .search__close { display: none; }
  .watch__title { font-size: 30px; }
}

@media (min-width: 960px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  .watch { grid-template-columns: minmax(0, 1fr) 380px; gap: 40px; }
  .watch__side .grid--related { grid-template-columns: 1fr; gap: 12px; }
  .watch__side .card { display: flex; gap: 10px; }
  .watch__side .thumb { flex: none; width: 168px; border-radius: 10px; }
  .watch__side .card__body { padding: 0; }
  .watch__side .avatar { display: none; }
  .watch__side .card__title { font-size: 14px; }
  .watch__side .card__meta { font-size: 12.5px; }
}

@media (min-width: 1280px) {
  .feed .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- Telegram prompt ---------- */
.tg-modal {
  width: min(400px, calc(100% - 2 * var(--gutter)));
  padding: 32px 24px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
  text-align: center;
}
.tg-modal[open] { animation: tg-modal-in .2s ease-out; }
.tg-modal:focus-visible { outline: none; }
.tg-modal::backdrop { background: rgba(0, 0, 0, .55); }
.tg-modal__close { position: absolute; top: 10px; right: 10px; color: var(--muted); }
.tg-modal__icon { color: #229ed9; }
.tg-modal__icon svg { width: 26px; height: 26px; }
.tg-modal__later {
  margin-top: 6px;
  padding: 10px 16px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tg-modal__later:hover { color: var(--text); }
@keyframes tg-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
