/* ==========================================================================
   Variables — warm "channel" palette (separate token set from style.css:
   this is a reading-focused design, not the visitka's green/accent system)
   ========================================================================== */
:root {
  --c-bg: #0c0906;
  --c-bg-elevated: #130f0a;
  --c-bg-card: #0d0a06;
  --c-bg-sunken: #090704;
  --c-border: #2a2018;
  --c-border-dark: #201810;
  --c-border-hover: #443423;

  --c-accent: #f0a14a;
  --c-accent-hover: #f5b968;
  --c-accent-rgb: 240, 161, 74;
  --c-accent-soft: rgba(240, 161, 74, 0.13);
  --c-accent-glow: rgba(240, 161, 74, 0.35);
  --c-accent-radial: radial-gradient(circle, rgba(240, 161, 74, 0.65) 0%, rgba(240, 161, 74, 0.25) 45%, rgba(240, 161, 74, 0) 75%);
  --c-warm-rgb: 181, 110, 58;

  --c-text: #e9e2d6;
  --c-text-soft: #c9beb0;
  --c-text-dim: #a4988a;
  --c-text-faint: #8f8377;
  --c-text-fainter: #655a4d;
  --c-text-faintest: #524940;
  --c-ink: #100d09;

  --c-radius: 14px;
  --c-radius-sm: 8px;

  --c-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --c-transition: 320ms var(--c-ease);
  --c-transition-fast: 150ms var(--c-ease);

  --c-max-width: 1180px;

  --c-font-serif: 'Source Serif 4', Georgia, serif;
  --c-font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --c-font-mono: 'IBM Plex Mono', Consolas, monospace;
}

/* ==========================================================================
   Reset
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html, body {
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--c-accent-rgb), 0.35) var(--c-bg-elevated);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--c-bg-elevated);
}

::-webkit-scrollbar-thumb {
  background-color: rgba(var(--c-accent-rgb), 0.35);
  border-radius: 8px;
  border: 3px solid var(--c-bg-elevated);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--c-accent);
}

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--c-font-serif);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Reader page (channel-posts.html) is an app-shell: the document itself
   never scrolls, only .c-feed does. Scoped via a class on <html> so
   channel.html keeps its normal page scroll. */
html.c-shell,
html.c-shell body {
  height: 100%;
  overflow: hidden;
}

h1, h2, h3, p, ul, blockquote, figure {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

a,
.c-topic-card,
.c-post,
.c-contact-link {
  -webkit-user-drag: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* The reset above beats the browser's default `[hidden] { display: none }`
   UA rule (author styles win over UA styles regardless of specificity), so
   `img.hidden = true` (e.g. swapping the lightbox between its <img> and its
   video player) silently did nothing without this. */
[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

pre, code {
  font-family: var(--c-font-mono);
}

/* ==========================================================================
   Cursor spotlight (Channel Home only, mouse-only) — same mechanics as the
   visitka's .cursor-spotlight, recolored to the channel's amber accent.
   ========================================================================== */
.c-cursor-spotlight {
  position: fixed;
  top: 0;
  left: 0;
  width: 640px;
  height: 640px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--c-accent-glow), transparent 70%);
  filter: blur(15px);
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transform: translate3d(-9999px, -9999px, 0) translate(-50%, -50%);
  transition: opacity 220ms var(--c-ease);
  will-change: transform, opacity;
}

.c-cursor-spotlight.is-active {
  opacity: 1;
}

@media (pointer: coarse) {
  .c-cursor-spotlight {
    display: none;
  }
}

/* ==========================================================================
   Nav (Channel Home)
   ========================================================================== */
.c-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(12, 9, 6, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-border);
}

.c-nav__inner {
  max-width: var(--c-max-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.c-nav__logo {
  font-family: var(--c-font-sans);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--c-text);
}

.c-nav__links {
  display: flex;
  gap: 2rem;
}

.c-nav__links a {
  font-family: var(--c-font-sans);
  color: var(--c-text-dim);
  font-size: 0.9rem;
  transition: color var(--c-transition);
  position: relative;
}

.c-nav__links a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 1px;
  background: var(--c-accent);
  transition: width var(--c-transition);
}

.c-nav__links a:hover,
.c-nav__links a:focus-visible {
  color: var(--c-text);
}

.c-nav__links a:hover::after,
.c-nav__links a:focus-visible::after {
  width: 100%;
}

.c-nav__toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 0.5rem;
  border-radius: var(--c-radius-sm);
  transition: background-color var(--c-transition-fast), transform var(--c-transition-fast);
}

.c-nav__toggle:hover,
.c-nav__toggle:focus-visible {
  background: var(--c-accent-soft);
  transform: scale(1.08);
}

.c-nav__toggle span {
  width: 22px;
  height: 2px;
  background: var(--c-text);
  transition: transform var(--c-transition), opacity var(--c-transition), background-color var(--c-transition-fast);
}

.c-nav__toggle:hover span,
.c-nav__toggle:focus-visible span {
  background: var(--c-accent);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.c-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.75rem;
  border-radius: var(--c-radius-sm);
  font-family: var(--c-font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: transform var(--c-transition-fast), box-shadow var(--c-transition-fast), background var(--c-transition-fast), border-color var(--c-transition-fast);
}

.c-btn--primary {
  background: var(--c-accent);
  color: var(--c-ink);
}

.c-btn--primary:hover,
.c-btn--primary:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--c-accent-glow);
  background: var(--c-accent-hover);
}

.c-btn--ghost {
  border-color: var(--c-border);
  color: var(--c-text);
}

.c-btn--ghost:hover,
.c-btn--ghost:focus-visible {
  border-color: var(--c-accent);
  color: var(--c-accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(var(--c-accent-rgb), 0.15);
}

/* ==========================================================================
   Reveal-on-scroll
   ========================================================================== */
.c-reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 700ms var(--c-ease), transform 700ms var(--c-ease);
  /* See .reveal in style.css: promotes a compositor layer before the
     scroll-triggered transition starts, to avoid mobile GPUs rasterizing
     it against a stale tile mid-scroll (reads as a flicker/vanish). */
  will-change: opacity, transform;
}

.c-reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ==========================================================================
   Hero (Channel Home) — grid pattern + glow, same recipe as the visitka hero
   ========================================================================== */
.c-hero {
  position: relative;
  z-index: 2;
  min-height: 92vh;
  /* See .hero in style.css: 100dvh/92dvh tracks the real visible mobile
     viewport instead of the browser's address-bar-hidden maximum. */
  min-height: 92dvh;
  display: flex;
  align-items: center;
  padding: 8rem 1.5rem 4rem;
  overflow: hidden;
  isolation: isolate;
}

.c-hero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at top right, rgba(var(--c-accent-rgb), 0.14), transparent 55%);
}

.c-hero__bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(var(--c-accent-rgb), 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--c-accent-rgb), 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 40%, black, transparent 75%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, black, transparent 75%);
}

.c-hero__glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Fine-pointer devices get the glow from the global .c-cursor-spotlight
   layer; this element only paints on touch devices, driving an autonomous
   drift instead. */
@media (pointer: coarse) {
  .c-hero__glow {
    background-image: radial-gradient(circle, var(--c-accent-glow), transparent 45%);
    background-repeat: no-repeat;
    background-size: 1100px 1100px;
    background-position: 30% 30%;
    will-change: background-position;
    animation: cHeroGlowDrift 10s ease-in-out infinite;
  }
}

@keyframes cHeroGlowDrift {
  0% { background-position: 30% 30%; }
  50% { background-position: 68% 52%; }
  100% { background-position: 30% 30%; }
}

.c-hero__content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.c-hero__greeting {
  font-family: var(--c-font-sans);
  color: var(--c-accent);
  font-size: 1.05rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.c-hero__name {
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.12;
  margin-bottom: 0.75rem;
}

.c-hero__role {
  font-family: var(--c-font-sans);
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  color: var(--c-text-dim);
  margin-bottom: 1.5rem;
}

.c-hero__desc {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--c-text-soft);
  max-width: 620px;
  margin-bottom: 2.25rem;
}

.c-hero__cta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   Sections (shared)
   ========================================================================== */
.c-section {
  position: relative;
  padding: 6rem 1.5rem;
  overflow: hidden;
}

.c-section::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--c-border) 25%, var(--c-border) 75%, transparent);
  filter: blur(1px);
  opacity: 0.6;
  pointer-events: none;
}

.c-section__inner {
  position: relative;
  z-index: 1;
  max-width: var(--c-max-width);
  margin: 0 auto;
}

.c-section__title {
  font-size: clamp(1.6rem, 3.6vw, 2.1rem);
  font-weight: 800;
  margin-bottom: 1.75rem;
}

/* ==========================================================================
   Section background orbs (scroll parallax) — one hue family (amber), two
   tones for depth instead of the visitka's two-color pairing.
   ========================================================================== */
.c-section-orbs {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.c-orb {
  position: absolute;
  pointer-events: none;
  will-change: transform;
}

.c-orb::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  filter: blur(90px);
  animation: cOrbPulse 10s ease-in-out infinite;
}

