/* =========================================================================
   TSOY.IN — Design System (extracted from claude.ai/design prototypes)
   Vanilla CSS, ready for Twig porting. No Tailwind.
   ========================================================================= */

:root {
  /* Type */
  --font-ui:      'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --font-read:    'Source Serif 4', Georgia, serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* Rubric accents — applied via data-rubric on <html> */
  --acc-default:  #52525B;
  --acc-finance:  #10B981;
  --acc-politics: #3B82F6;
  --acc-anime:    #EC4899;
  --acc-tech:     #8B5CF6;
  --acc-philo:    #F59E0B;
  --acc-biz:      #F97316;
  --acc-science:  #06B6D4;
  --acc-essay:    #D946EF;
  --accent:       var(--acc-default);

  /* Spacing */
  --s-1:4px;  --s-2:8px;  --s-3:12px; --s-4:16px;
  --s-6:24px; --s-8:32px; --s-12:48px;--s-16:64px; --s-24:96px;

  /* Radii */
  --r-btn:6px; --r-card:8px; --r-modal:12px; --r-pill:999px;

  /* Motion */
  --t-fast: 120ms ease-out;
  --t-base: 200ms cubic-bezier(.16,1,.3,1);
  --t-slow: 400ms cubic-bezier(.16,1,.3,1);
}

[data-theme="dark"] {
  --bg-1:#0A0A0F; --bg-2:#13131C; --bg-3:#1B1B27;
  --bg-overlay: rgba(10,10,15,0.85);
  --tx-1:#F4F4F8; --tx-2:#A0A0B0; --tx-3:#60606E;
  --bd-1:#23232F; --bd-2:#2E2E3D;
  --shadow-card: none;
  --shadow-elev: 0 8px 24px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.4);
  --code-bg: #1B1B27;
  --cover-a:#1B1B27; --cover-b:#13131C;
}
[data-theme="light"] {
  --bg-1:#FAFAF7; --bg-2:#FFFFFF; --bg-3:#F0F0EA;
  --bg-overlay: rgba(10,10,15,0.55);
  --tx-1:#0A0A0F; --tx-2:#52525B; --tx-3:#A1A1AA;
  --bd-1:#E5E5DF; --bd-2:#D4D4CE;
  --shadow-card: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow-elev: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --code-bg:#F0F0EA;
  --cover-a:#F0F0EA; --cover-b:#E5E5DF;
}

[data-rubric="default"]  { --accent: var(--acc-default); }
[data-rubric="finance"]  { --accent: var(--acc-finance); }
[data-rubric="politics"] { --accent: var(--acc-politics); }
[data-rubric="anime"]    { --accent: var(--acc-anime); }
[data-rubric="tech"]     { --accent: var(--acc-tech); }
[data-rubric="philo"]    { --accent: var(--acc-philo); }
[data-rubric="biz"]      { --accent: var(--acc-biz); }
[data-rubric="science"]  { --accent: var(--acc-science); }
[data-rubric="essay"]    { --accent: var(--acc-essay); }

/* =========================================================================
   RESET
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  background-color: var(--bg-1);
  transition: background-color var(--t-base);
}
body {
  background-color: var(--bg-1);
  color: var(--tx-1);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t-base), color var(--t-base);
}
img, video { max-width: 100%; height: auto; display: block; }
button { font: inherit; }
a { color: inherit; }
::selection { background: var(--accent); color: #fff; }

/* =========================================================================
   SECTION BAR (sticky top, rubric switcher + projects/support pills)
   ========================================================================= */
