/* ===================================================================
   MasisTV — Стандартная тема. Красивый адаптивный дизайн.
   Цвета и шрифты берутся из CSS-переменных (управляются в «Дизайн»).
   =================================================================== */

:root {
  --color-bg: #ffffff;
  --color-text: #1f2937;
  --color-muted: #6b7280;
  --color-accent: #4f46e5;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-heading: var(--font-body);
  --content-width: 46rem;

  /* Derived layout tokens (not user-facing) */
  --wrap: 74rem;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .14);
  /* Surfaces/borders derive from the colour tokens, so light/dark palettes
     (set in the Design panel) automatically drive cards, borders and footer. */
  --surface: var(--color-bg);
  --surface-2: color-mix(in srgb, var(--color-text) 5%, var(--color-bg));
  --border: color-mix(in srgb, var(--color-text) 12%, var(--color-bg));
  --header-h: 68px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.2; letter-spacing: -.01em; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); }
.wrap-narrow { max-width: calc(var(--content-width) + 4rem); margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); }

/* ---------- Header ---------- */
.site-header {
  position: relative;
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -.02em;
  color: var(--color-text);
}
.brand:hover { text-decoration: none; }
.brand-logo { display: block; height: 36px; width: auto; max-width: 220px; }
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .logo-light { display: none; }
  .logo-dark { display: block; }
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.site-nav a {
  color: var(--color-text);
  font-weight: 500;
  font-size: .96rem;
  padding: 8px 12px;
  border-radius: 999px;
  transition: background .18s ease, color .18s ease;
}
.site-nav a:hover { text-decoration: none; background: var(--surface-2); color: var(--color-accent); }

/* Dropdown submenus (desktop: hover; mobile: tap to expand). */
.has-sub { position: relative; }
.sub-toggle { display: inline-flex; align-items: center; gap: 4px; }
.sub-toggle .caret { transition: transform .2s ease; opacity: .7; }
.submenu {
  position: absolute; top: 100%; left: 0; z-index: 70; min-width: 200px;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
}
.submenu a { border-radius: 8px; padding: 8px 12px; font-weight: 400; white-space: nowrap; }
.has-sub:hover > .submenu, .has-sub:focus-within > .submenu {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.has-sub:hover > .sub-toggle .caret { transform: rotate(180deg); }

/* Dark-mode toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--color-text); cursor: pointer; font-size: 1.05rem; line-height: 1;
  transition: background .18s ease, border-color .18s ease;
}
.theme-toggle:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--color-accent) 40%, var(--border)); }
.theme-toggle .ti-sun { display: none; }
html.dark .theme-toggle .ti-sun { display: inline; }
html.dark .theme-toggle .ti-moon { display: none; }

/* Language globe */
.lang { position: relative; }
.lang-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--color-text); cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.lang-btn:hover { background: var(--surface-2); color: var(--color-accent); border-color: color-mix(in srgb, var(--color-accent) 40%, var(--border)); }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 10px);
  min-width: 170px; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
  z-index: 60;
}
.lang.open .lang-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.lang-menu a {
  display: block; padding: 9px 12px; border-radius: 8px;
  color: var(--color-text); font-size: .95rem;
}
.lang-menu a:hover { text-decoration: none; background: var(--surface-2); }
.lang-menu a.current { color: var(--color-accent); font-weight: 600; background: color-mix(in srgb, var(--color-accent) 8%, transparent); }