@keyframes cOrbPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.c-orb--accent::after {
  background: var(--c-accent);
  opacity: 0.14;
}

.c-orb--warm::after {
  background: rgb(var(--c-warm-rgb));
  opacity: 0.16;
}

#about .c-orb--accent {
  top: -16%;
  right: -10%;
  width: 380px;
  height: 380px;
}

#about .c-orb--accent::after {
  animation-duration: 9s;
}

#about .c-orb--warm {
  bottom: -10%;
  left: -8%;
  width: 280px;
  height: 280px;
}

#about .c-orb--warm::after {
  animation-duration: 12s;
  animation-delay: 1.5s;
}

#topics .c-orb--accent {
  top: -18%;
  left: -10%;
  width: 460px;
  height: 460px;
}

#topics .c-orb--accent::after {
  animation-duration: 13s;
  animation-delay: 0.6s;
}

#topics .c-orb--warm {
  top: 35%;
  right: -8%;
  width: 260px;
  height: 260px;
}

#topics .c-orb--warm::after {
  animation-duration: 8.5s;
}

#contacts .c-orb--accent {
  bottom: -22%;
  left: 30%;
  width: 440px;
  height: 440px;
}

#contacts .c-orb--accent::after {
  animation-duration: 12.5s;
  animation-delay: 0.4s;
}

#contacts .c-orb--warm {
  top: -12%;
  left: -8%;
  width: 240px;
  height: 240px;
}

#contacts .c-orb--warm::after {
  animation-duration: 8s;
  animation-delay: 1.8s;
}

/* ==========================================================================
   Stats
   ========================================================================== */
.c-stats {
  position: relative;
  overflow: hidden;
  max-width: var(--c-max-width);
  margin: 0 auto;
  padding: 0 1.5rem 5rem;
}

.c-stats__grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.125rem;
}

.c-stat {
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background: var(--c-bg-card);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color var(--c-transition), transform var(--c-transition), box-shadow var(--c-transition);
  /* See .stat in style.css: sits inside .c-stats.c-reveal, which gets its
     own transform during the scroll-reveal transition. Without its own
     promoted layer, a card here can get rasterized against the parent's
     stale transform matrix mid-transition on some mobile GPUs, landing
     visibly offset from its siblings until the next full repaint — see #3. */
  will-change: transform;
}

.c-stat:hover {
  border-color: var(--c-border-hover);
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.c-stat__number {
  font-family: var(--c-font-sans);
  font-size: clamp(1.6rem, 3.2vw, 1.9rem);
  font-weight: 700;
  color: var(--c-accent);
}

.c-stat__label {
  font-family: var(--c-font-sans);
  font-size: 0.82rem;
  color: var(--c-text-faint);
}

/* ==========================================================================
   Chart — same horizontal bar chart as the visitka's .chart, recolored to
   the channel's warm accent (see blocks.py's render_chart).
   ========================================================================== */
.c-chart__list {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.c-chart__row {
  display: grid;
  grid-template-columns: minmax(110px, 200px) 1fr auto;
  align-items: center;
  gap: 1rem;
}

.c-chart__label {
  font-family: var(--c-font-sans);
  color: var(--c-text-dim);
  font-size: 0.9rem;
}

.c-chart__track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--c-bg-sunken);
  border: 1px solid var(--c-border);
  overflow: hidden;
}

.c-chart__fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--c-accent-hover), var(--c-accent));
  transition: width 900ms var(--c-ease);
}

.c-chart__value {
  font-family: var(--c-font-sans);
  font-weight: 700;
  color: var(--c-accent);
  min-width: 2.5ch;
  text-align: right;
}

@media (max-width: 640px) {
  .c-chart__row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "label value" "track track";
    row-gap: 0.4rem;
  }

  .c-chart__label {
    grid-area: label;
  }

  .c-chart__value {
    grid-area: value;
  }

  .c-chart__track {
    grid-area: track;
  }
}

/* ==========================================================================
   Table — same scroll-shell data table as the visitka's .table-block,
   recolored to the channel's warm palette (see blocks.py's render_table).
   ========================================================================== */
.c-table-block__scroll {
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  background: var(--c-bg-card);
}

.c-table-block__table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-family: var(--c-font-sans);
  font-size: 0.9rem;
}

.c-table-block__table th,
.c-table-block__table td {
  padding: 0.85rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

.c-table-block__table th {
  color: var(--c-accent);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--c-bg-elevated);
}

.c-table-block__table tbody tr:last-child td {
  border-bottom: none;
}

.c-table-block__table tbody tr {
  transition: background-color var(--c-transition-fast);
}

.c-table-block__table tbody tr:hover {
  background: rgba(var(--c-accent-rgb), 0.06);
}

@media (max-width: 640px) {
  .c-table-block__table th,
  .c-table-block__table td {
    padding: 0.65rem 0.85rem;
    font-size: 0.83rem;
  }
}

/* ==========================================================================
   Timeline (О канале) — same structure/marker logic as the visitka's Опыт
   timeline (.timeline / .timeline__marker, border-left rail, is-visible ->
   fill + glow + scale), recolored to the amber accent.
   ========================================================================== */
.c-timeline {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: relative;
  max-width: 720px;
  padding-left: 1.75rem;
  border-left: 1px solid var(--c-border);
}

.c-timeline__item {
  position: relative;
}

.c-timeline__heading {
  position: relative;
}

.c-timeline__marker {
  position: absolute;
  left: -2.28rem;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c-bg);
  border: 2px solid var(--c-accent);
  transition: background-color 600ms var(--c-ease), box-shadow 600ms var(--c-ease), transform 600ms var(--c-ease);
}

.c-timeline__item.is-visible .c-timeline__marker {
  background: var(--c-accent);
  box-shadow: 0 0 16px 2px var(--c-accent-glow);
  transform: translateY(-50%) scale(1.15);
}

.c-timeline__content h3 {
  font-family: var(--c-font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 0.35rem;
}

.c-timeline__content p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--c-text-dim);
}

/* ==========================================================================
   Cards (Темы) — same hover recipe as the visitka's Проекты cards: lift,
   border tint, soft colored glow. No top stripe, no link glow box.
   ========================================================================== */
.c-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.c-topic-card {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 1.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform var(--c-transition), box-shadow var(--c-transition), border-color var(--c-transition);
}

.c-topic-card:hover,
.c-topic-card:focus-within {
  transform: translateY(-6px);
  border-color: rgba(var(--c-accent-rgb), 0.4);
  box-shadow: 0 16px 40px rgba(var(--c-accent-rgb), 0.14);
}

.c-topic-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--c-text);
}

.c-topic-card__desc {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--c-text-dim);
  flex-grow: 1;
}

.c-topic-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.c-tag {
  font-family: var(--c-font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--c-accent);
  border: 1px solid var(--c-border);
  border-radius: 20px;
  padding: 0.2rem 0.55rem;
}

.c-topic-card__link {
  font-family: var(--c-font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--c-accent);
  align-self: flex-start;
  border-bottom: 1px solid transparent;
  transition: border-color var(--c-transition), color var(--c-transition);
}

.c-topic-card__link:hover,
.c-topic-card__link:focus-visible {
  border-color: var(--c-accent);
}

/* ==========================================================================
   Contacts (footer of Channel Home) — same carded contact-link component as
   the visitka's .contacts/.contact-link, recolored to the channel palette.
   ========================================================================== */
.c-contacts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.c-contact-link {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: transform var(--c-transition), border-color var(--c-transition), box-shadow var(--c-transition);
}

.c-contact-link:hover,
.c-contact-link:focus-visible {
  transform: translateY(-4px);
  border-color: var(--c-accent);
  box-shadow: 0 12px 32px var(--c-accent-glow);
}

.c-contact-link__icon {
  width: 26px;
  height: 26px;
  margin-bottom: 0.2rem;
  color: var(--c-text-dim);
  transition: color var(--c-transition);
}

.c-contact-link__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.c-contact-link:hover .c-contact-link__icon,
.c-contact-link:focus-visible .c-contact-link__icon {
  color: var(--c-accent);
}

.c-contact-link--featured .c-contact-link__icon {
  width: 30px;
  height: 30px;
}

.c-contact-link__label {
  font-family: var(--c-font-sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-faint);
}

.c-contact-link__value {
  font-family: var(--c-font-sans);
  font-weight: 600;
  color: var(--c-text);
  word-break: break-word;
}

.c-contact-link--featured {
  grid-column: 1 / -1;
  padding: 1.75rem;
  background: linear-gradient(120deg, rgba(var(--c-accent-rgb), 0.14), rgba(var(--c-accent-rgb), 0.03));
  border-color: rgba(var(--c-accent-rgb), 0.4);
}

.c-contact-link--featured .c-contact-link__label {
  color: var(--c-text-dim);
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.95rem;
}

.c-contact-link--featured .c-contact-link__value {
  font-size: 1.4rem;
}