.section-bar {
  position: sticky; top: 0; z-index: 50;
  height: 40px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 48px;
  background: color-mix(in oklab, var(--accent) 8%, var(--bg-1));
  border-bottom: 1px solid var(--bd-1);
  font-size: 13px;
  backdrop-filter: blur(8px);
  transition: background var(--t-base);
}
.section-bar .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px color-mix(in oklab, var(--accent) 80%, transparent);
  transition: var(--t-base);
}
.section-bar .cur {
  display: flex; align-items: center; gap: 8px;
  font-weight: 500; color: var(--tx-1);
  cursor: pointer; user-select: none; flex-shrink: 0;
}
.section-bar .cur svg { width: 13px; height: 13px; opacity: .55; }
.section-bar .divider { width: 1px; height: 14px; background: var(--bd-1); flex-shrink: 0; }
.section-bar .rubrics-wrap { position: relative; flex: 1; min-width: 0; }
.section-bar .rubrics-wrap::before,
.section-bar .rubrics-wrap::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 24px; pointer-events: none; z-index: 2;
}
.section-bar .rubrics-wrap::before {
  left: 0; background: linear-gradient(90deg, color-mix(in oklab, var(--accent) 8%, var(--bg-1)) 30%, transparent);
}
.section-bar .rubrics-wrap::after {
  right: 0; background: linear-gradient(270deg, color-mix(in oklab, var(--accent) 8%, var(--bg-1)) 30%, transparent);
}
.section-bar .rubrics {
  display: flex; gap: 2px; align-items: center; color: var(--tx-2);
  overflow-x: auto; scrollbar-width: none;
}
.section-bar .rubrics::-webkit-scrollbar { display: none; }
.section-bar .rch {
  padding: 4px 10px; border-radius: var(--r-pill);
  cursor: pointer; transition: var(--t-fast);
  font-weight: 500; font-size: 12px;
  border: 1px solid transparent; background: transparent; color: inherit;
  white-space: nowrap; text-decoration: none;
}
.section-bar .rch:hover { color: var(--tx-1); background: var(--bg-3); }
.section-bar .rch.active { color: var(--tx-1); background: var(--bg-3); border-color: var(--bd-1); }
.section-bar .rch .sw { display: inline-block; width: 5px; height: 5px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.section-bar .right {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

/* =========================================================================
   APP HEADER
   ========================================================================= */
.app-header {
  padding: 18px 48px;
  display: flex; align-items: center; gap: 28px;
  border-bottom: 1px solid var(--bd-1);
  background: var(--bg-1);
}
.logo {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--tx-1);
  line-height: 1;
}
.logo .in { color: var(--accent); font-style: italic; transition: color var(--t-base); }
.app-header nav { display: flex; gap: 22px; color: var(--tx-2); font-size: 14px; font-weight: 500; }
.app-header nav a {
  color: inherit; text-decoration: none;
  transition: color var(--t-fast);
  display: inline-flex; align-items: center; gap: 6px; position: relative;
}
.app-header nav a:hover, .app-header nav a.active { color: var(--tx-1); }
.app-header nav a.active::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px color-mix(in oklab, var(--accent) 80%, transparent);
}
.app-header .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.icon-btn {
  height: 32px; min-width: 32px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-btn); border: 1px solid var(--bd-1); background: transparent;
  color: var(--tx-2); cursor: pointer; transition: var(--t-fast);
  font-family: var(--font-ui); font-size: 13px;
  text-decoration: none;
}
.icon-btn:hover { background: var(--bg-3); color: var(--tx-1); border-color: var(--bd-2); }
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--tx-3);
  border: 1px solid var(--bd-1); border-radius: 3px; padding: 0 5px;
  line-height: 14px; background: var(--bg-1);
}

/* =========================================================================
   BUTTONS
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; font-family: var(--font-ui); font-weight: 500; font-size: 14px;
  border-radius: var(--r-btn); border: 1px solid transparent; cursor: pointer;
  transition: var(--t-fast); line-height: 1.1; white-space: nowrap;
  text-decoration: none;
}
.btn svg { width: 14px; height: 14px; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: .4; cursor: not-allowed; filter: none; transform: none; }
.btn-secondary { background: var(--bg-3); color: var(--tx-1); border-color: var(--bd-1); }
.btn-secondary:hover { background: color-mix(in oklab, var(--bg-3) 60%, var(--bd-1)); border-color: var(--bd-2); }
.btn-ghost { background: transparent; color: var(--tx-1); }
.btn-ghost:hover { background: var(--bg-3); }
.btn-outline { background: transparent; color: var(--tx-1); border-color: var(--bd-2); }
.btn-outline:hover { background: var(--bg-3); }
.btn-danger { background: #DC2626; color: #fff; }
.btn-danger:hover { background: #B91C1C; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* =========================================================================
   FORMS
   ========================================================================= */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--tx-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--tx-3); }
.field .err-msg { font-size: 12px; color: #DC2626; }
.input, .textarea, .select {
  width: 100%; padding: 10px 12px;
  background: var(--bg-2); color: var(--tx-1);
  border: 1px solid var(--bd-1); border-radius: var(--r-btn);
  font-family: var(--font-ui); font-size: 14px;
  transition: border var(--t-fast), background var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--tx-3); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--bd-2); }
.input:focus, .textarea:focus, .select:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent;
}
.input.err { border-color: #DC2626; }
.input[disabled] { opacity: .5; cursor: not-allowed; }
.checkbox {
  appearance: none; width: 16px; height: 16px; border: 1px solid var(--bd-2); border-radius: 3px;
  background: var(--bg-2); cursor: pointer; position: relative; transition: var(--t-fast); flex-shrink: 0;
}
.checkbox:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after {
  content: ''; position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'><path d='M3.5 8L7 11L12.5 5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-size: contain;
}
.check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--tx-1); cursor: pointer; }

/* Toggle-switch — для bool-настроек в админке */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider {
    position: absolute; inset: 0;
    background: var(--bg-3); border: 1px solid var(--bd-1); border-radius: 999px;
    transition: var(--t-fast); cursor: pointer;
}
.switch .slider::before {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--tx-2);
    transition: var(--t-fast);
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* =========================================================================
   CHIPS · TAGS · BADGES · AVATARS
   ========================================================================= */