/* Hamburger */
.nav-toggle {
  display: none; margin-left: auto;
  width: 42px; height: 42px; padding: 0;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 12px; cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.nav-toggle span { display: block; width: 20px; height: 2px; background: var(--color-text); border-radius: 2px; transition: transform .25s ease, opacity .2s ease; }
.nav-scrim {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s; z-index: 55;
}

/* ---------- Home / archive hero ---------- */
.page-hero { padding: clamp(32px, 6vw, 64px) 0 clamp(20px, 4vw, 36px); }
.page-hero-title { margin: 0; font-size: clamp(1.9rem, 5vw, 3rem); font-weight: 800; }
.page-hero-sub { margin: 12px 0 0; color: var(--color-muted); font-size: 1.05rem; }

/* ---------- Post cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: clamp(20px, 3vw, 32px);
  padding-bottom: clamp(40px, 8vw, 80px);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--color-accent) 24%, var(--border)); }
.card-media {
  display: block; position: relative;
  aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2);
}
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s cubic-bezier(.2,.7,.2,1); }
.card:hover .card-media img { transform: scale(1.06); }
.card-ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 18px; text-align: center; font-weight: 700; color: #fff;
  font-size: 1.1rem; line-height: 1.3;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--color-accent) 85%, #000 0%),
    color-mix(in srgb, var(--color-accent) 55%, #7c3aed));
}
.card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-title { margin: 0; font-size: 1.22rem; font-weight: 700; line-height: 1.3; }
.card-title a { color: var(--color-text); }
.card-title a:hover { color: var(--color-accent); text-decoration: none; }
.card-excerpt {
  margin: 0; color: var(--color-muted); font-size: .96rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { margin-top: auto; padding-top: 6px; color: var(--color-muted); font-size: .85rem; display: flex; gap: 6px; flex-wrap: wrap; }
.card-meta .dot { opacity: .6; }
.empty { color: var(--color-muted); padding: 40px 0; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 0 clamp(48px, 8vw, 88px);
}
.pg-num, .pg-arrow, .pg-gap {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 42px; padding: 0 12px;
  border-radius: 12px; font-weight: 600; font-size: .98rem;
}
.pg-num, .pg-arrow {
  border: 1px solid var(--border); background: var(--surface); color: var(--color-text);
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .12s ease;
}
.pg-num:hover, .pg-arrow:not(.pg-disabled):hover {
  text-decoration: none; background: var(--surface-2);
  border-color: color-mix(in srgb, var(--color-accent) 40%, var(--border));
  color: var(--color-accent); transform: translateY(-1px);
}
.pg-current {
  background: var(--color-accent); border-color: var(--color-accent); color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--color-accent) 40%, transparent);
}
.pg-current:hover { color: #fff; background: var(--color-accent); transform: none; }
.pg-gap { color: var(--color-muted); min-width: 28px; padding: 0 4px; }
.pg-disabled { opacity: .38; cursor: default; }

/* ---------- Single post ---------- */
.post { padding-bottom: clamp(32px, 6vw, 64px); }

/* Breadcrumbs */
.breadcrumbs { padding-top: 24px; font-size: .85rem; color: var(--color-muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.breadcrumbs a { color: var(--color-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--color-accent); }
.breadcrumbs .sep { opacity: .5; }

/* Table of contents */
.toc { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 0 0 28px; }
.toc-title { font-weight: 700; font-size: .95rem; margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { padding: 3px 0; }
.toc a { color: var(--color-text); text-decoration: none; font-size: .95rem; }
.toc a:hover { color: var(--color-accent); }
.toc .toc-l3 { padding-left: 16px; font-size: .9rem; }

/* Related posts */
.related { padding: clamp(32px, 6vw, 56px) 0; border-top: 1px solid var(--border); }
.related-title { font-size: 1.5rem; margin: 0 0 20px; }
.post-head { padding: clamp(28px, 6vw, 56px) 0 8px; }
.post-title { margin: 0; font-size: clamp(1.8rem, 4.5vw, 2.7rem); font-weight: 800; }
.post-meta { margin-top: 14px; color: var(--color-muted); font-size: .95rem; display: flex; gap: 6px; }
.post-hero {
  width: 100%; aspect-ratio: 16 / 9; max-height: 42vh; object-fit: cover;
  border-radius: var(--radius); margin: 22px 0 6px; box-shadow: var(--shadow);
}

/* Content typography */
.prose { font-size: 1.09rem; line-height: 1.75; }
.prose > * + * { margin-top: 1.25em; }
.prose h2 { font-size: 1.6rem; margin-top: 1.8em; }
.prose h3 { font-size: 1.3rem; margin-top: 1.6em; }
.prose img, .prose figure img { border-radius: var(--radius-sm); }
.prose figure { margin: 1.6em 0; }
.prose figcaption { color: var(--color-muted); font-size: .9rem; text-align: center; margin-top: .6em; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose blockquote {
  margin: 1.6em 0; padding: 4px 0 4px 20px;
  border-left: 4px solid var(--color-accent); color: var(--color-muted); font-style: italic;
}
.prose code {
  background: var(--surface-2); padding: .15em .4em; border-radius: 6px;
  font-size: .9em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.prose pre { background: #0f172a; color: #e2e8f0; padding: 18px; border-radius: var(--radius-sm); overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius-sm); }

/* Reactions */
.reactions { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 8px; }
.reaction {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--color-text); font: inherit; font-size: 1rem; transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.reaction:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--color-accent) 40%, var(--border)); }
.reaction.on { border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, var(--surface)); }
.reaction .r-count { font-size: .85rem; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.reaction.on .r-count { color: var(--color-accent); font-weight: 600; }

.tags { margin-top: 40px; display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  padding: 6px 14px; border-radius: 999px; font-size: .88rem;
  background: var(--surface-2); color: var(--color-muted);
}
.tag:hover { text-decoration: none; background: color-mix(in srgb, var(--color-accent) 12%, transparent); color: var(--color-accent); }

/* ---------- Contact form ---------- */
.contact-page { padding: clamp(32px, 6vw, 64px) 0; }
.contact-form { margin-top: 20px; }
.contact-row { display: flex; gap: 12px; }
.contact-form input, .contact-form textarea {
  width: 100%; margin-top: 12px; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--color-text); font: inherit; font-size: .95rem;
}
.contact-row input { margin-top: 0; }
.contact-form textarea { resize: vertical; }
.contact-form .btn { margin-top: 16px; border: 0; }
@media (max-width: 560px) { .contact-row { flex-direction: column; gap: 0; } .contact-row input:last-child { margin-top: 12px; } }

/* ---------- Form builder ---------- */
.form-builder { display: flex; flex-wrap: wrap; gap: 14px 16px; }
.form-builder .form-field { flex: 1 1 100%; margin: 0; }
.form-builder .form-w-half { flex: 1 1 calc(50% - 8px); }
.form-builder .form-w-third { flex: 1 1 calc(33.333% - 11px); }
.form-builder input, .form-builder textarea, .form-builder select {
  width: 100%; margin-top: 6px; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--color-text); font: inherit; font-size: .95rem;
}
.form-builder textarea { resize: vertical; }
.form-label { font-weight: 600; font-size: .9rem; }
.form-section { flex: 1 1 100%; margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--border); font-size: 1.15rem; }
.form-html { flex: 1 1 100%; color: var(--color-muted); font-size: .95rem; }
.form-options { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.form-opt { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.form-opt input { width: auto; margin: 0; }
.form-consent { flex: 1 1 100%; }
.form-help { display: block; margin-top: 4px; color: var(--color-muted); font-size: .82rem; }
.form-builder .btn { flex: 1 1 100%; margin-top: 8px; border: 0; }
@media (max-width: 560px) { .form-builder .form-w-half, .form-builder .form-w-third { flex-basis: 100%; } }

/* ---------- Buttons / 404 ---------- */
.btn {
  display: inline-block; padding: 12px 22px; border-radius: 999px;
  background: var(--color-accent); color: #fff; font-weight: 600;
  transition: transform .15s ease, filter .15s ease;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); transform: translateY(-1px); }
.not-found { padding: clamp(48px, 9vw, 96px) 0 clamp(40px, 8vw, 80px); }
.nf-hero { text-align: center; max-width: 660px; margin: 0 auto; }

/* Big watermark number — decorative, so it scales freely and never wraps. */
.nf-code {
  margin: 0; line-height: .9; font-weight: 800; letter-spacing: -.04em;
  font-size: clamp(5.5rem, 22vw, 11rem);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--color-accent) 85%, var(--color-text)),
    color-mix(in srgb, var(--color-accent) 25%, transparent));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--color-accent);
}
.nf-title { margin: 4px 0 0; font-size: clamp(1.5rem, 4.5vw, 2.25rem); line-height: 1.2; }
.nf-lead { margin: 14px auto 0; max-width: 52ch; color: var(--color-muted); font-size: 1.02rem; }