.c-contacts-cta {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
}

.c-farewell {
  text-align: center;
  font-family: var(--c-font-sans);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-accent);
  margin-top: 2.5rem;
}

@keyframes cBreathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ==========================================================================
   Reader app shell — the document (html.c-shell, above) never scrolls.
   .c-app fills the viewport and lays out top bar + frame vertically;
   .c-frame fills the remaining height; only .c-feed scrolls internally.
   ========================================================================== */
.c-app {
  height: 100vh;
  /* See .hero in style.css: 100dvh tracks the real visible mobile viewport
     instead of the browser's address-bar-hidden maximum. html.c-shell
     never scrolls (overflow: hidden above), so on a plain 100vh the
     bottom-anchored jump-to-latest button was clipped off-screen behind
     the address bar on first paint instead of just being shorter. */
  height: 100dvh;
  max-width: var(--c-max-width);
  margin: 0 auto;
  padding: 1.5rem 1.5rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.c-app__top {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.c-app__back {
  font-family: var(--c-font-sans);
  font-size: 0.85rem;
  color: var(--c-text-faint);
  transition: color var(--c-transition-fast);
}

.c-app__back:hover,
.c-app__back:focus-visible {
  color: var(--c-accent);
}

.c-frame {
  position: relative;
  isolation: isolate;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  width: 100%;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Very subtle "breathing" glow behind the reading surface — anchored to
   the frame (not the scrolling feed) so it stays still while posts scroll,
   and sits under the sidebar/header's own opaque backgrounds so it only
   reads through in the feed's empty space. No cursor spotlight, no bright
   orbs: this page is for reading, not showing off.
   Positioned at 78% (not center-left) so its hot spot lands inside the
   feed's own area rather than under the sidebar's opaque 270px column —
   centering it at 30% put most of the glow directly behind the sidebar,
   where it was fully hidden and only its faint falloff ever reached the
   feed on desktop. */
.c-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 65% 50% at 78% 12%, rgba(var(--c-accent-rgb), 0.16), transparent 65%);
  animation: cBreathe 12s ease-in-out infinite;
}

/* Selectable "chat wallpaper" texture, chosen in the admin (posts-settings
   "Узор фона" field, see channel_settings_repository.py for the
   body[data-bg-pattern] attribute it writes). Same layering as ::before
   above — sits under the sidebar/header's own opaque backgrounds, so it
   only reads through the feed's actual empty space (padding, the gaps
   between post cards) rather than a thin, easy-to-miss strip around the
   outside of the frame. "none" (the default) paints nothing. Renders on
   mobile too, unlike the page orbs below: the frame fills the whole
   viewport there, so this is the *only* place the pattern could ever show. */
.c-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

body[data-bg-pattern="dots"] .c-frame::after {
  background-image: radial-gradient(rgba(var(--c-accent-rgb), 0.35) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
}

body[data-bg-pattern="grid"] .c-frame::after {
  background-image:
    linear-gradient(rgba(var(--c-accent-rgb), 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--c-accent-rgb), 0.16) 1px, transparent 1px);
  background-size: 32px 32px;
}

body[data-bg-pattern="diagonal"] .c-frame::after {
  background-image: repeating-linear-gradient(135deg, rgba(var(--c-accent-rgb), 0.16) 0, rgba(var(--c-accent-rgb), 0.16) 1px, transparent 1px, transparent 14px);
}

/* ---------- Sidebar (desktop) ---------- */
.c-sidebar {
  position: relative;
  z-index: 1;
  width: 270px;
  flex-shrink: 0;
  padding: 2rem 1.5rem;
  border-right: 1px solid var(--c-border);
  background: var(--c-bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}

.c-sidebar__name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--c-text);
  transition: color var(--c-transition-fast);
}

a.c-sidebar__name:hover,
a.c-sidebar__name:focus-visible {
  color: var(--c-accent);
}

.c-sidebar__desc {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--c-text-dim);
  margin-top: 0.5rem;
}

.c-search {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius-sm);
  background: var(--c-bg-card);
  color: var(--c-text-fainter);
  font-family: var(--c-font-sans);
  font-size: 0.8rem;
}

.c-search::placeholder {
  color: var(--c-text-fainter);
}

.c-filters {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.c-filter {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  font-family: var(--c-font-sans);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--c-text-dim);
  text-align: left;
  transition: background-color var(--c-transition-fast), color var(--c-transition-fast);
}

.c-filter:hover {
  color: var(--c-text);
}

.c-filter.is-active {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  font-weight: 600;
}

.c-sidebar__stats {
  display: flex;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--c-border);
  margin-top: auto;
}

.c-sidebar__stat {
  flex: 1;
}

.c-sidebar__stat-num {
  font-family: var(--c-font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--c-accent);
}

.c-sidebar__stat-label {
  font-family: var(--c-font-sans);
  font-size: 0.68rem;
  color: var(--c-text-fainter);
}

/* ==========================================================================
   Resource browser entry points (sidebar desktop + mobile dropdown) — each
   opens the shared #cResourceModal scoped to its type.
   ========================================================================== */
.c-sidebar__resources {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.c-sidebar__resources-title {
  font-family: var(--c-font-sans);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-faintest);
  padding: 0 0.6rem 0.35rem;
}

.c-resource-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  font-family: var(--c-font-sans);
  font-size: 0.8rem;
  color: var(--c-text-dim);
  text-align: left;
  transition: background-color var(--c-transition-fast), color var(--c-transition-fast);
}

.c-resource-btn:hover,
.c-resource-btn:focus-visible {
  background: var(--c-accent-soft);
  color: var(--c-accent);
}

/* ---------- Mobile header ---------- */
.c-mobile-header {
  display: none;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg-elevated);
  flex-shrink: 0;
  position: relative;
  /* Higher than .c-feed's z-index: the two are equal-position siblings in
     .c-frame's flex column, and .c-feed comes later in DOM order — without
     this, the dropdown menu below (a descendant capped inside this header's
     own stacking context) would paint underneath the feed instead of over it. */
  z-index: 2;
}

.c-mobile-back {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--c-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-dim);
  transition: background-color var(--c-transition-fast), color var(--c-transition-fast);
}

.c-mobile-back:hover,
.c-mobile-back:focus-visible {
  background: var(--c-accent-soft);
  color: var(--c-accent);
}

.c-mobile-header__text {
  flex: 1;
  min-width: 0;
}

.c-mobile-header__name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c-mobile-header__sub {
  font-family: var(--c-font-sans);
  font-size: 0.68rem;
  color: var(--c-text-fainter);
}

/* Same recipe as the visitka's .nav__toggle: hover lift+tint, spans that
   morph into a cross when .is-open (translateY to converge + rotate,
   middle span fades out). */
.c-mobile-toggle {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--c-radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background-color var(--c-transition-fast), transform var(--c-transition-fast);
}

.c-mobile-toggle:hover,
.c-mobile-toggle:focus-visible {
  background: var(--c-accent-soft);
  transform: scale(1.08);
}

.c-mobile-toggle span {
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: var(--c-text);
  transition: transform var(--c-transition), opacity var(--c-transition), background-color var(--c-transition-fast);
}

.c-mobile-toggle:hover span,
.c-mobile-toggle:focus-visible span {
  background: var(--c-accent);
}

.c-mobile-toggle.is-open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.c-mobile-toggle.is-open span:nth-child(2) {
  opacity: 0;
}

.c-mobile-toggle.is-open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ---------- Feed ---------- */
/* .c-feed-viewport is the non-scrolling flex slot (takes over .c-feed's
   old position in .c-frame's layout); .c-feed becomes an absolutely
   positioned fill of it so the jump-to-latest button can anchor to the
   viewport's corner without scrolling away with the feed's content. */
.c-feed-viewport {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
}

.c-feed {
  position: absolute;
  inset: 0;
  padding: 2rem 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--c-accent-rgb), 0.35) transparent;
}

/* ---------- Jump to latest ---------- */
.c-jump-latest {
  position: absolute;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 3;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--c-accent);
  color: var(--c-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(var(--c-accent-rgb), 0.3);
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  pointer-events: none;
  transition: opacity var(--c-transition), transform var(--c-transition), box-shadow var(--c-transition-fast), background-color var(--c-transition-fast);
}

.c-jump-latest.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.c-jump-latest:hover,
.c-jump-latest:focus-visible {
  background: var(--c-accent-hover);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(var(--c-accent-rgb), 0.5);
  transform: translateY(-2px);
}

.c-feed::-webkit-scrollbar {
  width: 8px;
}

.c-feed::-webkit-scrollbar-track {
  background: transparent;
}

.c-feed::-webkit-scrollbar-thumb {
  background-color: rgba(var(--c-accent-rgb), 0.35);
  border-radius: 8px;
}

.c-feed::-webkit-scrollbar-thumb:hover {
  background-color: rgba(var(--c-accent-rgb), 0.55);
}

.c-feed__empty {
  margin: auto;
  font-family: var(--c-font-sans);
  font-size: 0.9rem;
  color: var(--c-text-faint);
  text-align: center;
}