.chip-rubric {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  line-height: 1.2;
  background: color-mix(in oklab, var(--c, var(--accent)) 14%, var(--bg-2));
  color: var(--c, var(--accent));
  border: 1px solid color-mix(in oklab, var(--c, var(--accent)) 30%, transparent);
}
.chip-rubric .sw { width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--accent)); }
.tag {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: var(--r-pill);
  border: 1px solid var(--bd-1); color: var(--tx-2);
  background: var(--bg-2); font-size: 13px;
  cursor: pointer; transition: var(--t-fast); text-decoration: none;
}
.tag:hover { color: var(--tx-1); border-color: var(--bd-2); }
.tag .hash { color: var(--tx-3); margin-right: 2px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600;
}
.badge.draft  { background: rgba(160,160,176,.12); color: var(--tx-2); }
.badge.review { background: rgba(245,158,11,.14); color: #F59E0B; }
.badge.live   { background: rgba(16,185,129,.14); color: #10B981; }
.badge.sched  { background: rgba(59,130,246,.14); color: #3B82F6; }
.av {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--bd-1);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--tx-2); flex-shrink: 0;
}
.av.lg { width: 56px; height: 56px; font-size: 20px; }
.av.sm { width: 22px; height: 22px; font-size: 10px; }
.av.tinted {
  background: color-mix(in oklab, var(--c, var(--accent)) 16%, var(--bg-3));
  color: color-mix(in oklab, var(--c, var(--accent)) 70%, var(--tx-1));
  border-color: color-mix(in oklab, var(--c, var(--accent)) 30%, var(--bd-1));
}

/* =========================================================================
   MAIN container
   ========================================================================= */
main { max-width: 1280px; margin: 0 auto; padding: 0 48px; }
.container { max-width: 1280px; margin: 0 auto; padding: 0 48px; }

/* =========================================================================
   HERO — poster variant (full-bleed)
   ========================================================================= */
.hero {
  display: block;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-top: 0;
  margin-bottom: 96px;
  min-height: calc(100vh - 136px);
  position: relative; overflow: hidden; isolation: isolate;
  border-bottom: 1px solid var(--bd-1);
  transition: opacity 220ms cubic-bezier(.16,1,.3,1);
}
.hero.rotating { opacity: 0; }
.hero .cover {
  position: absolute; inset: 0; z-index: 0;
  background:
    linear-gradient(180deg, transparent 30%, color-mix(in oklab, var(--bg-1) 88%, transparent) 80%, var(--bg-1) 100%),
    radial-gradient(70% 55% at 100% 0%, color-mix(in oklab, var(--accent) 38%, transparent), transparent 70%),
    repeating-linear-gradient(135deg, var(--cover-a) 0 28px, var(--cover-b) 28px 56px);
}
.hero .cover .tl {
  position: absolute; top: 28px; right: 32px;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11px; color: #fff;
  background: var(--accent); padding: 6px 12px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; z-index: 2;
}
.hero .cover .lab {
  position: absolute; right: 32px; bottom: 28px;
  font-family: var(--font-mono); font-size: 10px; color: var(--tx-3);
  text-transform: uppercase; letter-spacing: 0.12em; z-index: 2;
}
.hero .cover::after {
  content: attr(data-watermark);
  position: absolute; right: -2vw; top: 50%; transform: translateY(-50%);
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: clamp(140px, 24vw, 360px); line-height: 0.85;
  color: color-mix(in oklab, var(--accent) 14%, transparent);
  letter-spacing: -0.04em; pointer-events: none; z-index: 1;
  white-space: nowrap; user-select: none;
}
.hero .body {
  position: relative; z-index: 3;
  max-width: 1280px; margin: 0 auto;
  padding: 0 48px 72px;
  min-height: calc(100vh - 136px);
  display: flex; flex-direction: column;
  justify-content: flex-end;
  gap: 22px;
}
.hero .body-inner { max-width: 820px; display: flex; flex-direction: column; gap: 22px; }
.hero h1.title {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(44px, 6.2vw, 88px); line-height: 1.04; letter-spacing: -0.025em;
  margin: 0; color: var(--tx-1); text-wrap: balance;
}
.hero h1.title em { font-style: italic; color: var(--accent); font-weight: 400; }
.hero p.excerpt {
  font-family: var(--font-read); font-size: 20px; line-height: 1.6;
  color: var(--tx-2); margin: 0; max-width: 640px;
}
.hero .meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  color: var(--tx-3); font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.hero .author-row { display: flex; align-items: center; gap: 10px; color: var(--tx-2); font-size: 13px; }
.hero .author-row .av { width: 28px; height: 28px; font-size: 11px; }
.hero .cta-row { display: flex; gap: 12px; margin-top: 8px; align-items: center; }
.hero .scroll-cue {
  position: absolute; left: 50%; bottom: 24px; z-index: 3; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--tx-3); font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.18em;
  cursor: pointer; transition: color var(--t-fast);
  background: transparent; border: none;
}
.hero .scroll-cue:hover { color: var(--tx-2); }
.hero .scroll-cue .chev { width: 16px; height: 16px; opacity: .6; animation: bob 2.2s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); opacity: .6; } 50% { transform: translateY(4px); opacity: 1; } }