/* Search */
.nf-search { margin-top: 28px; }
.nf-search-label {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.nf-search-row { display: flex; gap: 10px; max-width: 520px; margin: 0 auto; }
.nf-search-row input {
  flex: 1 1 auto; min-width: 0; padding: 12px 16px; font: inherit; font-size: .98rem;
  color: var(--color-text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; transition: border-color .15s ease, box-shadow .15s ease;
}
.nf-search-row input:focus {
  outline: none; border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 22%, transparent);
}
.nf-search-row .btn { flex: 0 0 auto; }

/* Secondary links */
.nf-actions {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 10px; margin-top: 24px;
}
.btn-ghost {
  display: inline-block; padding: 11px 18px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--color-text); font-weight: 500; font-size: .95rem;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn-ghost:hover {
  text-decoration: none; background: var(--surface-2); color: var(--color-accent);
  border-color: color-mix(in srgb, var(--color-accent) 40%, var(--border));
}

/* Suggested posts */
.nf-suggest { margin-top: clamp(48px, 8vw, 80px); }
.nf-suggest-title {
  margin: 0 0 20px; font-size: 1.15rem; text-align: center; color: var(--color-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
}

@media (max-width: 520px) {
  .nf-search-row { flex-direction: column; }
  .nf-search-row .btn { width: 100%; text-align: center; }
}

/* ---------- Comments ---------- */
.comments { padding-bottom: clamp(40px, 8vw, 80px); }
.comments-title { font-size: 1.5rem; margin: 0 0 20px; }
.comment-notice { background: color-mix(in srgb, var(--color-accent) 10%, var(--color-bg)); color: var(--color-text); border-radius: var(--radius-sm); padding: 10px 14px; font-size: .95rem; }
.comment-list, .comment-children { list-style: none; padding: 0; margin: 0; }
.comment { padding: 16px 0; border-bottom: 1px solid var(--border); }
.comment-children .comment:last-child { border-bottom: none; }
.comment-head { display: flex; align-items: baseline; gap: 10px; }
.comment-author { font-weight: 600; color: var(--color-text); text-decoration: none; }
.comment-date { color: var(--color-muted); font-size: .82rem; }
.comment-body { margin-top: 6px; line-height: 1.6; }
.comment-empty { color: var(--color-muted); }
.comment-closed { color: var(--color-muted); font-style: italic; }

.comment-form { margin-top: 32px; padding-top: 24px; border-top: 2px solid var(--border); }
.comment-form-title { font-size: 1.2rem; margin: 0 0 14px; }
.comment-fields { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.comment-form input, .comment-form textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--color-text); font: inherit; font-size: .95rem;
}
.comment-form textarea { margin-top: 10px; resize: vertical; }
.comment-form input:focus, .comment-form textarea:focus { outline: 2px solid color-mix(in srgb, var(--color-accent) 50%, transparent); outline-offset: 1px; }
.comment-hp { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; }
.comment-submit { margin-top: 14px; border: 0; }
@media (max-width: 560px) { .comment-fields { grid-template-columns: 1fr; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface-2); margin-top: 40px; }
.footer-inner { padding: 44px 0; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }

/* Subscribe form */
.subscribe { width: 100%; max-width: 30rem; margin-bottom: 8px; }
.subscribe-title { font-weight: 600; margin-bottom: 10px; }
.subscribe-notice { font-size: .9rem; color: var(--color-accent); margin-bottom: 10px; }
.subscribe-row { display: flex; gap: 8px; }
.subscribe-row input[type="email"] {
  flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--color-text); font: inherit; font-size: .95rem;
}
.subscribe-row .btn { white-space: nowrap; }
@media (max-width: 460px) { .subscribe-row { flex-direction: column; } .subscribe-row .btn { width: 100%; } }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; }
.footer-nav a { color: var(--color-muted); padding: 6px 10px; border-radius: 8px; font-size: .95rem; }
.footer-nav a:hover { text-decoration: none; color: var(--color-accent); }
.footer-copy { margin: 0; color: var(--color-muted); font-size: .88rem; }