/* Infinite-scroll-up trigger: sits above the oldest currently-rendered
   post, observed via IntersectionObserver to prepend the next older batch.
   Removed once the true start of the feed has been reached. */
.c-feed__sentinel {
  flex-shrink: 0;
  padding: 0.5rem 0;
  text-align: center;
  font-family: var(--c-font-sans);
  font-size: 0.7rem;
  color: var(--c-text-faintest);
}

/* A date pill is a button that opens the calendar (see .c-calendar below),
   so it gets a hover/focus treatment signaling it's clickable. */
.c-feed__chip {
  align-self: center;
  font-family: var(--c-font-sans);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--c-text-fainter);
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color var(--c-transition-fast), color var(--c-transition-fast), background-color var(--c-transition-fast);
}

.c-feed__chip:hover,
.c-feed__chip:focus-visible {
  border-color: rgba(var(--c-accent-rgb), 0.4);
  color: var(--c-accent);
  background: var(--c-accent-soft);
}

.c-post {
  border: 1px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-bg-card);
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  min-width: 0;
}

.c-post__category {
  font-family: var(--c-font-sans);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--c-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.c-post__heading {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--c-text);
  margin-top: 0.375rem;
}

.c-post__para {
  font-size: 0.97rem;
  line-height: 1.75;
  color: var(--c-text);
  white-space: pre-wrap;
  /* A long unbroken URL (or any other no-space run) in the source text
     otherwise refuses to wrap and pushes the post wider than its card —
     this lets it break rather than overflow. */
  overflow-wrap: anywhere;
}

/* Inline markdown link inside a paragraph — the source of truth that the
   .c-videolink preview card right below is generated from. */
.c-post__para a {
  color: var(--c-accent);
  text-decoration: underline;
  text-decoration-color: rgba(var(--c-accent-rgb), 0.4);
  text-underline-offset: 2px;
  transition: text-decoration-color var(--c-transition-fast), color var(--c-transition-fast);
}

.c-post__para a:hover,
.c-post__para a:focus-visible {
  text-decoration-color: var(--c-accent);
  color: var(--c-accent-hover);
}

.c-post__list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.c-post__list-item {
  display: flex;
  gap: 0.55rem;
  font-size: 0.94rem;
  line-height: 1.6;
  color: var(--c-text);
}

.c-post__list-item::before {
  content: '—';
  color: var(--c-accent);
  flex-shrink: 0;
}

.c-post__figure {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Clickable — opens the lightbox (see .c-lightbox below), so it gets the
   same lift/zoom affordance as the site's other interactive elements. */
.c-post__figure img {
  width: 100%;
  max-width: 520px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--c-border-dark);
  cursor: zoom-in;
  transition: transform var(--c-transition-fast), border-color var(--c-transition-fast);
}

.c-post__figure img:hover,
.c-post__figure img:focus-visible {
  transform: scale(1.015);
  border-color: rgba(var(--c-accent-rgb), 0.35);
}

.c-post__figure figcaption {
  font-family: var(--c-font-sans);
  font-size: 0.75rem;
  color: var(--c-text-fainter);
}

.c-post__placeholder-img {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  border: 1px solid var(--c-border-dark);
  background-image: repeating-linear-gradient(135deg, #1c150e, #1c150e 9px, #160f09 9px, #160f09 18px);
}

/* ==========================================================================
   Photo gallery block — a plain set of photos with no per-image caption.
   Adaptive grid (auto-fit keeps tiles a sane minimum size on both desktop
   and mobile); every tile opens the shared lightbox with prev/next paging
   across the rest of the gallery.
   ========================================================================== */
.c-post__gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  max-width: 560px;
}

.c-post__gallery-item {
  /* `aspect-ratio: 1` alone (no in-flow content, since the img below is
     absolutely positioned out of flow) isn't reliably picked up by CSS
     Grid's `grid-auto-rows: auto` sizing pass — rows ended up sized far
     shorter than the items in them, so every tile overflowed downward and
     overlapped the rows beneath it (looked like flattened/bleeding
     images). The classic padding-top: 100% trick below gives the item
     real in-flow content whose height is derived from its own resolved
     width — always definite by the time row-sizing runs, so the row track
     comes out correctly sized regardless of aspect-ratio/grid quirks. */
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--c-border-dark);
  cursor: zoom-in;
  transition: transform var(--c-transition-fast), border-color var(--c-transition-fast), z-index 0s var(--c-transition-fast);
}

.c-post__gallery-item::before {
  content: '';
  display: block;
  padding-top: 100%;
}

.c-post__gallery-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.c-post__gallery-item:hover,
.c-post__gallery-item:focus-visible {
  transform: scale(1.04);
  border-color: rgba(var(--c-accent-rgb), 0.4);
  z-index: 1;
}

/* ==========================================================================
   Video post block — custom player chrome over a native <video> with its
   own controls hidden. Not wired into the image lightbox: the transport
   bar needs direct clicks for play/seek/volume/fullscreen, and a
   click-to-lightbox handler on the element would fight with that.
   ========================================================================== */
.c-player {
  position: relative;
  width: 100%;
  max-width: 560px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--c-border-dark);
  background: #000;
}

.c-player__video {
  width: 100%;
  display: block;
  background: #000;
}

.c-player__overlay-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.15);
  opacity: 1;
  touch-action: manipulation;
  transition: opacity var(--c-transition-fast);
  cursor: pointer;
}

.c-player.is-playing .c-player__overlay-play {
  opacity: 0;
  pointer-events: none;
}

.c-player__overlay-play-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--c-accent-rgb), 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: transform var(--c-transition-fast), box-shadow var(--c-transition-fast), background-color var(--c-transition-fast);
}

.c-player__overlay-play:focus-visible .c-player__overlay-play-btn {
  transform: scale(1.08);
  box-shadow: 0 10px 30px var(--c-accent-glow);
  background: rgba(var(--c-accent-rgb), 0.72);
}

@media (hover: hover) and (pointer: fine) {
  .c-player__overlay-play:hover .c-player__overlay-play-btn {
    transform: scale(1.08);
    box-shadow: 0 10px 30px var(--c-accent-glow);
    background: rgba(var(--c-accent-rgb), 0.72);
  }
}

/* No persistent chrome while paused — just the translucent round button
   above. The full bar only exists once playback starts (`.is-playing`),
   and is itself translucent rather than a solid plate. It's also what
   `.is-idle` (below) fades back out after a few seconds of inactivity. */
.c-player__controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.625rem;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.24) 70%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity var(--c-transition), transform var(--c-transition);
}

.c-player.is-playing .c-player__controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.c-player__btn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  touch-action: manipulation;
  transition: background-color var(--c-transition-fast), color var(--c-transition-fast), transform var(--c-transition-fast);
}

.c-player__btn:focus-visible {
  background: rgba(var(--c-accent-rgb), 0.28);
  color: var(--c-accent);
  transform: scale(1.08);
}

/* Scoped to real pointer devices — a hover state that also nudges
   transform on a touchscreen risks the tap's end coordinates landing
   outside the (now scaled) element between touchstart and touchend,
   which is a well-known way for a tap to silently fail to register. */
@media (hover: hover) and (pointer: fine) {
  .c-player__btn:hover {
    background: rgba(var(--c-accent-rgb), 0.28);
    color: var(--c-accent);
    transform: scale(1.08);
  }
}

.c-player__time {
  font-family: var(--c-font-mono);
  font-size: 0.68rem;
  color: #fff;
  flex-shrink: 0;
  min-width: 32px;
}

.c-player__time--current {
  text-align: right;
}

.c-player__progress {
  flex: 1;
  height: 20px;
  min-width: 0;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}

.c-player__progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
}

.c-player__progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 2px;
  background: var(--c-accent);
}

.c-player__progress-handle {
  position: absolute;
  top: 50%;
  left: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(var(--c-accent-rgb), 0.28);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity var(--c-transition-fast);
}

.c-player__progress:hover .c-player__progress-handle,
.c-player__progress:focus-visible .c-player__progress-handle,
.c-player__progress.is-dragging .c-player__progress-handle {
  opacity: 1;
}