/* Hero auto-rotation progress segments */
.hero .hero-progress {
  position: absolute; top: 14px; left: 0; right: 0;
  display: flex; gap: 4px; padding: 0 32px; z-index: 5;
}
.hero .hero-progress .seg {
  flex: 1; height: 2px; border: none; padding: 0; cursor: pointer;
  background: color-mix(in oklab, var(--tx-1) 14%, transparent);
  position: relative; overflow: hidden; border-radius: 2px;
}
.hero .hero-progress .seg::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent);
}
.hero .hero-progress .seg.done::after { width: 100%; }
.hero .hero-progress .seg.active::after { animation: hero-fill 5s linear forwards; }
.hero.paused .hero-progress .seg.active::after { animation-play-state: paused; }
@keyframes hero-fill { from { width: 0; } to { width: 100%; } }

.hero .hero-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 4;
  width: 44px; height: 44px; border-radius: 50%;
  background: color-mix(in oklab, var(--bg-1) 70%, transparent);
  border: 1px solid var(--bd-1); color: var(--tx-2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0;
  transition: opacity var(--t-base), background var(--t-fast), color var(--t-fast), border var(--t-fast);
  backdrop-filter: blur(10px);
}
.hero .hero-nav svg { width: 18px; height: 18px; }
.hero .hero-nav.prev { left: 20px; }
.hero .hero-nav.next { right: 20px; }
.hero:hover .hero-nav { opacity: 1; }
.hero .hero-nav:hover { background: var(--bg-2); color: var(--tx-1); border-color: var(--bd-2); }

/* =========================================================================
   SECTION HEADER
   ========================================================================= */
.sec-head {
  display: flex; align-items: baseline; gap: 16px;
  border-top: 1px solid var(--bd-1);
  padding-top: 24px; margin: 64px 0 32px;
}
.sec-head .num { font-family: var(--font-mono); font-size: 11px; color: var(--tx-3); letter-spacing: 0.08em; }
.sec-head h2 {
  font-family: var(--font-display); font-weight: 500;
  font-size: 36px; margin: 0; letter-spacing: -0.015em; line-height: 1.1;
}
.sec-head h2 em { font-style: italic; color: var(--accent); }
.sec-head .desc { margin-left: auto; color: var(--tx-2); font-size: 13px; max-width: 360px; text-align: right; }
.sec-head .count { margin-left: auto; color: var(--tx-3); font-family: var(--font-mono); font-size: 12px; }

/* =========================================================================
   FEED + POST CARD
   ========================================================================= */