/* ---------- Responsive: mobile nav ---------- */
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
    width: min(80vw, 320px);
    flex-direction: column; align-items: stretch; gap: 4px;
    margin-left: 0; padding: calc(var(--header-h) + 16px) 16px 24px;
    background: var(--surface); border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%); transition: transform .28s cubic-bezier(.2,.7,.2,1);
    overflow-y: auto;
  }
  .site-nav a { font-size: 1.05rem; padding: 12px 14px; border-radius: 12px; }
  /* Mobile: submenu becomes an inline accordion opened by tapping the parent. */
  .has-sub { width: 100%; }
  .sub-toggle { justify-content: space-between; }
  .submenu {
    position: static; min-width: 0; border: 0; box-shadow: none; padding: 0 0 0 12px;
    background: transparent; opacity: 1; visibility: visible; transform: none;
    max-height: 0; overflow: hidden; transition: max-height .25s ease;
  }
  .has-sub.open > .submenu { max-height: 600px; }
  .has-sub.open > .sub-toggle .caret { transform: rotate(180deg); }
  .submenu a { font-size: .98rem; padding: 10px 14px; }
  body.nav-open .site-nav { transform: translateX(0); }
  body.nav-open .nav-scrim { opacity: 1; visibility: visible; }
  body.nav-open { overflow: hidden; }
  .lang { order: 3; }
  .header-inner { gap: 12px; }
}