.c-player__volume {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.c-player__volume-range {
  width: 56px;
  accent-color: var(--c-accent);
}

/* YouTube-style idle fade: while playing and the pointer has been still for
   a few seconds, the control bar (and cursor) recede so the video itself is
   the only thing on screen — any pointer movement, or a tap on mobile
   (see setupVideoPlayer's video 'click' handler), snaps it back. Written
   after the .is-playing rule above so it wins the tie on specificity when
   both classes are present. */
.c-player.is-idle .c-player__controls {
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
}

.c-player.is-idle {
  cursor: none;
}

/* ==========================================================================
   Fullscreen — the browser stretches whichever element called
   requestFullscreen() to fill the screen, but a bare <video width:100%> has
   no height rule of its own, so it was rendering at its natural (shorter)
   height and sticking to the top with a dead black band below and the
   control bar pinned to the bottom of the *screen* rather than the video.
   Centering the player as a flex box and letting the video size itself by
   contain within it fixes both.
   ========================================================================== */
.c-player.is-fullscreen {
  max-width: none;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
}

.c-player.is-fullscreen .c-player__video {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.c-videolink {
  display: flex;
  gap: 0.875rem;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 0.875rem;
  background: var(--c-bg-sunken);
  max-width: 480px;
  cursor: pointer;
  transition: transform var(--c-transition-fast), border-color var(--c-transition-fast), box-shadow var(--c-transition-fast);
}

.c-videolink:hover,
.c-videolink:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(var(--c-accent-rgb), 0.45);
  box-shadow: 0 12px 28px rgba(var(--c-accent-rgb), 0.16);
}

.c-videolink__thumb {
  position: relative;
  width: 110px;
  height: 78px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 6px;
  background-image: repeating-linear-gradient(135deg, #1c150e, #1c150e 9px, #160f09 9px, #160f09 18px);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Real preview image (when the source provides a thumbnail) fills the box. */
.c-videolink__thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Fallback when no thumbnail is available: domain favicon centered over
   the diagonal placeholder pattern instead of an empty dark plate. */
.c-videolink__favicon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--c-bg-elevated);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.c-videolink__meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  justify-content: center;
  min-width: 0;
}

.c-videolink__title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c-videolink__domain {
  font-family: var(--c-font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--c-accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Voice message — compact Telegram-style bubble: round play button,
   scrubbable track, remaining-time readout that counts down while playing.
   ========================================================================== */
.c-voice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 360px;
  padding: 0.625rem 0.875rem;
  border-radius: 999px;
  background: var(--c-bg-sunken);
  border: 1px solid var(--c-border-dark);
  transition: border-color var(--c-transition-fast);
}

.c-voice.is-playing {
  border-color: rgba(var(--c-accent-rgb), 0.35);
}

.c-voice__play {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-accent);
  color: var(--c-ink);
  transition: transform var(--c-transition-fast), box-shadow var(--c-transition-fast), background-color var(--c-transition-fast);
}

.c-voice__play:hover,
.c-voice__play:focus-visible {
  transform: scale(1.06);
  box-shadow: 0 6px 18px var(--c-accent-glow);
  background: var(--c-accent-hover);
}

.c-voice__body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.c-voice__track {
  flex: 1;
  height: 18px;
  min-width: 0;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  position: relative;
}

.c-voice__track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--c-border);
}

.c-voice__track-fill {
  position: absolute;
  left: 0;
  height: 3px;
  width: 0;
  border-radius: 2px;
  background: var(--c-accent);
}

.c-voice__time {
  flex-shrink: 0;
  font-family: var(--c-font-mono);
  font-size: 0.68rem;
  color: var(--c-text-faint);
  min-width: 30px;
}

/* ==========================================================================
   Round video message ("кружок") — circular, click-to-play like Telegram's
   own video circles, with a fading duration readout.
   ========================================================================== */
.c-round-video {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--c-border-dark);
  background: #000;
  cursor: pointer;
}

.c-round-video__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.c-round-video__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  opacity: 1;
  transition: opacity var(--c-transition-fast), background-color var(--c-transition-fast);
}

.c-round-video__overlay svg {
  width: 34px;
  height: 34px;
}

.c-round-video.is-playing .c-round-video__overlay {
  opacity: 0;
  background: transparent;
}

.c-round-video:hover .c-round-video__overlay {
  background: rgba(0, 0, 0, 0.32);
}

.c-round-video.is-playing:hover .c-round-video__overlay {
  opacity: 1;
}

.c-round-video__duration {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  font-family: var(--c-font-mono);
  font-size: 0.68rem;
  color: #fff;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* ==========================================================================
   File attachment card — icon plate + name/size, whole card opens/downloads
   the file. Used for documents, archives and non-browser-playable video.
   ========================================================================== */
.c-filecard {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  max-width: 420px;
  padding: 0.75rem 0.875rem;
  border-radius: 10px;
  background: var(--c-bg-sunken);
  border: 1px solid var(--c-border-dark);
  transition: border-color var(--c-transition-fast), transform var(--c-transition-fast), background-color var(--c-transition-fast);
}

.c-filecard:hover,
.c-filecard:focus-visible {
  border-color: rgba(var(--c-accent-rgb), 0.4);
  background: var(--c-accent-soft);
  transform: translateY(-1px);
}

.c-filecard__icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  color: var(--c-accent);
  font-family: var(--c-font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.c-filecard__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.c-filecard__name {
  font-family: var(--c-font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c-filecard__size {
  font-family: var(--c-font-mono);
  font-size: 0.7rem;
  color: var(--c-text-faint);
}

.c-filecard__download {
  flex-shrink: 0;
  color: var(--c-text-faint);
  display: flex;
}

.c-filecard:hover .c-filecard__download,
.c-filecard:focus-visible .c-filecard__download {
  color: var(--c-accent);
}

/* ==========================================================================
   Sticker — rendered small and borderless, like a Telegram sticker.
   ========================================================================== */
.c-sticker {
  display: flex;
}

.c-sticker__img {
  width: 128px;
  height: 128px;
  object-fit: contain;
}

/* Play badge on a video tile inside a mixed photo/video gallery grid. */
.c-post__gallery-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  pointer-events: none;
}

.c-post__gallery-play svg {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.c-post__time {
  align-self: flex-end;
  font-family: var(--c-font-sans);
  font-size: 0.7rem;
  color: var(--c-text-faintest);
}

/* ==========================================================================
   Image lightbox
   ========================================================================== */
.c-lightbox {
  --c-lightbox-pad-y: 3rem;
  --c-lightbox-pad-x: 2rem;
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--c-lightbox-pad-y) var(--c-lightbox-pad-x);
  background: rgba(6, 4, 2, 0.88);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--c-transition);
}

.c-lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Holds whichever of the img/video is current — sized to its content
   (not the full lightbox) so clicking the backdrop around it still closes
   the lightbox, and animated as one unit when paging so a photo and a
   video slide can cross-fade/slide the same way despite being different
   elements underneath. */
.c-lightbox__stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

/* max-height here deliberately isn't a percentage: .c-lightbox uses
   align-items: center (not stretch), so the flex item never gets a
   *definite* height for a percentage-height descendant to resolve
   against — a `max-height: 100%` on a child in that situation computes
   to `none`, which was letting every portrait photo/video render at full
   natural pixel size and spill off the top/bottom of the screen. Sizing
   against the viewport directly sidesteps that resolution question. */
.c-lightbox__img {
  max-width: calc(100vw - var(--c-lightbox-pad-x) * 2);
  max-height: calc(100vh - var(--c-lightbox-pad-y) * 2);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.c-lightbox__stage {
  transform: scale(0.96);
  transition: transform var(--c-transition);
}

.c-lightbox.is-open .c-lightbox__stage {
  transform: scale(1);
}

.c-lightbox__stage.is-sliding {
  transition: transform 220ms var(--c-ease), opacity 220ms var(--c-ease);
}

.c-lightbox__video {
  width: min(720px, calc(100vw - var(--c-lightbox-pad-x) * 2));
  max-height: calc(100vh - var(--c-lightbox-pad-y) * 2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.c-lightbox__video .c-player {
  max-width: 100%;
  max-height: calc(100vh - var(--c-lightbox-pad-y) * 2);
}

/* A portrait video sized only by `width: 100%` (the feed's own layout,
   reused here) would overflow the same way the photos did — constrain by
   height too and let it shrink proportionally instead of just being
   capped/cropped by the player's overflow: hidden. */
.c-lightbox__video .c-player__video {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - var(--c-lightbox-pad-y) * 2);
  object-fit: contain;
}

.c-lightbox__video .c-player {
  max-width: none;
}

.c-lightbox__close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--c-transition-fast), color var(--c-transition-fast), transform var(--c-transition-fast);
}

.c-lightbox__close:hover,
.c-lightbox__close:focus-visible {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  transform: scale(1.08);
}

/* Prev/next paging through a gallery's images — hidden via [hidden] when
   the open image belongs to a single-photo block or a one-image gallery. */
.c-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: 1.8rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--c-transition-fast), color var(--c-transition-fast), transform var(--c-transition-fast);
}

.c-lightbox__nav:hover,
.c-lightbox__nav:focus-visible {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  transform: translateY(-50%) scale(1.08);
}

.c-lightbox__nav--prev {
  left: 1.25rem;
}

.c-lightbox__nav--next {
  right: 1.25rem;
}

@media (max-width: 600px) {
  .c-lightbox {
    --c-lightbox-pad-y: 1.25rem;
    --c-lightbox-pad-x: 0.75rem;
  }

  /* Touch has swipe (already wired up alongside these buttons) — the
     arrows just eat thumb-reachable screen edge for no benefit here. */
  .c-lightbox__nav {
    display: none;
  }
}

/* ==========================================================================
   Calendar (opened from a date pill)
   ========================================================================== */