.feed {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px 28px;
  transition: opacity var(--t-base);
}
.feed.is-filtering { opacity: 0; }
.post-card {
  display: flex; flex-direction: column; gap: 14px;
  cursor: pointer; transition: var(--t-base);
  text-decoration: none; color: inherit;
}
.post-card .cover {
  aspect-ratio: 16/10; border-radius: var(--r-card);
  background:
    linear-gradient(135deg, color-mix(in oklab, var(--c, var(--accent)) 18%, transparent), transparent 60%),
    repeating-linear-gradient(135deg, var(--cover-a) 0 12px, var(--cover-b) 12px 24px);
  border: 1px solid var(--bd-1); position: relative; overflow: hidden;
  transition: var(--t-base);
}
.post-card .cover .ph {
  position: absolute; left: 12px; bottom: 12px;
  font-family: var(--font-mono); font-size: 9px; color: var(--tx-3);
  text-transform: uppercase; letter-spacing: 0.12em;
}
.post-card:hover .cover { border-color: color-mix(in oklab, var(--c, var(--accent)) 50%, var(--bd-2)); transform: translateY(-2px); }
.post-card .title {
  font-family: var(--font-display); font-weight: 500;
  font-size: 22px; line-height: 1.2; letter-spacing: -0.01em;
  color: var(--tx-1); margin: 0;
  transition: color var(--t-fast);
}
.post-card:hover .title { color: var(--c, var(--accent)); }
.post-card .excerpt {
  margin: 0; color: var(--tx-2); font-size: 14px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card .meta {
  display: flex; align-items: center; gap: 10px;
  color: var(--tx-3); font-size: 12px;
  border-top: 1px solid var(--bd-1); padding-top: 12px; margin-top: auto;
}
.post-card .meta .au { display: flex; align-items: center; gap: 8px; color: var(--tx-2); }
.post-card .meta .au .av { width: 22px; height: 22px; font-size: 10px; }
.post-card .meta .sep { color: var(--tx-3); }
.post-card .meta .ts { font-family: var(--font-mono); font-size: 11px; }

/* =========================================================================
   READING PROGRESS (article page)
   ========================================================================= */
.reading-bar {
  position: sticky; top: 40px; z-index: 49;
  height: 2px; background: transparent; pointer-events: none;
}
.reading-bar .fill { height: 100%; background: var(--accent); width: 0; transition: width 60ms linear; }

/* =========================================================================
   ARTICLE BODY
   ========================================================================= */
.article-hero {
  width: 100vw; margin-left: calc(50% - 50vw);
  aspect-ratio: 21/9; min-height: 460px;
  position: relative; overflow: hidden;
  background:
    linear-gradient(180deg, transparent 40%, color-mix(in oklab, var(--bg-1) 70%, transparent) 90%, var(--bg-1) 100%),
    radial-gradient(60% 50% at 100% 0%, color-mix(in oklab, var(--accent) 30%, transparent), transparent 70%),
    repeating-linear-gradient(135deg, var(--cover-a) 0 28px, var(--cover-b) 28px 56px);
  border-bottom: 1px solid var(--bd-1);
}
.article-hero::after {
  content: attr(data-watermark);
  position: absolute; right: -2vw; top: 50%; transform: translateY(-50%);
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: clamp(120px, 22vw, 300px); line-height: 0.85;
  color: color-mix(in oklab, var(--accent) 12%, transparent);
  letter-spacing: -0.04em; pointer-events: none;
  white-space: nowrap; user-select: none;
}
.article-hero .corner-tl {
  position: absolute; top: 24px; right: 32px;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; color: #fff;
  background: var(--accent); padding: 5px 12px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600;
}
.article-hero .corner-bl {
  position: absolute; left: 32px; bottom: 24px;
  font-family: var(--font-mono); font-size: 10px; color: var(--tx-3);
  text-transform: uppercase; letter-spacing: 0.12em;
  background: color-mix(in oklab, var(--bg-1) 70%, transparent);
  padding: 5px 10px; border-radius: 6px; backdrop-filter: blur(8px);
}
.article-title-block { max-width: 920px; margin: 56px auto 32px; padding: 0 48px; }
.article-title-block .crumbs {
  display: flex; gap: 8px; align-items: center;
  color: var(--tx-3); font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 16px;
}
.article-title-block h1 {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(36px, 4.8vw, 56px); line-height: 1.08; letter-spacing: -0.02em;
  margin: 12px 0 16px;
}
.article-title-block h1 em { font-style: italic; color: var(--accent); font-weight: 400; }
.article-title-block .lede {
  font-family: var(--font-read); font-style: italic;
  font-size: 19px; line-height: 1.6; color: var(--tx-2); margin: 0 0 24px;
  max-width: 720px;
}
.article-title-block .metabar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding-top: 24px; border-top: 1px solid var(--bd-1);
}
.article-title-block .metabar .author { display: flex; align-items: center; gap: 10px; }
.article-title-block .metabar .actions { margin-left: auto; display: flex; gap: 6px; }

.article-body {
  max-width: 720px; margin: 0 auto; padding: 0 24px 64px;
  font-family: var(--font-read); font-size: 19px; line-height: 1.7; color: var(--tx-1);
}
.article-body p { margin: 0 0 24px; }
.article-body p strong { font-weight: 600; }
.article-body a {
  color: var(--tx-1); text-decoration: underline;
  text-decoration-color: var(--accent); text-underline-offset: 3px;
}
.article-body h2, .article-body h3 {
  font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em;
  margin: 40px 0 16px;
}
.article-body h2 { font-size: 32px; line-height: 1.2; }
.article-body h3 { font-size: 22px; line-height: 1.3; }
.article-body blockquote {
  margin: 32px 0; padding: 4px 0 4px 24px;
  border-left: 2px solid var(--accent);
  font-family: var(--font-display); font-style: italic;
  font-size: 24px; line-height: 1.45; color: var(--tx-1);
}
.article-body ul, .article-body ol { padding-left: 24px; margin: 0 0 24px; }
.article-body li { margin: 8px 0; }
.article-body ul li::marker { color: var(--accent); }
.article-body code { font-family: var(--font-mono); font-size: 0.86em; background: var(--code-bg); border: 1px solid var(--bd-1); padding: 1px 6px; border-radius: 4px; }
.article-body pre {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
  background: var(--code-bg); border: 1px solid var(--bd-1); border-radius: var(--r-btn);
  padding: 18px; overflow-x: auto; margin: 0 0 24px;
}
.article-body figure { margin: 32px 0; }
.article-body figure img { width: 100%; border-radius: var(--r-card); }
.article-body figure.wide { width: calc(100% + 80px); margin-left: -40px; }
.article-body figure.full { width: 100vw; margin-left: calc(50% - 50vw); }
.article-body figcaption {
  font-family: var(--font-ui); font-size: 13px; font-style: italic;
  color: var(--tx-3); margin-top: 8px; text-align: center;
}
.article-body table {
  width: 100%; border-collapse: collapse; margin: 0 0 24px;
  font-family: var(--font-ui); font-size: 15px;
}
.article-body table th, .article-body table td {
  text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--bd-1);
}
.article-body table tr:hover td { background: var(--bg-2); }
.article-body hr {
  border: none; height: 1px; background: var(--bd-1); margin: 40px auto;
  width: 60%; position: relative;
}
.article-body hr::after {
  content: '· · ·'; display: block; text-align: center; position: relative;
  top: -10px; color: var(--tx-3); background: var(--bg-1); width: 60px; margin: 0 auto;
  font-family: var(--font-mono); letter-spacing: 0.4em;
}

