:root {
  --gold: #d4a733;
  --gold-light: #f0c95a;
  --gold-dark: #a87f24;
  --gold-mid: #c69a2d;
  --purple: #2a1740;
  --purple-2: #3a2358;
  --purple-3: #4a2f6e;
  --purple-deep: #170c26;
  --parchment: #f7f1e3;
  --cream: #fbf3dd;
  --ink: #2a2320;
  --lavender: #c9b6e0;
  --muted: #b9a6d6;
  --green: #9fdcb0;
  --line: rgba(212,167,51,.18);
  --danger: #e06b6b;
  /* legacy aliases → фиолетовые */
  --blue: #3a2358;
  --blue-2: #4a2f6e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "PT Serif", Georgia, serif;
  background:
    radial-gradient(circle at 20% 12%, rgba(212,167,51,.12), transparent 45%),
    radial-gradient(circle at 82% 88%, rgba(74,47,110,.55), transparent 55%),
    #170c26;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  color: var(--lavender);
}

/* ---------- каркас приложения (адаптивный) ---------- */
.app {
  width: min(100%, 460px);
  height: min(96vh, 920px);
  background: linear-gradient(180deg, #2f1a47, #1a0f2b 70%, #140a20);
  border-radius: 24px;
  box-shadow: 0 22px 55px rgba(0,0,0,.55), inset 0 0 0 3px #b8892a, inset 0 0 0 9px #170c26;
  display: flex; flex-direction: column;
  overflow: hidden;
}
@media (max-width: 520px) {
  body { padding: 0; }
  .app {
    width: 100%; height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
}
.topbar-app {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #4a2f6e, #2a1740);
  border-bottom: 1px solid rgba(212,167,51,.35);
  color: #f6d98b;
}
.topbar-app .brand { flex: 1; display: flex; align-items: center; justify-content: center; gap: 9px; cursor: pointer; font-size: 17px; letter-spacing: .4px; }
.topbar-app .brand b { color: #f6e2a8; font-family: Georgia, serif; letter-spacing: 1px; }
.ubrus-img {
  height: 42px; width: 42px; flex: none; object-fit: cover;
  border-radius: 9px; background: var(--cream);
  border: 1.5px solid var(--gold);
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.nav-btn {
  width: 38px; height: 38px; flex: none;
  border: none; border-radius: 10px;
  background: rgba(255,255,255,.10); color: #f6d98b;
  font-size: 18px; line-height: 1; padding: 0;
  cursor: pointer; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-btn.ghost { background: transparent; }
.nav-btn:hover { background: rgba(255,255,255,.20); }

.view { flex: 1; overflow-y: auto; padding: 16px; scrollbar-width: thin; }

.tabbar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #1f1030; border-top: 1px solid rgba(212,167,51,.28);
}
.tab {
  border: none; background: none; padding: 8px 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: #b9a6d6; font-family: inherit;
}
.tab span { font-size: 20px; }
.tab small { font-size: 11px; }
.tab.active { color: var(--gold-light); font-weight: 700; }
.tab.active span { transform: translateY(-1px); }

/* ---------- общие элементы ---------- */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  color: var(--ink);
}
.h1 { font-size: 21px; color: #f0d98f; margin: 4px 0 10px; font-family: Georgia, serif; letter-spacing: .5px; }
.h2 { font-size: 16px; color: #e8cf86; margin: 0 0 8px; }
.sub { font-size: 12.5px; color: var(--lavender); margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 12.5px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #f6dea0 0%, #e3bb54 40%, #c69a2d 72%, #a87f24 100%);
  color: #2a1740; font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
  box-shadow: 0 6px 16px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.55);
  transition: filter .15s ease, transform .08s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #f6dea0 0%, #e3bb54 40%, #c69a2d 72%, #a87f24 100%); }
.btn.outline {
  background: transparent; color: #f0d98f;
  border: 1.5px solid rgba(240,217,143,.55); box-shadow: none;
}
.btn.outline:hover { background: rgba(240,217,143,.10); }
.btn.small { width: auto; padding: 9px 14px; font-size: 13px; }
.btn.danger { background: var(--danger); box-shadow: none; }
input, textarea, select {
  width: 100%; padding: 12px; margin-bottom: 10px;
  border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--gold); border-color: transparent; }
textarea { resize: vertical; min-height: 70px; }

/* ---------- стартовая ---------- */
.hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100%; padding: 4px; gap: 12px; text-align: center;
}
.start-icon {
  width: 100%; height: auto; display: block;
  border-radius: 14px;
  border: 2px solid var(--gold);
  box-shadow: 0 12px 34px rgba(0,0,0,.55), 0 0 0 6px rgba(212,167,51,.14);
}
.motto { font-size: 21px; font-style: italic; color: #f0d98f; margin-bottom: 4px; font-family: Georgia, serif; }
.motto-sub { font-size: 12.5px; color: var(--lavender); margin-bottom: 18px; }
.greeting { font-size: 13px; color: var(--green); margin-bottom: 10px; }

/* ---------- улей / соты ---------- */
.hive-stage { position: relative; margin: 6px auto 18px; width: min(100%, 340px); aspect-ratio: 1/1; overflow: hidden; }
.cell {
  position: absolute; display: grid; place-items: center; text-align: center; cursor: pointer;
  clip-path: url(#hexRound);
  border-radius: 16px;
  color: #fff; transition: transform .12s ease;
  filter: drop-shadow(0 5px 8px rgba(0,0,0,.4));
}
.cell:hover { transform: translate(-50%,-50%) scale(1.06); }
.cell .inner { position: relative; z-index: 1; padding: 4px; line-height: 1.1; }
.cell-bg { position: absolute; inset: 4px; clip-path: url(#hexRound); }
.cell.center {
  width: 112px; height: 128px; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: linear-gradient(150deg, #f3cf6e, #d4a733 55%, #b8892a);
  font-weight: 700; filter: drop-shadow(0 0 9px rgba(240,201,90,.5)) drop-shadow(0 6px 10px rgba(0,0,0,.45));
}
.cell.center .label { font-size: 12.5px; line-height: 1.12; }
.cell.center .tag { font-size: 9.5px; opacity: .92; }
.cell.around {
  width: 72px; height: 82px;
  background: linear-gradient(150deg, #f6d98f, #d4a733 55%, #b8892a);
  color: var(--ink); opacity: .98;
}
.cell.around .cell-bg { background: linear-gradient(150deg, #fdf7e6, #efe1bd); }
.cell.around .inner.angel { width: 82%; height: 82%; display: block; }
.cell.around svg { width: 100%; height: 100%; display: block; }
/* позиции 8 сот вокруг (с отступом от краёв) */
.p-top    { left: 50%; top: 13%; transform: translate(-50%,-50%); }
.p-top-r  { left: 75%; top: 25%; transform: translate(-50%,-50%); }
.p-right  { left: 85%; top: 50%; transform: translate(-50%,-50%); }
.p-bot-r  { left: 75%; top: 75%; transform: translate(-50%,-50%); }
.p-bottom { left: 50%; top: 87%; transform: translate(-50%,-50%); }
.p-bot-l  { left: 25%; top: 75%; transform: translate(-50%,-50%); }
.p-left   { left: 15%; top: 50%; transform: translate(-50%,-50%); }
.p-top-l  { left: 25%; top: 25%; transform: translate(-50%,-50%); }

/* кнопки под ульем */
.hive-actions { display: flex; gap: 10px; margin-top: 8px; }
.hive-actions .btn { flex: 1; width: auto; }

/* ---------- списки ---------- */
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 8px; cursor: pointer; color: var(--ink);
}
.list-item:hover { background: #fbf7ea; }
.list-item .avatar {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  background: linear-gradient(145deg, var(--purple-3), var(--purple));
  color: #f6d98b; display: grid; place-items: center; font-size: 19px; font-weight: 700;
}
.list-item .body { flex: 1; min-width: 0; }
.list-item .body b { display: block; font-size: 14.5px; }
.list-item .body small { color: #8a7f6d; font-size: 12px; }

.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: #efe6c8; color: #6b5616; }
.chip.active { background: #dff0e2; color: #25603a; }

/* ---------- орнаментальные плашки меню ---------- */
.plaque {
  position: relative;
  display: flex; align-items: center;
  min-height: 56px;
  margin-bottom: 12px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #fdf7e6 0%, #f4e6c2 55%, #e9d9a6 100%);
  border: 2px solid #b8892a;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #fbf3dd, inset 0 0 0 3px #d9b24a, 0 3px 9px rgba(0,0,0,.30);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .2s ease, filter .15s ease;
}
.plaque:hover { transform: translateY(-1px); filter: brightness(1.03); box-shadow: inset 0 0 0 2px #fbf3dd, inset 0 0 0 3px #d9b24a, 0 7px 16px rgba(0,0,0,.40); }
.plaque:active { transform: translateY(1px); }
.plaque-ico {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 27px; height: 27px; color: #a87f24; line-height: 0;
}
.plaque-ico svg { width: 100%; height: 100%; display: block; }
.plaque-label {
  flex: 1; text-align: center;
  font-size: 15.5px; font-weight: 700; letter-spacing: 1.5px;
  color: #8a6a12; text-transform: uppercase;
  font-family: Georgia, "Times New Roman", serif;
}
.back-plaque { min-height: 46px; margin-top: 4px; }
.back-plaque .plaque-label { font-size: 14px; }

/* ---------- чат ---------- */
.chat-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.35; }
.msg .meta { font-size: 10.5px; opacity: .75; margin-bottom: 2px; }
.msg.mine { align-self: flex-end; background: linear-gradient(145deg, var(--purple-3), var(--purple)); color: #fff; border-bottom-right-radius: 4px; }
.msg.other { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; color: var(--ink); }
.msg .who { font-weight: 700; font-size: 11.5px; display: block; margin-bottom: 2px; }
.chat-input { display: flex; gap: 8px; position: sticky; bottom: 0; background: transparent; padding-top: 6px; }
.chat-input input { flex: 1; margin-bottom: 0; }
.chat-input button { width: auto; padding: 0 16px; }

/* вкладки чата (вариант В — соборный) */
.chat-tabs { display: flex; gap: 6px; margin: 4px 0 10px; flex-wrap: wrap; }
.chat-tab {
  font-size: 12px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(212,167,51,.45); color: #c9b6e0; background: transparent; font-family: inherit;
}
.chat-tab.on { background: linear-gradient(135deg, #f0d98f, #c69a2d); color: #2a1740; font-weight: 700; border-color: transparent; }

/* панель православных смайликов */
.emoji-btn {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  border: 1.5px solid rgba(240,201,90,.55); background: rgba(240,201,90,.12);
  font-size: 19px; cursor: pointer;
}
.emoji-panel {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
  background: #1f1030; border: 1px solid rgba(212,167,51,.35); border-radius: 12px;
  padding: 8px; margin-bottom: 8px;
}
.emoji-panel[hidden] { display: none; }
.emoji-cell {
  font-size: 20px; padding: 4px; border: none; background: transparent; cursor: pointer; border-radius: 8px;
}
.emoji-cell:hover { background: rgba(240,201,90,.18); }

/* ---------- модал / тост ---------- */
.modal { position: fixed; inset: 0; background: rgba(10,5,18,.7); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { width: 340px; max-width: 100%; background: var(--parchment); border-radius: 18px; padding: 20px; box-shadow: 0 22px 55px rgba(0,0,0,.55); border: 2px solid var(--gold); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { color: var(--purple); font-size: 19px; }
.close { border: none; background: none; font-size: 18px; cursor: pointer; color: #8a7f6d; }
.auth-switch { text-align: center; margin-top: 8px; font-size: 13px; }
.auth-switch a { color: var(--purple); text-decoration: none; }
.form-error { color: var(--danger); font-size: 12.5px; text-align: center; margin-top: 6px; min-height: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: #1f1030; color: #f6d98b; padding: 10px 16px; border-radius: 999px;
  border: 1px solid rgba(212,167,51,.5);
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 60;
  white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; color: var(--lavender); padding: 30px 10px; font-size: 13.5px; }
.article-body { white-space: pre-wrap; line-height: 1.6; font-size: 15px; color: var(--ink); }

/* вступительное поучение в разделе библиотеки */
.theme-intro {
  background: rgba(212,167,51,.12);
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  padding: 10px 12px; margin-bottom: 10px;
  font-size: 13.5px; line-height: 1.45; color: #e9def3; font-style: italic;
}

/* святые отцы */
.father-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(212,167,51,.35);
  border-radius: 14px;
  padding: 14px; margin-bottom: 14px;
}
.father-head b { display: block; color: #f0d98f; font-size: 16px; font-family: Georgia, serif; }
.father-head small { display: block; color: #b9a6d6; font-size: 12px; margin-top: 2px; margin-bottom: 10px; }
.father-teach { margin-bottom: 10px; }
.teach { background: rgba(212,167,51,.10); border-left: 3px solid var(--gold); border-radius: 0 8px 8px 0; padding: 8px 10px; margin-bottom: 8px; }
.teach b { display: block; color: #e8cf86; font-size: 12.5px; margin-bottom: 3px; }
.teach span { color: #e9def3; font-size: 13px; line-height: 1.45; font-style: italic; }
.father-works { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.father-works[hidden] { display: none; }
.work { background: rgba(255,255,255,.05); border-radius: 8px; padding: 8px 10px; font-size: 13px; color: #e9def3; }

/* духовный гимн — поучения подряд, без кликов */
.hymn { border-bottom: 1px solid rgba(212,167,51,.18); padding: 12px 2px; }
.hymn-body { font-size: 14px; line-height: 1.55; color: #efe6d6; }
.hymn-cap { margin-top: 6px; font-size: 12px; color: #b9a6d6; font-style: italic; text-align: right; }
.works-label { font-size: 12px; color: #b9a6d6; margin: 8px 0 5px; }
.works-inline { display: flex; flex-direction: column; gap: 6px; }

/* аккордеон библиотеки */
.acc {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(212,167,51,.35);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}
.acc > summary {
  cursor: pointer;
  padding: 14px 16px;
  font-size: 16px; font-weight: 700;
  color: #f0d98f; font-family: Georgia, serif;
  list-style: none;
  display: flex; align-items: center; justify-content: space-between;
}
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after { content: '▾'; color: var(--gold); font-size: 13px; }
.acc[open] > summary::after { content: '▴'; }
.acc-body { padding: 0 16px 14px; }
.acc-father { border-top: 1px solid rgba(212,167,51,.18); padding: 6px 0; }
.acc-father > summary { cursor: pointer; padding: 8px 0; color: #e8cf86; font-size: 14px; list-style: none; }
.acc-father > summary::-webkit-details-marker { display: none; }
.acc-father > summary::after { content: ' ▾'; color: var(--gold); }
.acc-father[open] > summary::after { content: ' ▴'; }
.acc-father .works-inline { padding: 4px 0 8px 10px; }