.c-calendar {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(6, 4, 2, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--c-transition);
}

.c-calendar.is-open {
  opacity: 1;
  pointer-events: auto;
}

.c-calendar__panel {
  width: 100%;
  max-width: 320px;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  padding: 1.25rem;
  transform: translateY(8px) scale(0.98);
  transition: transform var(--c-transition);
}

.c-calendar.is-open .c-calendar__panel {
  transform: none;
}

.c-calendar__header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.c-calendar__title {
  flex: 1;
  text-align: center;
  font-family: var(--c-font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--c-text);
  text-transform: capitalize;
}

.c-calendar__nav,
.c-calendar__close {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--c-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-dim);
  font-size: 1.1rem;
  line-height: 1;
  transition: background-color var(--c-transition-fast), color var(--c-transition-fast);
}

.c-calendar__nav:hover,
.c-calendar__nav:focus-visible,
.c-calendar__close:hover,
.c-calendar__close:focus-visible {
  background: var(--c-accent-soft);
  color: var(--c-accent);
}

.c-calendar__weekdays,
.c-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.c-calendar__weekdays {
  margin-bottom: 0.4rem;
}

.c-calendar__weekdays span {
  text-align: center;
  font-family: var(--c-font-sans);
  font-size: 0.68rem;
  color: var(--c-text-faintest);
}

.c-calendar__grid {
  gap: 0.2rem;
}

.c-calendar__day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-family: var(--c-font-sans);
  font-size: 0.8rem;
  color: var(--c-text-faint);
}

.c-calendar__day--outside {
  visibility: hidden;
}

.c-calendar__day--has-post {
  color: var(--c-text);
  background: var(--c-accent-soft);
  cursor: pointer;
  transition: background-color var(--c-transition-fast), color var(--c-transition-fast), transform var(--c-transition-fast);
}

.c-calendar__day--has-post::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--c-accent);
  transform: translateX(-50%);
}

.c-calendar__day--has-post:hover,
.c-calendar__day--has-post:focus-visible {
  background: rgba(var(--c-accent-rgb), 0.28);
  color: var(--c-accent);
  transform: scale(1.08);
}

.c-calendar__day--today {
  box-shadow: inset 0 0 0 1px rgba(var(--c-accent-rgb), 0.5);
}

/* ==========================================================================
   Resource browser modal — one shared shell, repopulated per resource type
   (media grid / link previews / voice players) with items pulled from every
   post regardless of the feed's current filter or search.
   ========================================================================== */
.c-resource-modal {
  position: fixed;
  inset: 0;
  z-index: 205;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(6, 4, 2, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--c-transition);
}

.c-resource-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.c-resource-modal__panel {
  width: 100%;
  max-width: 620px;
  max-height: min(680px, 88vh);
  display: flex;
  flex-direction: column;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(8px) scale(0.98);
  transition: transform var(--c-transition);
  overflow: hidden;
}

.c-resource-modal.is-open .c-resource-modal__panel {
  transform: none;
}

.c-resource-modal__header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid var(--c-border);
}

.c-resource-modal__title {
  font-family: var(--c-font-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-text);
}

.c-resource-modal__close {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: 1.4rem;
  line-height: 1;
  transition: background-color var(--c-transition-fast), color var(--c-transition-fast), transform var(--c-transition-fast);
}

.c-resource-modal__close:hover,
.c-resource-modal__close:focus-visible {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  transform: scale(1.08);
}

.c-resource-modal__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--c-accent-rgb), 0.35) transparent;
  padding: 1.25rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.c-resource-modal__body::-webkit-scrollbar {
  width: 8px;
}

.c-resource-modal__body::-webkit-scrollbar-track {
  background: transparent;
}

.c-resource-modal__body::-webkit-scrollbar-thumb {
  background-color: rgba(var(--c-accent-rgb), 0.35);
  border-radius: 8px;
}

.c-resource-modal__body::-webkit-scrollbar-thumb:hover {
  background-color: rgba(var(--c-accent-rgb), 0.55);
}

.c-resource-modal__body--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 0.5rem;
}

.c-resource-modal__empty {
  margin: auto;
  font-family: var(--c-font-sans);
  font-size: 0.9rem;
  color: var(--c-text-faint);
  text-align: center;
  padding: 2.5rem 0;
}

/* Incremental-render trigger for the media grid (see appendMediaBatch in
   channel.js) — spans the full row so it doesn't sit awkwardly in a single
   grid column. */
.c-resource-modal__sentinel {
  grid-column: 1 / -1;
  padding: 0.75rem 0;
  text-align: center;
  font-family: var(--c-font-sans);
  font-size: 0.7rem;
  color: var(--c-text-faintest);
}

/* A link/voice row gets a small date label above the card so items pulled
   from many different posts still read as a timeline, not a jumbled list. */
.c-resource-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.c-resource-item__date {
  font-family: var(--c-font-mono);
  font-size: 0.65rem;
  color: var(--c-text-faintest);
  padding: 0 0.1rem;
}

.c-resource-item .c-videolink,
.c-resource-item .c-voice {
  max-width: none;
}

@media (max-width: 600px) {
  .c-resource-modal {
    padding: 0;
    align-items: flex-end;
  }

  .c-resource-modal__panel {
    max-width: none;
    max-height: 82vh;
    width: 100%;
    border-radius: var(--c-radius) var(--c-radius) 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .c-resource-modal.is-open .c-resource-modal__panel {
    transform: none;
  }
}

/* ==========================================================================
   Custom context menu — replaces the browser's native right-click menu over
   media/voice/file/link targets (see the JS section of the same name).
   Positioned by JS via left/top (clamped to the viewport); hidden by
   default via opacity+scale rather than `display` so the fade/pop reads as
   a real appearance instead of a hard cut.
   ========================================================================== */
.c-context-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 260;
  min-width: 200px;
  padding: 0.4rem;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius-sm);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(var(--c-accent-rgb), 0.06);
  opacity: 0;
  transform: scale(0.96);
  transform-origin: top left;
  pointer-events: none;
  transition: opacity var(--c-transition-fast), transform var(--c-transition-fast);
}

.c-context-menu.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.c-context-menu__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem;
  border-radius: 6px;
  font-family: var(--c-font-sans);
  font-size: 0.85rem;
  color: var(--c-text-soft);
  text-align: left;
  transition: background-color var(--c-transition-fast), color var(--c-transition-fast);
}

.c-context-menu__item:hover,
.c-context-menu__item:focus-visible {
  background: var(--c-accent-soft);
  color: var(--c-accent);
}

.c-context-menu__icon {
  display: flex;
  flex-shrink: 0;
  color: var(--c-text-faint);
  transition: color var(--c-transition-fast);
}

.c-context-menu__item:hover .c-context-menu__icon,
.c-context-menu__item:focus-visible .c-context-menu__icon {
  color: var(--c-accent);
}

/* Brief flash on the post a "Перейти к посту" jump lands on, so it reads
   clearly against the rest of the feed instead of just silently scrolling
   into view. */
.c-post--highlight {
  animation: cPostHighlight 1.6s var(--c-ease);
}

@keyframes cPostHighlight {
  0% {
    box-shadow: 0 0 0 1px rgba(var(--c-accent-rgb), 0.7), 0 0 24px var(--c-accent-glow);
    border-color: rgba(var(--c-accent-rgb), 0.7);
  }
  100% {
    box-shadow: none;
    border-color: var(--c-border);
  }
}

/* ==========================================================================
   Background pattern — page-margin texture outside the card, chosen in the
   admin (posts-settings "Узор фона" field). Same body[data-bg-pattern]
   attribute .c-frame::after reads for the feed's own background (see
   above) — one setting, two places it shows up. Sits below the page orbs;
   "none" (the default) paints nothing. Desktop only, same reasoning as the
   page orbs below: the frame is edge-to-edge on mobile, so there's no
   margin left for either to show through (the feed's own texture still
   covers that case).
   ========================================================================== */
.c-bg-pattern {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

body[data-bg-pattern="dots"] .c-bg-pattern {
  background-image: radial-gradient(rgba(var(--c-accent-rgb), 0.28) 1.5px, transparent 1.5px);
  background-size: 26px 26px;
}

body[data-bg-pattern="grid"] .c-bg-pattern {
  background-image:
    linear-gradient(rgba(var(--c-accent-rgb), 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--c-accent-rgb), 0.14) 1px, transparent 1px);
  background-size: 48px 48px;
}

body[data-bg-pattern="diagonal"] .c-bg-pattern {
  background-image: repeating-linear-gradient(135deg, rgba(var(--c-accent-rgb), 0.14) 0, rgba(var(--c-accent-rgb), 0.14) 1px, transparent 1px, transparent 18px);
}

/* ==========================================================================
   Page orbs — livelier than the internal feed breathing, positioned in the
   margins around the centered card. One of the "Узор фона" choices in the
   admin (value "orbs", alongside none/dots/grid/diagonal — see the
   .c-bg-pattern block above), so shown only when that's selected, not
   unconditionally. Desktop only regardless (see the mobile media query
   below): on mobile the frame is edge-to-edge, there is no free space
   around it to put orbs in.
   ========================================================================== */