/* =========================================================================
   FOOTER
   ========================================================================= */
.app-footer {
  border-top: 1px solid var(--bd-1);
  padding: 64px 48px 32px;
  margin-top: 96px;
  background: var(--bg-1);
}
.app-footer .cols {
  display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 48px;
  max-width: 1280px; margin: 0 auto;
}
.app-footer .col h4 {
  font-family: var(--font-mono); font-size: 11px; color: var(--tx-3);
  text-transform: uppercase; letter-spacing: 0.1em; margin: 0 0 16px; font-weight: 600;
}
.app-footer .col p { color: var(--tx-2); font-size: 14px; line-height: 1.6; margin: 0; }
.app-footer .col ul { list-style: none; padding: 0; margin: 0; }
.app-footer .col li { margin: 8px 0; }
.app-footer .col a { color: var(--tx-2); text-decoration: none; transition: var(--t-fast); font-size: 14px; }
.app-footer .col a:hover { color: var(--tx-1); }
.app-footer .copy {
  max-width: 1280px; margin: 48px auto 0;
  padding-top: 24px; border-top: 1px solid var(--bd-1);
  display: flex; justify-content: space-between;
  color: var(--tx-3); font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em;
}

/* =========================================================================
   CHAT FAB + DRAWER
   ========================================================================= */
