/* =========================================================
   GGCBG – Bible Study Hub · design system
   ========================================================= */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --surface-3: #f1eee7;
  --ink: #1c1a2b;
  --ink-2: #4f4c63;
  --muted: #858296;
  --line: #e7e2d8;
  --line-2: #d9d3c6;
  --brand: #4b45c6;
  --brand-ink: #ffffff;
  --brand-2: #3a35a8;
  --brand-soft: #ecebfc;
  --gold: #b9802a;
  --gold-soft: #f8eedb;
  --good: #1d8a4e;
  --good-soft: #e3f4ea;
  --warn: #a8670a;
  --warn-soft: #fbf0dc;
  --bad: #c43636;
  --bad-soft: #fbe7e7;
  --tg: #2aabee;
  --tg-bubble: #effdde;
  --tg-chat: #c8d9b4;
  --shadow-sm: 0 1px 2px rgba(28, 26, 43, .06);
  --shadow: 0 1px 2px rgba(28, 26, 43, .05), 0 8px 24px -12px rgba(28, 26, 43, .14);
  --shadow-lg: 0 24px 60px -20px rgba(28, 26, 43, .35);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sidebar: 264px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111019;
  --surface: #1a1925;
  --surface-2: #201f2d;
  --surface-3: #272636;
  --ink: #edecf6;
  --ink-2: #b7b5ca;
  --muted: #858399;
  --line: #2c2a3c;
  --line-2: #3a384d;
  --brand: #8a85ff;
  --brand-ink: #14132a;
  --brand-2: #a6a2ff;
  --brand-soft: #27254d;
  --gold: #e2b563;
  --gold-soft: #3a2f1c;
  --good: #4cc483;
  --good-soft: #17322a;
  --warn: #e6a94a;
  --warn-soft: #3a2d17;
  --bad: #f07474;
  --bad-soft: #3d1f24;
  --tg-bubble: #2b5278;
  --tg-chat: #0e1621;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
.display { font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
code { font: .88em ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-3); padding: .1em .4em; border-radius: 6px; }
::selection { background: var(--brand-soft); }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- buttons ---------- */
.btn {
  --b: var(--surface); --c: var(--ink); --bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px;
  background: var(--b); color: var(--c); border: 1px solid var(--bd);
  font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  text-decoration: none !important;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { --b: var(--brand); --c: var(--brand-ink); --bd: var(--brand); box-shadow: 0 6px 16px -8px var(--brand); }
.btn-primary:hover { --b: var(--brand-2); border-color: var(--brand-2); }
.btn-tg { --b: var(--tg); --c: #fff; --bd: var(--tg); box-shadow: 0 6px 16px -8px var(--tg); }
.btn-tg:hover { filter: brightness(1.05); border-color: var(--tg); }
.btn-ghost { --b: transparent; --bd: transparent; --c: var(--ink-2); }
.btn-ghost:hover { --b: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn-danger { --c: var(--bad); }
.btn-danger:hover { --b: var(--bad-soft); border-color: var(--bad); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; gap: 6px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  border-radius: 11px; padding: 10px 12px; font: 15px/1.4 var(--font);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.input-lg { font-size: 20px; padding: 12px 14px; font-family: var(--font-display); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 40px; height: 24px; border-radius: 99px; background: var(--line-2); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent); }

.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px dashed var(--line-2); border-radius: 14px; padding: 18px; text-align: center; color: var(--muted);
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; min-height: 120px; overflow: hidden;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dropzone.has-image { border-style: solid; }
.dropzone .remove { position: absolute; top: 8px; right: 8px; z-index: 2; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-gold { background: var(--gold-soft); color: var(--gold); }
.badge-tg { background: color-mix(in srgb, var(--tg) 14%, transparent); color: var(--tg); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; margin: 0 auto 10px; color: var(--line-2); }
.empty h3 { color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .actions { text-align: right; white-space: nowrap; }
.t-title { font-weight: 600; color: var(--ink); }
.thumb { width: 52px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface-3); flex: none; }
.thumb-ph { display: grid; place-items: center; color: var(--muted); }

/* =========================================================
   Admin shell
   ========================================================= */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 18px; color: var(--ink); text-decoration: none !important; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--brand), #7c4dce 60%, var(--gold)); color: #fff; box-shadow: 0 8px 18px -8px var(--brand);
}
.brand-mark .icon { width: 22px; height: 22px; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1.15; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
  color: var(--ink-2); font-weight: 500; text-decoration: none; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-3); color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav a .count { margin-left: auto; font-size: 12px; background: var(--surface-3); color: var(--ink-2); padding: 1px 8px; border-radius: 99px; font-weight: 600; }
.nav a.active .count { background: var(--brand); color: var(--brand-ink); }
.sidebar-foot { margin-top: auto; }
.bot-card { padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
.bot-card .row { gap: 10px; flex-wrap: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.dot.off { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 14px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar h1 { font-size: 22px; font-family: var(--font-display); font-weight: 600; }
.topbar .crumb { font-size: 12.5px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--gold-soft), var(--brand-soft)); color: var(--brand); font-weight: 700; font-size: 13px;
}
.content { padding: 8px 32px 48px; max-width: 1320px; width: 100%; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* user menu */
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; z-index: 50;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px;
  opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity .15s, transform .15s;
}
.menu.open .menu-pop { opacity: 1; transform: none; pointer-events: auto; }
.menu-pop a, .menu-pop button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 9px; color: var(--ink-2); background: none; border: 0; font: 500 14px var(--font); cursor: pointer; text-decoration: none; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-3); color: var(--ink); }
.menu-pop .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }

/* mobile bottom nav */
.tabbar { display: none; }
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 19px; }
  .content { padding: 4px 16px 110px; }
  .tabbar {
    display: flex; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  }
  .tabbar a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border-radius: 10px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
  .tabbar a.active { color: var(--brand); }
  .tabbar a.active .icon { stroke-width: 2.2; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 961px) { .show-mobile { display: none !important; } }

/* ---------- dashboard ---------- */
.grid { display: grid; gap: 20px; }
.grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-dash { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-dash { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } .grid { gap: 14px; } }

.stat { padding: 18px 18px 16px; position: relative; overflow: hidden; }
.stat .stat-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 14px; }
.stat.gold .stat-icon { background: var(--gold-soft); color: var(--gold); }
.stat.good .stat-icon { background: var(--good-soft); color: var(--good); }
.stat.tg .stat-icon { background: color-mix(in srgb, var(--tg) 14%, transparent); color: var(--tg); }
.stat .stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .stat-label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.stat .stat-trend { position: absolute; top: 18px; right: 18px; font-size: 12px; font-weight: 600; color: var(--muted); }

.hero-card {
  position: relative; overflow: hidden; border-radius: 22px; padding: 26px; color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(233, 183, 94, .55), transparent 55%),
    radial-gradient(90% 120% at 0% 100%, rgba(124, 77, 206, .7), transparent 60%),
    linear-gradient(135deg, #2e2a8a, #4b45c6);
  box-shadow: 0 20px 40px -24px #2e2a8a;
}
.hero-card::after {
  content: ""; position: absolute; right: -40px; bottom: -60px; width: 260px; height: 260px; opacity: .12;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.2'%3E%3Cpath d='M2 6s1.5-2 5-2 5 2 5 2v14s-1.5-1-5-1-5 1-5 1V6zM12 6s1.5-2 5-2 5 2 5 2v14s-1.5-1-5-1-5 1-5 1V6z'/%3E%3C/svg%3E") no-repeat center / contain;
}
.hero-card .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
.hero-card h2 { font-family: var(--font-display); font-size: 28px; font-weight: 600; margin: 8px 0 12px; max-width: 30ch; }
.hero-card .meta { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; opacity: .92; }
.hero-card .meta span { display: inline-flex; gap: 7px; align-items: center; }
.hero-card .btn { --b: rgba(255, 255, 255, .14); --c: #fff; --bd: rgba(255, 255, 255, .25); backdrop-filter: blur(6px); }
.hero-card .btn:hover { --b: rgba(255, 255, 255, .24); border-color: rgba(255, 255, 255, .45); }
.hero-card .btn-light { --b: #fff; --c: #2e2a8a; --bd: #fff; }
.hero-card .btn-light:hover { --b: #f3f1ff; }
.countdown { display: flex; gap: 10px; margin: 20px 0; position: relative; z-index: 1; }
.countdown div { min-width: 64px; padding: 10px 8px; border-radius: 12px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); text-align: center; }
.countdown b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.countdown small { font-size: 11px; opacity: .8; text-transform: uppercase; letter-spacing: .08em; }
.rsvp-bar { display: flex; gap: 16px; font-size: 13px; position: relative; z-index: 1; }

.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; gap: 14px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.date-chip { width: 48px; flex: none; text-align: center; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.date-chip .m { display: block; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: var(--chip, var(--brand)); padding: 2px 0; }
.date-chip .d { display: block; font-size: 18px; font-weight: 700; padding: 3px 0 4px; }
.activity-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--ink-2); }
.activity-icon.k-announcement, .activity-icon.k-forward { background: color-mix(in srgb, var(--tg) 14%, transparent); color: var(--tg); }
.activity-icon.k-event { background: var(--brand-soft); color: var(--brand); }
.activity-icon.k-reminder { background: var(--warn-soft); color: var(--warn); }
.activity-icon.k-post { background: var(--gold-soft); color: var(--gold); }
.activity-icon.k-test, .activity-icon.k-welcome { background: var(--good-soft); color: var(--good); }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* charts */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--brand); transition: opacity .15s; }
.chart .bar.gold { fill: var(--gold); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g:hover .bar { opacity: .8; }
.chart .value-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, calc(-100% - 10px));
  background: var(--ink); color: var(--bg); padding: 7px 10px; border-radius: 9px; font-size: 12px; white-space: nowrap;
  box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .12s;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { font-size: 14px; display: block; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: none; font: 600 12.5px var(--font); color: var(--muted); padding: 5px 10px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Telegram preview ---------- */
.tg-preview { border-radius: 16px; padding: 18px 14px; min-height: 180px; display: flex; flex-direction: column; justify-content: flex-end;
  background-color: var(--tg-chat);
  background-image: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .25) 0 2px, transparent 3px), radial-gradient(circle at 70% 60%, rgba(255, 255, 255, .2) 0 2px, transparent 3px);
  background-size: 46px 46px, 64px 64px;
}
.tg-head { display: flex; align-items: center; gap: 10px; margin: -6px -2px 14px; color: #fff; font-size: 13px; text-shadow: 0 1px 2px rgba(0,0,0,.2); }
.tg-head .avatar { width: 30px; height: 30px; font-size: 11px; background: #fff; color: var(--tg); }
.tg-bubble {
  align-self: flex-start; max-width: 92%; background: var(--surface); color: var(--ink); border-radius: 14px 14px 14px 4px;
  font-size: 14.5px; line-height: 1.45; box-shadow: 0 1px 1px rgba(0,0,0,.12); overflow: hidden; word-wrap: break-word;
}
:root[data-theme="dark"] .tg-bubble { background: #182533; color: #f5f5f5; }
.tg-bubble .tg-text { padding: 8px 12px 6px; white-space: pre-wrap; }
.tg-bubble .tg-text a { color: var(--tg); }
.tg-bubble .tg-text blockquote { margin: 2px 0; padding: 2px 8px; border-left: 3px solid var(--tg); background: color-mix(in srgb, var(--tg) 10%, transparent); border-radius: 4px; white-space: pre-wrap; }
.tg-bubble .tg-text .spoiler { background: var(--line-2); color: transparent; border-radius: 4px; }
.tg-bubble .tg-meta { display: flex; justify-content: flex-end; gap: 4px; font-size: 11px; color: var(--muted); padding: 0 10px 6px; }
.tg-bubble img { width: 100%; max-height: 260px; object-fit: cover; }
.tg-buttons { display: grid; grid-auto-flow: column; gap: 4px; margin-top: 4px; max-width: 92%; }
.tg-buttons span { background: rgba(0, 0, 0, .18); color: #fff; font-size: 13px; font-weight: 600; text-align: center; padding: 8px; border-radius: 10px; }

.composer-tools { display: flex; gap: 2px; padding: 6px; border: 1px solid var(--line-2); border-bottom: 0; border-radius: 11px 11px 0 0; background: var(--surface-2); flex-wrap: wrap; }
.composer-tools button { width: 32px; height: 30px; border: 0; background: none; border-radius: 7px; color: var(--ink-2); cursor: pointer; font: 700 13px var(--font); display: grid; place-items: center; }
.composer-tools button:hover { background: var(--surface-3); color: var(--ink); }
.composer-tools + .textarea { border-radius: 0 0 11px 11px; }
.counter { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--bad); font-weight: 600; }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; }
.cal-head h3 { font-family: var(--font-display); font-size: 20px; font-weight: 600; min-width: 170px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .dow { padding: 8px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cal .day { min-height: 108px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; position: relative; transition: background .12s; }
.cal .day.out { background: var(--surface-2); }
.cal .day.out .num { color: var(--line-2); }
.cal .day.clickable { cursor: pointer; }
.cal .day.clickable:hover { background: var(--brand-soft); }
.cal .num { font-size: 12.5px; font-weight: 600; color: var(--ink-2); width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal .today .num { background: var(--brand); color: var(--brand-ink); }
.cal .ev { display: block; font-size: 12px; line-height: 1.25; padding: 4px 6px; border-radius: 6px; color: var(--ink); text-decoration: none !important;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-left: 3px solid var(--c); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal .ev:hover { background: color-mix(in srgb, var(--c) 24%, var(--surface)); }
.cal .ev b { font-weight: 700; }
.cal .more { font-size: 11px; color: var(--muted); padding-left: 4px; }
.cal-mini .day { min-height: 0; aspect-ratio: 1; align-items: center; justify-content: center; padding: 2px; }
.cal-mini .dow { padding: 6px 0; text-align: center; font-size: 10px; }
.cal-mini .ev-dots { display: flex; gap: 2px; height: 5px; }
.cal-mini .ev-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c); }
.cal-mini { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.cal-mini, .cal-mini .dow, .cal-mini .day { border-top: 0; border-left: 0; }
.cal-mini .day:nth-child(7n), .cal-mini .dow:nth-child(7n) { border-right: 0; }
@media (max-width: 720px) {
  .cal:not(.cal-mini) .day { min-height: 64px; padding: 3px; }
  .cal:not(.cal-mini) .ev { font-size: 0; padding: 0; height: 6px; border: 0; background: var(--c); border-radius: 3px; }
  .cal .dow { padding: 6px 2px; text-align: center; font-size: 10px; }
}
.color-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.color-pick label { position: relative; cursor: pointer; }
.color-pick input { position: absolute; opacity: 0; }
.color-pick span { display: block; width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); transition: box-shadow .15s; }
.color-pick input:checked + span { box-shadow: 0 0 0 2px var(--c); }
.color-pick input:focus-visible + span { box-shadow: 0 0 0 3px var(--c); }

/* ---------- tabs & misc ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--brand); border-color: var(--brand); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 600; text-decoration: none !important; }
.pill:hover { border-color: var(--muted); color: var(--ink); }
.pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill .n { opacity: .6; font-weight: 500; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 18px 44px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13px; }
.steps li.done::before { content: "✓"; background: var(--good-soft); color: var(--good); }
.steps li::after { content: ""; position: absolute; left: 13.5px; top: 30px; bottom: 4px; width: 1px; background: var(--line); }
.steps li:last-child::after { display: none; }
.kbd-box { font: 13px ui-monospace, Consolas, monospace; background: var(--surface-3); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; white-space: pre; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--brand-soft); color: var(--ink); font-size: 14px; }
.callout .icon { color: var(--brand); margin-top: 2px; }
.callout.warn { background: var(--warn-soft); }
.callout.warn .icon { color: var(--warn); }
.callout.good { background: var(--good-soft); }
.callout.good .icon { color: var(--good); }
.callout p:last-child { margin: 0; }

/* toasts */
.toasts { position: fixed; z-index: 100; top: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 13px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 14px; pointer-events: auto; animation: toast-in .25s ease; }
.toast .icon { margin-top: 1px; }
.toast.success .icon { color: #5fd895; }
.toast.error .icon { color: #ff8a8a; }
.toast.hide { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 90; background: rgba(15, 14, 26, .45); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: min(420px, 100%); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px; animation: pop .18s ease; }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal p { color: var(--ink-2); font-size: 14px; }
.modal .row { justify-content: flex-end; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(100% 80% at 100% 0%, rgba(233, 183, 94, .55), transparent 55%),
    radial-gradient(80% 90% at 0% 100%, rgba(124, 77, 206, .75), transparent 60%),
    linear-gradient(160deg, #23206e, #4b45c6);
}
.auth-art blockquote { font-family: var(--font-display); font-size: clamp(24px, 3vw, 36px); line-height: 1.25; margin: 0; max-width: 18em; }
.auth-art cite { display: block; margin-top: 14px; font-style: normal; opacity: .8; font-size: 15px; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-form .box { width: min(380px, 100%); }
.auth-form h1 { font-family: var(--font-display); font-size: 30px; font-weight: 600; margin: 18px 0 6px; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-art { display: none; } }

/* =========================================================
   Public site
   ========================================================= */
.site-nav { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.site-nav .inner { display: flex; align-items: center; gap: 18px; height: 66px; }
.site-nav .brand { padding: 0; }
.site-nav nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav nav a { padding: 8px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; text-decoration: none; }
.site-nav nav a:hover { background: var(--surface-3); color: var(--ink); }
.site-nav nav a.active { color: var(--brand); background: var(--brand-soft); }
@media (max-width: 640px) { .site-nav nav a.hide-sm { display: none; } .site-nav .brand-sub { display: none; } }
.wrap { width: min(1120px, 100% - 40px); margin-inline: auto; }
.wrap-narrow { width: min(720px, 100% - 40px); margin-inline: auto; }
.site-hero { padding: 72px 0 40px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; }
.site-hero h1 { font-family: var(--font-display); font-size: clamp(36px, 5.4vw, 60px); font-weight: 600; line-height: 1.05; letter-spacing: -.03em; }
.site-hero h1 em { font-style: italic; color: var(--brand); }
.site-hero .lead { font-size: 18px; color: var(--ink-2); margin: 18px 0 26px; max-width: 34em; }
.verse-card { padding: 28px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; }
.verse-card::before { content: "“"; position: absolute; top: -18px; left: 22px; font-family: var(--font-display); font-size: 110px; line-height: 1; color: var(--gold); opacity: .45; }
.verse-card p { font-family: var(--font-display); font-size: 21px; line-height: 1.45; margin: 12px 0 14px; position: relative; }
.verse-card cite { font-style: normal; font-weight: 600; color: var(--gold); font-size: 14px; letter-spacing: .03em; }
@media (max-width: 860px) { .site-hero { grid-template-columns: 1fr; padding: 40px 0 24px; } }
.section { padding: 36px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section-head h2 { font-family: var(--font-display); font-size: 28px; font-weight: 600; }
.post-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
@media (max-width: 960px) { .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .post-grid { grid-template-columns: 1fr; } }
.post-card { display: flex; flex-direction: column; overflow: hidden; color: var(--ink); text-decoration: none !important; transition: transform .2s, box-shadow .2s; }
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.post-card .cover { aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--brand-soft), var(--gold-soft)); display: grid; place-items: center; color: var(--brand); }
.post-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.post-card .cover .icon { width: 40px; height: 40px; opacity: .5; }
.post-card .body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post-card h3 { font-family: var(--font-display); font-size: 21px; font-weight: 600; line-height: 1.2; }
.post-card .ex { color: var(--ink-2); font-size: 14.5px; }
.post-card .meta { margin-top: auto; font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; align-items: center; padding-top: 8px; }
.scripture-tag { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; font-weight: 600; color: var(--gold); }
.event-list { display: grid; gap: 12px; }
.event-row { display: flex; gap: 18px; align-items: center; padding: 16px 18px; }
.event-row .date-chip { width: 58px; }
.event-row .date-chip .d { font-size: 22px; }
.event-row h3 { font-size: 17px; font-weight: 650; }
.event-row .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13.5px; color: var(--ink-2); margin-top: 4px; }
.event-row .meta span { display: inline-flex; gap: 5px; align-items: center; }
.article { padding: 48px 0 64px; }
.article h1 { font-family: var(--font-display); font-size: clamp(32px, 5vw, 48px); font-weight: 600; line-height: 1.1; letter-spacing: -.02em; margin: 14px 0 16px; }
.article .byline { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.article .cover-img { border-radius: 20px; margin: 30px 0; aspect-ratio: 16 / 8; object-fit: cover; width: 100%; box-shadow: var(--shadow); }
.prose { font-size: 18px; line-height: 1.75; color: var(--ink); }
.prose h2, .prose h3, .prose h4 { font-family: var(--font-display); font-weight: 600; margin: 1.6em 0 .5em; }
.prose h2 { font-size: 1.6em; } .prose h3 { font-size: 1.3em; } .prose h4 { font-size: 1.1em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.15em; }
.prose blockquote { margin: 1.5em 0; padding: 4px 0 4px 22px; border-left: 3px solid var(--gold); font-family: var(--font-display); font-size: 1.12em; color: var(--ink-2); font-style: italic; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.site-foot { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: 14px; margin-top: 40px; }

/* Telegram Mini App tweaks */
html.in-telegram .topbar { padding-top: 10px; }
html.in-telegram .hide-in-telegram { display: none !important; }
html.in-telegram body.pub .site-nav { position: static; }
html.in-telegram .article-wrap { padding-top: 22px; }

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

/* ---------- profile pictures, roles & comments ---------- */
img.avatar { object-fit: cover; background: var(--surface-3); display: block; }
.avatar-xs { width: 20px; height: 20px; font-size: 9px; }
.avatar-md { width: 44px; height: 44px; font-size: 15px; }
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }
.avatar-editor { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.avatar-stage {
  position: relative; width: 132px; height: 132px; border-radius: 50%; overflow: hidden; flex: none;
  background: var(--surface-3); box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--line-2);
  touch-action: none; user-select: none;
}
.avatar-stage.has-new { cursor: grab; }
.avatar-stage.is-empty:not(.has-new) { box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--warn); }
.avatar-stage canvas, .avatar-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-stage canvas { display: none; }
.avatar-stage.has-new canvas { display: block; }
.avatar-stage.has-new img { display: none; }
.avatar-stage .avatar-empty { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); text-align: center; }
.avatar-stage.is-empty:not(.has-new) .avatar-empty { display: flex; }
.avatar-editor input[type=range] { width: 100%; max-width: 240px; accent-color: var(--brand); }

.role-pick { display: grid; gap: 8px; }
.role-pick label { position: relative; cursor: pointer; }
.role-pick input { position: absolute; opacity: 0; }
.role-pick span { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 12px; transition: border-color .15s, background .15s; }
.role-pick span b { font-size: 14px; }
.role-pick small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.role-pick label:hover span { border-color: var(--muted); }
.role-pick input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.role-pick input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.comments { margin-top: 44px; }
.comment-list { list-style: none; padding: 0; margin: 18px 0 8px; }
.comment { display: flex; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 90px; }
.comment:last-child { border-bottom: 0; }
.comment:target { background: var(--brand-soft); border-radius: 12px; padding-inline: 12px; }
.comment .avatar { width: 40px; height: 40px; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 28px; }
.comment-del { margin-left: auto; }
.comment-body { margin-top: 2px; font-size: 15.5px; line-height: 1.6; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 12px; margin-top: 18px; align-items: flex-start; }
.comment-form > .avatar { width: 40px; height: 40px; }
.comment-signin { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.comment-signin > .icon { color: var(--brand); width: 28px; height: 28px; }

/* =========================================================
   Blog (Substack-style) — archive, article, likes
   ========================================================= */
:root { --font-read: "Spectral", "Iowan Old Style", Georgia, serif; --pub-max: 1080px; --read-max: 728px; }
body.pub { background: var(--surface); }
:root[data-theme="dark"] body.pub { background: var(--bg); }

.pub-wrap { width: min(var(--pub-max), 100% - 32px); margin-inline: auto; padding: 28px 0 40px; }
.pub-narrow { width: min(var(--read-max), 100% - 32px); }

.rail-label { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.rail-label a { font-size: 12px; letter-spacing: 0; text-transform: none; font-weight: 600; }

.sort-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin: 18px 0 4px; overflow-x: auto; }
.sort-tabs a { padding: 12px 0 11px; font-size: 15px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.sort-tabs a:hover { color: var(--ink); }
.sort-tabs a.active { color: var(--ink); border-color: var(--ink); font-weight: 600; }
.post-list { display: flex; flex-direction: column; }
.post-item { border-bottom: 1px solid var(--line); }
.post-item-link { display: flex; gap: 22px; align-items: flex-start; padding: 22px 0; color: var(--ink); text-decoration: none !important; }
.post-item-text { flex: 1; min-width: 0; }
.post-item h3 { font-size: 20px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }
.post-item-link:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.post-item-sub { color: var(--ink-2); font-size: 15.5px; margin: 5px 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-item-thumb { width: 112px; height: 112px; border-radius: 6px; object-fit: cover; flex: none; background: var(--surface-3); }
@media (max-width: 560px) { .post-item-thumb { width: 84px; height: 84px; } .post-item h3 { font-size: 17.5px; } }
.post-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.post-meta-author { font-weight: 600; color: var(--ink-2); }
.meta-stat { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; }
.meta-stat .icon { width: 14px; height: 14px; }

.archive-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.archive-head h1, .page-title { font-family: var(--font-display); font-size: 34px; font-weight: 600; letter-spacing: -.02em; }
.archive-search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 99px; background: var(--surface); color: var(--muted); }
.archive-search input { border: 0; outline: 0; background: none; font: 14px var(--font); color: var(--ink); width: 180px; }
.archive-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }

/* Article */
.article-wrap { width: min(var(--read-max), 100% - 32px); margin-inline: auto; padding: 44px 0 24px; }
.article-head h1 { font-family: var(--font-display); font-size: clamp(32px, 5vw, 44px); font-weight: 600; line-height: 1.12; letter-spacing: -.025em; margin: 10px 0 10px; }
.article-sub { font-size: 20px; line-height: 1.45; color: var(--muted); margin: 0 0 22px; }
.article-byline { display: flex; align-items: center; gap: 12px; }
.byline-name { font-weight: 600; font-size: 14.5px; }
.byline-date { font-size: 13.5px; color: var(--muted); }
.action-bar { display: flex; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 20px 0; }
.action-bar-bottom { margin-top: 36px; }
.action-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: 600 13.5px var(--font); cursor: pointer; text-decoration: none !important; transition: background .15s, color .15s, border-color .15s; }
.action-btn:hover { border-color: var(--muted); color: var(--ink); }
.action-btn[data-share] { margin-left: auto; }
.action-btn.is-on { color: #e0245e; border-color: color-mix(in srgb, #e0245e 40%, transparent); background: color-mix(in srgb, #e0245e 8%, transparent); }
.action-btn.is-on .icon { fill: currentColor; }
.action-btn:disabled { opacity: .6; }
.article-cover { width: 100%; border-radius: 8px; margin: 4px 0 28px; }
.prose-read { font-family: var(--font-read); font-size: 20px; line-height: 1.7; }
.prose-read h2, .prose-read h3, .prose-read h4 { font-family: var(--font); font-weight: 700; letter-spacing: -.01em; }
.author-card { display: flex; gap: 14px; align-items: flex-start; padding: 20px 0; border-bottom: 1px solid var(--line); }
.keep-reading { padding-top: 10px; }
.article-wrap .comments { margin-top: 32px; }

/* =========================================================
   Books
   ========================================================= */
.book-cover { display: block; border-radius: 4px 8px 8px 4px; object-fit: cover; background: var(--surface-3); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 8px 18px -10px rgba(0,0,0,.45), inset 4px 0 0 rgba(0,0,0,.12); flex: none; }
.book-cover-sm { width: 46px; height: 69px; }
.book-cover-md { width: 100%; aspect-ratio: 2 / 3; height: auto; }
.book-cover-lg { width: 100%; max-width: 300px; aspect-ratio: 2 / 3; height: auto; }
.book-cover-gen { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 12% 10%; color: #fff; overflow: hidden;
  background: radial-gradient(120% 80% at 100% 0%, rgba(255,255,255,.18), transparent 60%), linear-gradient(160deg, var(--bc), color-mix(in srgb, var(--bc) 70%, #000)); }
.book-cover-gen::before { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 1px; background: rgba(255,255,255,.35); }
.bc-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(13px, 1.6vw, 20px); line-height: 1.15; overflow-wrap: anywhere; }
.bc-author { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.book-cover-sm.book-cover-gen { padding: 6px 5px; }
.book-cover-sm .bc-title { font-size: 7px; }
.book-cover-sm .bc-author, .book-cover-sm.book-cover-gen::before { display: none; }
.book-cover-lg .bc-title { font-size: 26px; }

.books-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 22px 0 26px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.books-head h1 { font-family: var(--font-display); font-size: clamp(32px, 5vw, 44px); font-weight: 600; letter-spacing: -.02em; }
.books-head p { font-size: 17px; color: var(--ink-2); margin: 8px 0 16px; max-width: 36em; }
.shelf { margin-bottom: 26px; }
.shelf-row { display: grid; grid-auto-flow: column; grid-auto-columns: 132px; gap: 18px; overflow-x: auto; padding: 6px 2px 14px; scroll-snap-type: x mandatory; }
.shelf-item { display: flex; flex-direction: column; gap: 6px; color: var(--ink); text-decoration: none !important; scroll-snap-align: start; }
.shelf-item b { font-size: 13.5px; line-height: 1.3; }
.shelf-item .book-cover, .book-card .book-cover { transition: transform .2s; }
.shelf-item:hover .book-cover { transform: translateY(-3px); }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 26px 22px; }
.book-card { display: flex; flex-direction: column; gap: 12px; color: var(--ink); text-decoration: none !important; }
.book-card-cover { position: relative; padding: 18px 26px 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; height: 250px; }
.book-card-cover .book-cover { width: 100%; max-width: 150px; margin: 0 auto; }
.book-card:hover .book-cover { transform: translateY(-4px); }
.book-flag { position: absolute; top: 10px; left: 10px; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--gold-soft); color: var(--gold); }
.book-card h3 { font-size: 17px; font-weight: 700; line-height: 1.3; }
.book-card:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.book-author { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.book-desc { font-size: 14px; color: var(--muted); margin: 6px 0 8px; }
.stars { color: #e3a008; letter-spacing: 2px; font-size: 14px; margin-top: 4px; }
.stars-lg { font-size: 22px; letter-spacing: 3px; }
.book-detail { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 48px; align-items: start; }
.book-detail-cover { position: sticky; top: 130px; display: flex; flex-direction: column; gap: 16px; }
.book-download { display: flex; flex-direction: column; gap: 8px; }
.book-download .btn { width: 100%; }
.book-detail-body h1 { font-family: var(--font-display); font-size: clamp(30px, 4.5vw, 42px); font-weight: 600; line-height: 1.12; letter-spacing: -.02em; margin: 10px 0 6px; }
.book-detail-author { font-size: 19px; color: var(--ink-2); margin: 0 0 6px; }
.book-review { font-size: 19px; }
.book-owner-tools { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 18px; margin-top: 28px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .book-detail { grid-template-columns: 1fr; gap: 22px; }
  .book-detail-cover { position: static; align-items: center; }
  .book-detail-cover .book-cover-lg { max-width: 200px; }
  .book-download { width: 100%; max-width: 320px; }
}
.book-form-grid { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 22px; }
.book-form-grid .span-2 { grid-column: 1 / -1; }
.book-dropzone { aspect-ratio: 2 / 3; min-height: 0; }
@media (max-width: 600px) { .book-form-grid { grid-template-columns: 1fr; } .book-dropzone { max-width: 180px; } }
.star-input { display: flex; align-items: center; gap: 2px; }
.star-input button { border: 0; background: none; font-size: 28px; line-height: 1; color: var(--line-2); cursor: pointer; padding: 0 2px; transition: transform .1s, color .1s; }
.star-input button.on { color: #e3a008; }
.star-input button:hover { transform: scale(1.12); }
.file-pick { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1.5px dashed var(--line-2); border-radius: 12px; cursor: pointer; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.file-pick:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-current { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; margin-bottom: 8px; }

/* =========================================================
   Telegram Mini App — app layout (only inside Telegram)
   ========================================================= */
.apptabs, .show-in-telegram { display: none; }
html.in-telegram .btn.show-in-telegram { display: inline-flex; }
html.in-telegram p.show-in-telegram, html.in-telegram div.show-in-telegram { display: block; }
html.in-telegram { -webkit-tap-highlight-color: transparent; }
html.in-telegram body { overscroll-behavior-y: none; }

/* Compact header: name + avatar; sections move to the bottom tab bar. */
html.in-telegram .site-nav { position: sticky; top: 0; }
html.in-telegram body.pub .site-nav { position: sticky; }
html.in-telegram .site-nav .inner { height: 54px; gap: 10px; }
html.in-telegram .site-nav .brand-sub,
html.in-telegram body[data-user] .site-nav nav,
html.in-telegram [data-theme-toggle],
html.in-telegram .site-foot { display: none !important; }
html.in-telegram .site-nav .brand { gap: 10px; min-width: 0; }
html.in-telegram .site-nav .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
html.in-telegram .site-nav .brand-mark .icon { width: 17px; height: 17px; }
html.in-telegram .site-nav .brand-name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.in-telegram .site-nav .menu { margin-left: auto; }
html.in-telegram .site-nav nav a { padding: 6px 10px; }

/* Bottom tab bar */
html.in-telegram .apptabs {
  display: flex; position: fixed; z-index: 45; left: 0; right: 0; bottom: 0;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
html.in-telegram .apptabs a {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px 4px; border-radius: 12px; color: var(--muted); text-decoration: none;
  font-size: 11px; font-weight: 600; transition: color .15s, background .15s;
}
html.in-telegram .apptabs a .icon { width: 22px; height: 22px; }
html.in-telegram .apptabs a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
html.in-telegram .apptabs a.active { color: var(--brand); }
html.in-telegram .apptabs a.active .icon { stroke-width: 2.3; }
html.in-telegram .apptabs a:active { background: var(--surface-3); }
html.in-telegram body[data-user]:not([data-admin]) { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px)); }

/* Dashboard inside Telegram: same feel, room for its own tab bar. */
html.in-telegram .tabbar { padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px)); }
html.in-telegram .tabbar a .icon { width: 22px; height: 22px; }

/* Tighter, phone-sized spacing for the public pages. */
html.in-telegram .site-hero { padding: 18px 0 6px; gap: 16px; }
html.in-telegram .site-hero h1 { font-size: 30px; }
html.in-telegram .site-hero .lead { font-size: 15.5px; margin: 10px 0 14px; }
html.in-telegram .section { padding: 16px 0; }
html.in-telegram .section-head { margin-bottom: 12px; }
html.in-telegram .section-head h2 { font-size: 22px; }
html.in-telegram .wrap, html.in-telegram .pub-wrap { width: calc(100% - 28px); }
html.in-telegram .pub-wrap { padding-top: 14px; }
html.in-telegram .article-wrap { width: calc(100% - 28px); padding-top: 16px; }
html.in-telegram .article-head h1 { font-size: 28px; }
html.in-telegram .prose-read { font-size: 18px; }
html.in-telegram .books-head { padding: 8px 0 16px; }
html.in-telegram .books-head h1, html.in-telegram .archive-head h1 { font-size: 28px; }
html.in-telegram .card, html.in-telegram .btn, html.in-telegram .pill { touch-action: manipulation; }
html.in-telegram .btn { min-height: 40px; }

/* Guest note (not registered) */
.guest-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--brand-soft); margin: 4px 0 18px; font-size: 14px; }
.guest-note .icon { color: var(--brand); margin-top: 2px; }

/* In-app RSVP on the schedule */
.rsvp-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.rsvp-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: 600 13.5px var(--font); cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.rsvp-btn:hover { border-color: var(--muted); }
.rsvp-btn .n { font-weight: 500; opacity: .7; }
.rsvp-btn.on[data-status="yes"] { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.rsvp-btn.on[data-status="maybe"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.rsvp-btn.on[data-status="no"] { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.rsvp-btn:disabled { opacity: .6; }

/* Schedule inside the app: what is coming up first, the month calendar below. */
html.in-telegram .schedule-page { display: flex; flex-direction: column; }
html.in-telegram .schedule-upcoming { order: -1; padding-top: 18px; }
html.in-telegram .schedule-cal { padding-top: 8px !important; }