.c-page-orbs {
  display: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

body[data-bg-pattern="orbs"] .c-page-orbs {
  display: block;
}

.c-page-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  animation: cPageOrbPulse 11s ease-in-out infinite;
}

.c-page-orb--a {
  top: -14%;
  left: -8%;
  width: 480px;
  height: 480px;
  background: var(--c-accent);
  opacity: 0.16;
}

.c-page-orb--b {
  bottom: -18%;
  right: -10%;
  width: 560px;
  height: 560px;
  background: rgb(var(--c-warm-rgb));
  opacity: 0.18;
  animation-duration: 14s;
  animation-delay: 2s;
}

@keyframes cPageOrbPulse {
  0%, 100% { transform: scale(1) translate(0, 0); }
  50% { transform: scale(1.18) translate(2%, -2%); }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .c-stats__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .c-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  /* Same .nav__toggle/.nav__links mobile-dropdown recipe as index.html
     (identical markup/CSS/JS), reused as-is by both the Channel Home nav
     (#cNavLinks) and the reader's filter menu (#cFiltersMobile) — only
     recolored via the channel's c- variables. */
  .c-nav__links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    flex-direction: column;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
    padding: 1rem 1.5rem 1.5rem;
    gap: 1rem;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--c-transition), transform var(--c-transition);
  }

  .c-nav__links.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .c-nav__toggle {
    display: flex;
  }

  .c-nav__toggle.is-open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .c-nav__toggle.is-open span:nth-child(2) {
    opacity: 0;
  }

  .c-nav__toggle.is-open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .c-hero {
    padding-top: 7rem;
  }

  .c-hero__cta {
    flex-direction: column;
    align-items: stretch;
  }

  .c-section {
    padding: 4rem 1.25rem;
  }

  .c-contacts {
    grid-template-columns: 1fr;
  }

  /* Reader: switch from sidebar+feed to mobile header+chat feed. The
     .c-app / .c-frame / .c-feed height chain (base rules above) already
     holds at 100vh with only .c-feed scrolling — no min-height override
     needed here, that would just push the shell taller than the viewport
     and bring back page-level scrolling. */
  .c-app {
    padding: 0;
  }

  .c-app__top {
    display: none;
  }

  /* No free space around an edge-to-edge frame on mobile to put orbs (or
     the page-margin pattern) in — the feed's own .c-frame::after texture
     already covers this case. The body[data-bg-pattern="orbs"] override
     above is more specific than a plain .c-page-orbs rule, so it has to be
     repeated here to actually win on mobile instead of just the desktop
     default. */
  .c-page-orbs,
  .c-bg-pattern,
  body[data-bg-pattern="orbs"] .c-page-orbs {
    display: none;
  }

  .c-frame {
    flex-direction: column;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .c-jump-latest {
    right: 1rem;
    bottom: 1rem;
    width: 38px;
    height: 38px;
  }

  .c-sidebar {
    display: none;
  }

  .c-mobile-header {
    display: flex;
  }

  .c-feed {
    padding: 1rem 0.875rem;
    gap: 0.75rem;
  }

  .c-post {
    max-width: 94%;
    border-radius: 14px 14px 14px 4px;
    padding: 0.75rem 0.875rem;
    gap: 0.625rem;
  }

  .c-post__heading {
    font-size: 0.95rem;
  }

  .c-post__para {
    font-size: 0.85rem;
    line-height: 1.6;
  }

  .c-post__list-item {
    font-size: 0.82rem;
  }

  .c-post__figure figcaption {
    font-size: 0.68rem;
  }

  .c-post__gallery {
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
    gap: 0.375rem;
  }

  .c-player {
    max-width: 100%;
  }

  /* 30px controls are an easy click but a genuinely small target for a
     real thumb — bump everything toward the ~44px minimum touch-target
     guideline so taps land reliably instead of slipping onto a neighbor
     or the video underneath. */
  .c-player__controls {
    gap: 0.15rem;
    padding: 0.5rem 0.4rem;
  }

  .c-player__btn {
    width: 40px;
    height: 40px;
  }

  .c-player__progress {
    height: 40px;
  }

  .c-player__volume-range {
    display: none;
  }

  .c-videolink {
    padding: 0.625rem;
    gap: 0.625rem;
  }

  .c-videolink__thumb {
    width: 80px;
    height: 56px;
  }

  .c-videolink__favicon {
    width: 22px;
    height: 22px;
  }

  .c-videolink__title {
    font-size: 0.78rem;
  }

  .c-post__code {
    font-size: 0.72rem;
    padding: 0.625rem 0.7rem;
  }
}

@media (max-width: 480px) {
  .c-stats__grid {
    grid-template-columns: 1fr;
  }

  .c-nav__inner {
    padding: 1rem;
  }

  .c-calendar {
    padding: 1rem;
  }

  .c-calendar__panel {
    max-width: 100%;
  }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .c-reveal,
  .c-btn,
  .c-topic-card,
  .c-stat,
  .c-contact-link,
  .c-videolink,
  .c-jump-latest,
  .c-lightbox,
  .c-lightbox__img,
  .c-calendar,
  .c-calendar__panel,
  .c-post__figure img,
  .c-post__gallery-item,
  .c-lightbox__nav,
  .c-player__overlay-play,
  .c-player__overlay-play-btn,
  .c-player__btn,
  .c-feed__chip,
  .c-nav__links,
  .c-nav__links a::after {
    transition: none !important;
  }

  .c-reveal {
    opacity: 1;
    transform: none;
  }

  .c-hero__glow,
  .c-orb::after,
  .c-frame::before,
  .c-page-orb {
    animation: none !important;
  }

  .c-frame::before {
    opacity: 0.7;
  }

  .c-orb {
    transition: none !important;
  }

  .c-cursor-spotlight {
    display: none;
  }
}

/* ==========================================================================
   Banner (constructor-added block type) — same hover-lift language as
   index.html's .channel-plug, recolored via the channel's c- variables.
   ========================================================================== */
.c-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  padding: 1.5rem 1.75rem;
  text-decoration: none;
  color: inherit;
  transition: transform var(--c-transition), box-shadow var(--c-transition), border-color var(--c-transition);
}

.c-banner:hover,
.c-banner:focus-visible {
  transform: translateY(-4px);
  border-color: var(--c-border-hover);
  box-shadow: 0 16px 40px var(--c-accent-glow);
}

.c-banner__title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 0.35rem;
}

.c-banner__desc {
  color: var(--c-text-dim);
  font-size: 0.92rem;
}

.c-banner__cta {
  flex-shrink: 0;
  color: var(--c-accent);
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}

/* ==========================================================================
   Grid (constructor-added block type) — same card-hover pattern as
   index.html's .interest, recolored. Explicit 4-column grid with per-item
   colSpan/rowSpan (see blocks.py's render_grid / style.css's .interests
   for the full rationale — both grids share the same constructor UI).
   ========================================================================== */
.c-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(160px, auto);
  gap: 1.5rem;
}

.c-grid__item {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: border-color var(--c-transition), transform var(--c-transition), box-shadow var(--c-transition);
}

.c-grid__item:hover {
  border-color: var(--c-border-hover);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px var(--c-accent-soft);
}

.c-grid__item h3 {
  color: var(--c-accent);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.c-grid__item p {
  color: var(--c-text-dim);
  font-size: 0.95rem;
}

.c-grid__item__number {
  display: block;
  color: var(--c-accent);
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1.1;
}

.c-grid__item__label {
  display: block;
  color: var(--c-text-dim);
  font-size: 0.95rem;
  margin-top: 0.4rem;
}

a.c-grid__item {
  text-decoration: none;
  color: inherit;
  position: relative;
}

a.c-grid__item:hover {
  border-color: var(--c-accent);
}

.c-grid__item__arrow {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  color: var(--c-accent);
  font-size: 1.2rem;
  transition: transform var(--c-transition);
}

a.c-grid__item:hover .c-grid__item__arrow {
  transform: translateX(4px);
}

@media (max-width: 860px) {
  .c-grid {
    grid-template-columns: 1fr;
  }

  .c-grid__item {
    grid-column: auto !important;
    grid-row: auto !important;
  }
}

/* ==========================================================================
   Anime (constructor-added block type) — same --a-accent/--a-accent-rgb
   per-card tint as style.css's .anime-card, falling back to --c-accent.
   ========================================================================== */
.c-anime-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.4rem;
}