.chat-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 10px 12px; border-radius: var(--r-pill);
  background: var(--bg-2); border: 1px solid var(--bd-2); box-shadow: var(--shadow-elev);
  font-family: var(--font-ui); font-size: 13px; color: var(--tx-1); cursor: pointer;
}
.chat-fab .online { width: 8px; height: 8px; border-radius: 50%; background: #10B981; box-shadow: 0 0 8px #10B981; animation: pulse 2s ease-in-out infinite; }
.chat-fab .cnt { color: var(--tx-3); font-family: var(--font-mono); font-size: 11px; }
@keyframes pulse { 50% { opacity: .45; } }

.chat-drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 360px; z-index: 70;
  background: var(--bg-2); border-left: 1px solid var(--bd-1);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-slow);
}
.chat-drawer.open { transform: translateX(0); }
.chat-drawer .dh { padding: 16px; border-bottom: 1px solid var(--bd-1); display: flex; align-items: center; gap: 10px; }
.chat-drawer .dh .nm { font-weight: 600; font-size: 14px; }
.chat-drawer .dh .cnt { color: var(--tx-3); font-family: var(--font-mono); font-size: 11px; }
.chat-drawer .dh .x { margin-left: auto; }
.chat-drawer .msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; }
.msg .body { display: flex; flex-direction: column; gap: 2px; max-width: 240px; }
.msg .meta { font-size: 11px; color: var(--tx-3); display: flex; gap: 6px; }
.msg .meta .nm { color: var(--tx-1); font-weight: 600; }
.msg .txt { font-size: 13px; color: var(--tx-1); line-height: 1.5; }
.msg.mine { justify-content: flex-end; }
.msg.mine .body { align-items: flex-end; }
.msg.mine .txt {
  background: color-mix(in oklab, var(--accent) 16%, var(--bg-3));
  padding: 8px 12px; border-radius: 12px 12px 4px 12px;
}
.chat-drawer .di { border-top: 1px solid var(--bd-1); padding: 12px; display: flex; gap: 8px; align-items: center; }
.chat-drawer .di input {
  flex: 1; background: var(--bg-3); border: 1px solid var(--bd-1); border-radius: var(--r-pill);
  padding: 8px 12px; color: var(--tx-1); font-size: 13px;
}
.chat-drawer .di input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.chat-drawer .di .send {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.chat-drawer .di .send svg { width: 14px; height: 14px; }

/* =========================================================================
   POPOVERS — Projects + Support
   ========================================================================= */
.popover-wrap { position: relative; display: inline-block; }
.btn-pill {
  border-radius: var(--r-pill); height: 26px;
  padding: 4px 12px; font-size: 12px; gap: 6px;
  display: inline-flex; align-items: center; cursor: pointer;
  font-family: var(--font-ui); font-weight: 500;
  border: 1px solid transparent; transition: var(--t-fast);
  text-decoration: none;
}
.btn-pill svg { width: 12px; height: 12px; }
.btn-pill.support { background: var(--accent); color: #fff; border-color: transparent; }
.btn-pill.support:hover { filter: brightness(1.08); }
.btn-pill.projects { background: transparent; color: var(--tx-1); border-color: var(--bd-2); }
.btn-pill.projects:hover { background: var(--bg-3); }

.popover {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 360px; z-index: 90;
  background: var(--bg-2); border: 1px solid var(--bd-2);
  border-radius: var(--r-card); box-shadow: var(--shadow-elev);
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
  overflow: hidden;
}
.popover.open { opacity: 1; transform: translateY(0); pointer-events: all; }
.popover .head { padding: 16px 18px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--bd-1); }
.popover .head h6 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 18px; letter-spacing: -0.01em; }
.popover .head h6 em { font-style: italic; color: var(--accent); }
.popover .head .x { margin-left: auto; }
.popover section { padding: 14px 12px; }
.popover section + section { border-top: 1px solid var(--bd-1); }
.popover section > label {
  display: block; padding: 0 6px 8px;
  font-family: var(--font-mono); font-size: 10px; color: var(--tx-3);
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600;
}
.popover .foot {
  padding: 12px 18px; border-top: 1px solid var(--bd-1);
  display: flex; align-items: center; gap: 10px;
  color: var(--tx-3); font-size: 11px; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.popover .foot .live { width: 6px; height: 6px; border-radius: 50%; background: var(--acc-finance); box-shadow: 0 0 6px var(--acc-finance); }

.social-row, .donate-row, .project-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: var(--r-btn);
  text-decoration: none; color: var(--tx-1); cursor: pointer;
  transition: var(--t-fast);
}
.social-row:hover, .donate-row:hover, .project-row:hover { background: var(--bg-3); }
.social-row .ico, .donate-row .glyph, .project-row .glyph {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-3); border: 1px solid var(--bd-1); color: var(--tx-1);
}
.social-row:hover .ico, .donate-row:hover .glyph, .project-row:hover .glyph {
  background: color-mix(in oklab, var(--accent) 14%, var(--bg-3));
  border-color: color-mix(in oklab, var(--accent) 30%, var(--bd-1));
  color: var(--accent);
}
.social-row .info, .donate-row .info, .project-row .info { flex: 1; min-width: 0; }
.social-row .name, .donate-row .name, .project-row .name { font-size: 14px; font-weight: 500; line-height: 1.2; }
.social-row .handle { font-family: var(--font-mono); font-size: 11px; color: var(--tx-3); }
.donate-row .hint, .project-row .hint { font-size: 12px; color: var(--tx-3); }
.social-row .count {
  font-family: var(--font-mono); font-size: 12px; color: var(--tx-2);
  padding: 3px 8px; background: var(--bg-3); border-radius: 4px;
}
.social-row .arrow, .donate-row .arrow, .project-row .arrow {
  width: 14px; height: 14px; color: var(--tx-3); transition: var(--t-fast);
}
.social-row:hover .arrow, .donate-row:hover .arrow, .project-row:hover .arrow {
  color: var(--accent); transform: translate(2px, -2px);
}