@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
  .brand { font-size: 1.2rem; }
}

/* ---------- PWA install banner ---------- */
#pwa-banner {
  position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 140%);
  z-index: 200; width: min(440px, calc(100vw - 24px));
  padding: 16px 18px 18px; border-radius: 18px;
  background: var(--surface); color: var(--color-text);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transition: transform .35s cubic-bezier(.2,.7,.2,1); opacity: .98;
}
#pwa-banner.show { transform: translate(-50%, 0); }
#pwa-banner .pwa-row { display: flex; align-items: center; gap: 14px; }
#pwa-banner .pwa-icon { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: 0 0 auto; }
#pwa-banner .pwa-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#pwa-banner .pwa-text strong { font-size: 1.02rem; }
#pwa-banner .pwa-text span { color: var(--color-muted); font-size: .9rem; line-height: 1.35; }
#pwa-banner .pwa-install { display: block; width: 100%; margin-top: 14px; border: 0; text-align: center; cursor: pointer; }
#pwa-banner .pwa-ios { margin: 12px 0 0; color: var(--color-muted); font-size: .9rem; line-height: 1.4; }
#pwa-banner .pwa-close {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px;
  border: 0; border-radius: 999px; background: transparent; color: var(--color-muted);
  font-size: 15px; cursor: pointer; line-height: 1;
}
#pwa-banner .pwa-close:hover { background: var(--surface-2); color: var(--color-text); }

/* ---------- Member account pages ---------- */
.account-page { max-width: 30rem; margin: 0 auto; padding-bottom: clamp(40px, 8vw, 80px); }
.account-form input { margin-top: 12px; }
.account-error {
  margin: 16px 0 0; padding: 10px 14px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, #dc2626 12%, var(--color-bg));
  border: 1px solid color-mix(in srgb, #dc2626 35%, var(--border));
  color: var(--color-text); font-size: .95rem;
}
.account-or { margin: 26px 0 10px; text-align: center; color: var(--color-muted); font-size: .9rem; }
.social-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tg-widget { display: flex; justify-content: center; margin-top: 12px; }
.account-alt { margin-top: 26px; text-align: center; color: var(--color-muted); font-size: .95rem; }
.account-card {
  margin-top: 20px; padding: 20px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); text-align: center;
}
.account-name { margin: 0; font-size: 1.15rem; font-weight: 700; }
.account-email { margin: 4px 0 0; color: var(--color-muted); }
.account-hint { margin: 12px 0 16px; color: var(--color-muted); font-size: .9rem; }
.account-card .btn-ghost { cursor: pointer; font: inherit; font-size: .95rem; }
.comment-as { color: var(--color-muted); font-size: .95rem; margin: 0 0 10px; }

/* ---------- Frontend admin bar (WordPress-style, staff only) ---------- */
#admin-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 38px; z-index: 300;
  display: none; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 10px; background: #1f2430; color: #e5e7eb;
  font-size: .85rem; line-height: 1;
}
html.has-abar #admin-bar { display: flex; }
html.has-abar body { padding-top: 38px; }
#admin-bar a, #admin-bar button {
  color: #cbd5e1; text-decoration: none; padding: 6px 9px; border-radius: 6px;
  background: none; border: 0; cursor: pointer; font: inherit; white-space: nowrap;
}
#admin-bar a:hover, #admin-bar button:hover { background: #334155; color: #fff; text-decoration: none; }
.ab-left, .ab-right { display: flex; align-items: center; gap: 2px; min-width: 0; }
.ab-left { overflow-x: auto; scrollbar-width: none; }
.ab-left::-webkit-scrollbar { display: none; }
.ab-brand { font-weight: 600; }
.ab-edit { color: #a5b4fc; }
.ab-badge {
  display: inline-block; min-width: 18px; text-align: center;
  background: #dc2626; color: #fff; border-radius: 999px; padding: 1px 5px; font-size: .72rem;
}
#ab-show {
  position: fixed; top: 0; right: 14px; z-index: 300;
  background: #1f2430; color: #cbd5e1; border: 0; border-radius: 0 0 8px 8px;
  padding: 3px 12px; cursor: pointer; font-size: .8rem;
}
#ab-show:hover { color: #fff; }
html.has-abar #ab-show { display: none; }