.c-anime-card {
  --a-glow: rgba(var(--a-accent-rgb, var(--c-accent-rgb)), 0.4);
  --a-soft: rgba(var(--a-accent-rgb, var(--c-accent-rgb)), 0.16);
  position: relative;
  display: block;
  border-radius: var(--c-radius);
  overflow: hidden;
  border: 1px solid var(--a-soft);
  background: var(--c-bg-card);
  color: inherit;
  text-decoration: none;
  aspect-ratio: 2 / 3;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.c-anime-card:hover,
.c-anime-card:focus-visible {
  transform: translateY(-6px);
  border-color: var(--a-accent, var(--c-accent));
  box-shadow: 0 16px 40px var(--a-glow);
}

.c-anime-card--featured {
  grid-column: span 2;
  grid-row: span 2;
}

.c-anime-card__poster {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-size: cover;
  background-position: center;
}

.c-anime-card__poster--placeholder {
  background-image: repeating-linear-gradient(135deg, var(--c-bg-card), var(--c-bg-card) 10px, var(--c-bg-elevated) 10px, var(--c-bg-elevated) 20px);
}

.c-anime-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent 55%);
  pointer-events: none;
}

.c-anime-card__info {
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.8rem;
}

.c-anime-card__title {
  display: block;
  color: var(--c-text);
  font-weight: 700;
  font-size: 0.95rem;
  text-shadow: 0 0 12px var(--a-glow);
}

.c-anime-card--featured .c-anime-card__title {
  font-size: 1.3rem;
}

.c-anime-card__year {
  display: block;
  color: var(--a-accent, var(--c-accent));
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 0.15rem;
}

@media (max-width: 640px) {
  .c-anime-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
  }

  .c-anime-card--featured {
    grid-column: span 2;
    grid-row: span 1;
  }
}

/* ==========================================================================
   Books (constructor-added block type)
   ========================================================================== */
.c-book-highlight {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--c-accent-soft);
  border: 1px solid var(--c-accent-glow);
  border-radius: var(--c-radius);
  padding: 1.5rem 1.75rem;
  margin: 0 0 2.5rem;
}

.c-book-highlight__icon {
  flex-shrink: 0;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  color: var(--c-accent);
  letter-spacing: 0.05em;
}

.c-book-highlight__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.c-book-highlight__author {
  color: var(--c-text-dim);
  font-size: 0.9rem;
}

.c-book-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--c-border);
}

.c-book-list__item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--c-border);
}

.c-book-list__title {
  font-weight: 600;
}

.c-book-list__author {
  color: var(--c-text-dim);
  font-size: 0.9rem;
}

/* ==========================================================================
   Quote block (constructor-added block type)
   ========================================================================== */
.c-quote-block {
  max-width: 560px;
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  padding: 1.75rem 2rem;
  text-align: center;
}

.c-quote-block__text {
  font-size: 1.1rem;
  font-style: italic;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.c-quote-block__author {
  color: var(--c-accent);
  font-size: 0.85rem;
  font-weight: 600;
  font-style: normal;
}

/* ==========================================================================
   Text block (constructor-added block type)
   ========================================================================== */
.c-text-block {
  color: var(--c-text-dim);
  font-size: 0.98rem;
  line-height: 1.75;
  max-width: 640px;
}

/* ==========================================================================
   Block background animations (constructor "Анимация фона" field — see
   blocks.py's _bg_animation_html / admin.js's BG_ANIMATIONS). Same ten
   presets as style.css's .bg-anim, re-tinted to the warm palette here
   (--c-warm-rgb primary, --c-accent-rgb secondary). Sits at z-index: 0,
   same layer as .c-section-orbs, behind .c-section__inner (z-index: 1).
   ========================================================================== */
.c-bg-anim {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

/* 1. Drift orbs — two soft blurred circles wandering independently */
.c-bg-anim--drift-orbs::before,
.c-bg-anim--drift-orbs::after {
  content: '';
  position: absolute;
  width: 42%;
  padding-bottom: 42%;
  border-radius: 50%;
  filter: blur(60px);
}

.c-bg-anim--drift-orbs::before {
  left: 6%;
  top: 8%;
  background: radial-gradient(circle, rgba(var(--c-warm-rgb), 0.24), transparent 70%);
  animation: bgAnimDrift1 26s ease-in-out infinite;
}

.c-bg-anim--drift-orbs::after {
  right: 8%;
  bottom: 6%;
  background: radial-gradient(circle, rgba(var(--c-accent-rgb), 0.2), transparent 70%);
  animation: bgAnimDrift2 32s ease-in-out infinite;
}

@keyframes bgAnimDrift1 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(8%, 12%); }
}

@keyframes bgAnimDrift2 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-10%, -8%); }
}

/* 2. Aurora — wide diagonal color band sweeping slowly */
.c-bg-anim--aurora {
  background: linear-gradient(115deg,
    transparent 20%,
    rgba(var(--c-warm-rgb), 0.16) 40%,
    rgba(var(--c-accent-rgb), 0.16) 55%,
    transparent 75%);
  background-size: 250% 250%;
  animation: bgAnimAurora 34s ease-in-out infinite;
}

@keyframes bgAnimAurora {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* 3. Grain pulse — faint vignette breathing */
.c-bg-anim--grain-pulse {
  background: radial-gradient(ellipse 70% 60% at 50% 40%, rgba(var(--c-accent-rgb), 0.18), transparent 70%);
  animation: bgAnimPulse 14s ease-in-out infinite;
}

@keyframes bgAnimPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* 4. Soft grid — faint ruled lines panning diagonally */
.c-bg-anim--soft-grid {
  background-image:
    linear-gradient(rgba(var(--c-accent-rgb), 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--c-accent-rgb), 0.09) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 50%, black, transparent 75%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, black, transparent 75%);
  animation: bgAnimGridPan 40s linear infinite;
}

@keyframes bgAnimGridPan {
  0% { background-position: 0 0, 0 0; }
  100% { background-position: 46px 46px, 46px 46px; }
}

/* 5. Floating particles — small dots drifting upward at two speeds */
.c-bg-anim--floating-particles::before,
.c-bg-anim--floating-particles::after {
  content: '';
  position: absolute;
  inset: -20% 0;
  background-image: radial-gradient(circle, rgba(var(--c-accent-rgb), 0.4) 0 2px, transparent 3px);
  background-repeat: repeat;
  background-size: 90px 120px;
}

.c-bg-anim--floating-particles::before {
  background-position: 10px 20px;
  animation: bgAnimFloat 22s linear infinite;
}

.c-bg-anim--floating-particles::after {
  background-position: 60px 80px;
  opacity: 0.6;
  animation: bgAnimFloat 30s linear infinite reverse;
}

@keyframes bgAnimFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-120px); }
}

/* 6. Gradient sweep — soft glow sweeping left to right */
.c-bg-anim--gradient-sweep {
  background: radial-gradient(ellipse 45% 70% at 50% 50%, rgba(var(--c-accent-rgb), 0.2), transparent 70%);
  background-repeat: no-repeat;
  animation: bgAnimSweep 28s ease-in-out infinite;
}

@keyframes bgAnimSweep {
  0%, 100% { background-position: -20% 50%; }
  50% { background-position: 120% 50%; }
}

/* 7. Slow rotate — large soft conic blob rotating gently */
.c-bg-anim--slow-rotate::before {
  content: '';
  position: absolute;
  inset: -30%;
  background: conic-gradient(from 0deg,
    rgba(var(--c-warm-rgb), 0.12),
    rgba(var(--c-accent-rgb), 0.12),
    rgba(var(--c-warm-rgb), 0.12));
  filter: blur(50px);
  animation: bgAnimRotate 60s linear infinite;
}

@keyframes bgAnimRotate {
  to { transform: rotate(360deg); }
}

/* 8. Pulse glow — single centered glow breathing */
.c-bg-anim--pulse-glow {
  background: radial-gradient(circle at 50% 45%, rgba(var(--c-accent-rgb), 0.24), transparent 60%);
  animation: bgAnimPulseGlow 9s ease-in-out infinite;
}

@keyframes bgAnimPulseGlow {
  0%, 100% { transform: scale(0.92); opacity: 0.6; }
  50% { transform: scale(1.05); opacity: 1; }
}

/* 9. Rising bubbles — a steady grid of soft circles rising, seamless loop */
.c-bg-anim--rising-bubbles {
  background-image: radial-gradient(circle, rgba(var(--c-warm-rgb), 0.26) 0 5px, transparent 6px);
  background-repeat: repeat;
  background-size: 70px 140px;
  animation: bgAnimRiseUp 20s linear infinite;
}

@keyframes bgAnimRiseUp {
  0% { background-position: 0 0; }
  100% { background-position: 0 -140px; }
}

/* 10. Wave lines — gently shifting diagonal stripes */
.c-bg-anim--wave-lines {
  background-image: repeating-linear-gradient(
    -6deg,
    rgba(var(--c-accent-rgb), 0.12) 0px,
    rgba(var(--c-accent-rgb), 0.12) 2px,
    transparent 2px,
    transparent 34px
  );
  background-size: 200% 200%;
  animation: bgAnimWave 24s ease-in-out infinite;
}

@keyframes bgAnimWave {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 12% 8%; }
}

@media (prefers-reduced-motion: reduce) {
  .c-bg-anim,
  .c-bg-anim::before,
  .c-bg-anim::after {
    animation: none !important;
  }
}