/* =========================================================================
   AUTH (login/register) — two-column
   ========================================================================= */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-visual {
  background:
    radial-gradient(50% 40% at 20% 30%, color-mix(in oklab, var(--accent) 24%, transparent), transparent 70%),
    repeating-linear-gradient(135deg, var(--cover-a) 0 22px, var(--cover-b) 22px 44px);
  border-right: 1px solid var(--bd-1);
  padding: 80px 64px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-visual .quote {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: clamp(36px, 4vw, 56px); line-height: 1.1; letter-spacing: -0.02em;
  color: var(--tx-1); max-width: 480px;
}
.auth-visual .quote em { color: var(--accent); }
.auth-form { padding: 80px 64px; display: flex; flex-direction: column; gap: 24px; align-items: stretch; justify-content: center; max-width: 480px; }
.auth-form h1 { font-family: var(--font-display); font-weight: 500; font-size: 36px; margin: 0; letter-spacing: -0.015em; }
.auth-form .sub { color: var(--tx-2); font-size: 15px; margin: 0; }
.auth-form .switch-link { color: var(--tx-3); font-size: 13px; }
.auth-form .switch-link a { color: var(--tx-1); }

/* =========================================================================
   ADMIN layout
   ========================================================================= */
.admin-shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
.admin-side {
  background: var(--bg-2); border-right: 1px solid var(--bd-1);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-side .logo { padding: 0 8px 16px; }
.admin-side .group { font-family: var(--font-mono); font-size: 10px; color: var(--tx-3); text-transform: uppercase; letter-spacing: 0.1em; padding: 16px 8px 4px; font-weight: 600; }
.admin-side a {
  padding: 7px 10px; border-radius: var(--r-btn);
  color: var(--tx-2); text-decoration: none; font-size: 13px;
  display: flex; align-items: center; gap: 10px; transition: var(--t-fast);
}
.admin-side a:hover { background: var(--bg-3); color: var(--tx-1); }
.admin-side a.active {
  background: color-mix(in oklab, var(--accent) 14%, var(--bg-3));
  color: var(--accent);
}
.admin-side a svg { width: 14px; height: 14px; }
.admin-main { display: flex; flex-direction: column; }
.admin-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 32px; border-bottom: 1px solid var(--bd-1);
  background: var(--bg-1);
}
.admin-topbar .crumbs { color: var(--tx-2); font-size: 13px; }
.admin-topbar .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.admin-content { padding: 32px; flex: 1; }
.admin-content h1 { font-family: var(--font-display); font-weight: 500; font-size: 32px; margin: 0 0 24px; letter-spacing: -0.015em; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--bg-2); border: 1px solid var(--bd-1); border-radius: var(--r-card);
  padding: 20px; display: flex; flex-direction: column; gap: 6px;
}
.stat-card .lab { font-family: var(--font-mono); font-size: 10px; color: var(--tx-3); text-transform: uppercase; letter-spacing: 0.1em; }
.stat-card .val { font-family: var(--font-display); font-size: 32px; font-weight: 500; }
.stat-card .delta { font-family: var(--font-mono); font-size: 11px; color: var(--acc-finance); }
.stat-card .delta.neg { color: #DC2626; }

/* =========================================================================
   INSTALLER
   ========================================================================= */
.installer-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 48px 24px;
}
.installer-card {
  width: 100%; max-width: 640px;
  background: var(--bg-2); border: 1px solid var(--bd-1); border-radius: var(--r-modal);
  box-shadow: var(--shadow-elev); padding: 48px;
}
.installer-card .logo { font-size: 28px; display: block; margin-bottom: 8px; }
.installer-card .step-meta { font-family: var(--font-mono); font-size: 11px; color: var(--tx-3); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 24px; }
.installer-steps { display: flex; gap: 8px; margin-bottom: 32px; }
.installer-steps .seg { flex: 1; height: 3px; background: var(--bg-3); border-radius: 2px; }
.installer-steps .seg.done { background: var(--accent); }
.installer-steps .seg.active { background: color-mix(in oklab, var(--accent) 50%, var(--bg-3)); }
.installer-card h1 { font-family: var(--font-display); font-weight: 500; font-size: 36px; margin: 0 0 8px; letter-spacing: -0.015em; }
.installer-card .sub { color: var(--tx-2); font-size: 15px; margin: 0 0 32px; }
.installer-actions { display: flex; gap: 12px; margin-top: 32px; }

/* =========================================================================
   ERROR PAGES
   ========================================================================= */
.error-page {
  min-height: 80vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 48px;
  text-align: center;
}
.error-page .code {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: clamp(140px, 22vw, 280px); line-height: 0.85; letter-spacing: -0.04em;
  color: var(--accent);
}
.error-page h1 { font-family: var(--font-display); font-weight: 500; font-size: 32px; margin: 0; }
.error-page p { color: var(--tx-2); margin: 0 0 16px; }

/* =========================================================================
   EMPTY STATES + PANELS
   ========================================================================= */
.empty {
  text-align: center; padding: 40px 24px; background: var(--bg-2); border: 1px dashed var(--bd-2);
  border-radius: var(--r-card);
}
.empty h4 { margin: 0 0 6px; font-size: 16px; }
.empty p { margin: 0 0 16px; color: var(--tx-2); font-size: 14px; }
.panel { background: var(--bg-2); border: 1px solid var(--bd-1); border-radius: var(--r-card); padding: 24px; }

/* =========================================================================
   UTILS
   ========================================================================= */
.text-mono { font-family: var(--font-mono); }
.text-display { font-family: var(--font-display); }
.text-read { font-family: var(--font-read); }
.text-2 { color: var(--tx-2); }
.text-3 { color: var(--tx-3); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.uppercase { text-transform: uppercase; letter-spacing: 0.06em; }
.small { font-size: 12px; }
.t-caption {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--tx-3);
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.divider-hr { border: none; border-top: 1px solid var(--bd-1); margin: 0; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 900px) {
  .section-bar { padding: 0 16px; gap: 12px; }
  .app-header { padding: 14px 16px; gap: 16px; flex-wrap: wrap; }
  .app-header nav { gap: 14px; font-size: 13px; }
  main, .container { padding: 0 16px; }
  .hero { min-height: 80vh; }
  .hero .body { padding: 0 16px 48px; min-height: 80vh; }
  .feed { grid-template-columns: 1fr; gap: 24px; }
  .article-title-block, .article-body { padding-left: 16px; padding-right: 16px; }
  .article-hero { min-height: 280px; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { position: static; height: auto; }
  .app-footer .cols { grid-template-columns: 1fr 1fr; gap: 32px; }
  .chat-drawer { width: 100%; }
}
