:root {
  --brown: #5b3a21;
  --brown-dark: #3b2615;
  --cream: #fffbf2;
  --ink: #2a1f16;
  --muted: #6d5d4e;
  --green: #4c9a3f;
  --gold: #f2c200;
  --orange: #f08a24;
  --red: #d32f2f;
  --blue: #3b82f6;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  position: relative;
  min-height: max(220vh, 1600px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #3b2615;
  line-height: 1.55;
}

/* Tall aspen background: canopy at the top, soil + intertwined roots at the bottom,
   stretched to the full height of the page so scrolling travels down the trees. */
#bg {
  position: absolute; inset: 0; z-index: -2;
  background: url("assets/bg.jpg") center top / 100% 100% no-repeat;
}
#leaves { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
  background: rgba(40, 27, 16, .82);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid rgba(242, 194, 0, .55);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 60px; height: 60px; flex: none; border-radius: 50%; object-fit: cover; display: block;
  border: 3px solid var(--gold); box-shadow: 0 2px 8px rgba(0,0,0,.45);
}
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font: 700 clamp(1.02rem, 4.3vw, 1.7rem)/1.15 Georgia, "Times New Roman", serif; }
.brand h1 a { color: #fff; text-decoration: none; }
.social { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.social a {
  color: #fff; text-decoration: none; font-size: .72rem; font-weight: 600;
  padding: 3px 8px; border: 1px solid rgba(255,255,255,.55); border-radius: 999px;
}
.social a:hover, .social a:focus-visible { background: var(--gold); color: #2a1f16; border-color: var(--gold); }

.menu-wrap { position: relative; flex: none; }
.burger {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.08); cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; padding: 0;
}
.burger span { display: block; width: 24px; height: 3px; border-radius: 2px; background: #fff; transition: transform .2s, opacity .2s; }
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }
.burger:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.menu {
  position: absolute; right: 0; top: calc(100% + 10px); width: 230px;
  background: var(--brown); border-radius: 14px; padding: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); border: 1px solid #7a5232;
}
.menu[hidden] { display: none; }
.menu a {
  display: block; padding: 13px 14px; border-radius: 9px; color: #fff; text-decoration: none; font-weight: 600;
  transition: background .12s, color .12s;
}
.menu a.m-home:hover,      .menu a.m-home:focus-visible      { background: var(--green);  color: #10230d; }
.menu a.m-about:hover,     .menu a.m-about:focus-visible     { background: var(--gold);   color: #2a1f16; }
.menu a.m-knowledge:hover, .menu a.m-knowledge:focus-visible { background: var(--orange); color: #2a1500; }
.menu a.m-contact:hover,   .menu a.m-contact:focus-visible   { background: var(--blue);   color: #fff; }
.menu a.m-manager:hover,   .menu a.m-manager:focus-visible   { background: var(--red);    color: #fff; }
.menu a.current { outline: 2px solid rgba(255,255,255,.35); outline-offset: -2px; }

/* ---------- content ---------- */
main { position: relative; z-index: 2; padding: 18px 12px 40px; outline: none; }
.card {
  max-width: 720px; margin: 0 auto 18px; padding: 22px 20px;
  background: rgba(255, 251, 242, .94); border-radius: 18px;
  box-shadow: 0 6px 22px rgba(0,0,0,.3);
}
.card h2 { margin: 0 0 10px; font: 700 1.6rem/1.2 Georgia, "Times New Roman", serif; color: var(--brown-dark); }
.card h3 { margin: 18px 0 8px; font-size: 1.1rem; color: var(--brown-dark); }
.card p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: .9rem; }

.btn, button.btn, .btn-link {
  display: inline-block; border: 0; border-radius: 999px; padding: 10px 22px; font: inherit; font-weight: 600;
  background: var(--brown); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #7a5232; }
.btn.secondary { background: #e9dfd0; color: var(--brown-dark); }
.btn.danger { background: var(--red); }
.btn.small { padding: 5px 13px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #1f6fe5; outline-offset: 2px; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--ink);
  border: 2px solid #cdbfae; border-radius: 12px; background: #fff;
}
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-weight: 600; margin: 12px 0 5px; }

.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }

.notice { background: #fff3cd; border: 1px solid #e6c85c; border-radius: 12px; padding: 12px 14px; margin: 14px 0 0; font-size: .92rem; }
.notice.err { background: #fde4e4; border-color: #e49a9a; color: #7a1313; }
.notice.ok { background: #e2f3de; border-color: #9fcf95; color: #1e4d17; }

/* search results */
.results { margin-top: 16px; display: grid; gap: 10px; }
.result { border: 1px solid #e0d4c3; border-radius: 12px; background: #fff; padding: 12px 14px; cursor: pointer; }
.result:hover { border-color: var(--orange); }
.result h4 { margin: 0 0 3px; font-size: 1.02rem; }
.result .snip { margin: 0; color: var(--muted); font-size: .92rem; }
.badge { display: inline-block; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px;
         border-radius: 999px; background: #e6efe0; color: #2d5a22; margin-right: 6px; vertical-align: middle; }
.badge.factor { background: #dbe9f8; color: #1d3a63; }

/* posts */
.post h3 { margin-top: 0; font: 700 1.3rem/1.25 Georgia, serif; }
.post .meta { color: var(--muted); font-size: .82rem; margin-bottom: 10px; }
.post .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.post img, .post video { max-width: 100%; border-radius: 12px; margin-top: 12px; display: block; }
.post iframe { width: 100%; height: 520px; border: 1px solid #d8cbb9; border-radius: 12px; margin-top: 12px; background: #fff; resize: vertical; }

/* comments */
.comment { margin-top: 14px; }
.c-box { background: #fff; border: 1px solid #e0d4c3; border-radius: 12px; padding: 10px 13px; }
.comment.is-owner > .c-box { border-color: var(--green); background: #f3faf0; }
.c-head { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); margin-bottom: 4px; flex-wrap: wrap; }
.c-name { font-weight: 700; color: var(--ink); }
.is-owner .c-name { color: #2d6a22; }
.c-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.c-actions { margin-top: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 2px 0; font: inherit; font-size: .85rem; font-weight: 600; color: #1f5fbf; cursor: pointer; }
.linkbtn.del { color: var(--red); }
.replies { margin-left: 12px; padding-left: 12px; border-left: 3px solid #d6c7b2; }
.replies.flat { margin-left: 0; padding-left: 0; border-left: 0; }
.reply-form { margin-top: 8px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* pain factors graphic */
.pf { background: #dbe9f8; border-radius: 20px; padding: 22px 18px; }
.pf h2 { color: #14213d; font: 800 2rem/1.1 system-ui, sans-serif; }
.pf .sub { color: #56627a; margin: 0 0 16px; }
.pf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.pf-head { border-radius: 999px; padding: 10px; text-align: center; color: #fff; font-weight: 800; letter-spacing: .05em; font-size: .8rem; }
.pf-head.site { background: #5a6578; } .pf-head.system { background: #14213d; }
.factor { border: 0; border-radius: 10px; padding: 12px 6px; min-height: 54px; font: inherit; font-size: .92rem; color: #14213d; cursor: pointer;
          transition: transform .1s, box-shadow .1s; }
.factor.site { background: #fff; } .factor.system { background: #e8effc; }
.factor:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(20,33,61,.22); }

dialog { border: 0; border-radius: 16px; padding: 24px; max-width: 440px; width: calc(100% - 32px); box-shadow: 0 10px 40px rgba(0,0,0,.4); }
dialog::backdrop { background: rgba(20,33,61,.5); }
dialog h2 { margin: 0 0 4px; color: #14213d; font-family: Georgia, serif; }
dialog .tag { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: #5a6578; margin: 0 0 12px; }
dialog .evidence { display: inline-block; font-size: .78rem; font-weight: 600; background: #e6efe0; color: #2d5a22; border-radius: 999px; padding: 2px 10px; margin: 0 0 12px; }
dialog .evidence[hidden] { display: none; }
dialog .body { line-height: 1.55; margin: 0 0 18px; }

.disclaimer { border-left: 5px solid var(--orange); background: #fff4e5; padding: 14px 16px; border-radius: 0 12px 12px 0; margin-top: 18px; }

.foot { position: relative; z-index: 2; text-align: center; font-size: .78rem; color: #fff; padding: 14px 16px 20px;
        background: rgba(30, 20, 12, .72); }
.mgr-post { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid #e5d9c8; }
.mgr-post span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filename { font-size: .9rem; color: var(--muted); margin-left: 8px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* likes */
.like { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 9px; border-radius: 999px;
        cursor: pointer; color: #8a7f73; font: inherit; font-size: .9rem; font-weight: 700; }
.like svg { width: 20px; height: 20px; fill: currentColor; }
.like .like-count { color: var(--ink); }
.like:hover { background: rgba(46, 158, 63, .12); }
.like.on { color: #2e9e3f; }

/* ---- header right side: Manager Active + menu ---- */
.top-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
@media (min-width: 700px) { .top-right { flex-direction: row; align-items: center; gap: 12px; } }
.mgr-wrap { position: relative; }
.mgr-active {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid #7fd17a; background: rgba(76,154,63,.28); color: #e9ffe6;
  border-radius: 999px; padding: 4px 11px; font: inherit; font-size: .74rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.mgr-active .dot { width: 8px; height: 8px; border-radius: 50%; background: #5be04f; box-shadow: 0 0 6px #5be04f; }
.mgr-active:hover { background: rgba(76,154,63,.5); }
.mgr-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 170px; background: #fff; border-radius: 12px; padding: 6px; z-index: 40;
            box-shadow: 0 10px 28px rgba(0,0,0,.45); }
.mgr-menu[hidden] { display: none; }
.mgr-menu a, .mgr-menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 8px;
            font: inherit; font-weight: 600; color: var(--ink); text-decoration: none; cursor: pointer; }
.mgr-menu a:hover, .mgr-menu button:hover { background: #f0e6d6; }
.mgr-menu button { color: var(--red); }

/* ---- knowledge topics ---- */
.topics { display: grid; gap: 10px; margin-top: 14px; }
@media (min-width: 560px) { .topics { grid-template-columns: 1fr 1fr; } }
.topic { display: block; padding: 16px 16px; border-radius: 14px; background: #fff; border: 2px solid #e0d4c3; color: var(--brown-dark);
         font-weight: 700; text-decoration: none; text-align: center; transition: transform .1s, border-color .1s, background .1s; }
.topic:hover, .topic:focus-visible { border-color: var(--orange); background: #fff7ea; transform: translateY(-1px); }
.crumbs { max-width: 720px; margin: 0 auto 10px; }
.crumbs a { display: inline-block; background: rgba(40,27,16,.78); color: #fff; text-decoration: none; padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: .9rem; }
.crumbs a:hover { background: var(--brown); }
.topic-head h2 { margin: 0; }
.soon { margin: 0; font: 700 1.4rem Georgia, serif; color: var(--brown-dark); text-align: center; padding: 18px 0; }

/* ---- post actions + per-post comments ---- */
.post .row { margin-top: 14px; }
.cm-toggle { background: none; border: 0; padding: 6px 10px; font: inherit; font-size: .9rem; font-weight: 700; color: #1f5fbf; cursor: pointer; border-radius: 999px; }
.cm-toggle:hover { background: rgba(31,95,191,.1); }
.cm-panel { margin-top: 12px; padding-top: 6px; border-top: 1px solid #e5d9c8; }
.cm-panel[hidden] { display: none; }
.comment.flash > .c-box { animation: flash 2.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px rgba(242,194,0,.9); background: #fff6cc; } 100% { box-shadow: 0 0 0 0 rgba(242,194,0,0); } }
.cm-result { cursor: default; }
.cm-result:hover { border-color: #e0d4c3; }
.cm-result .snip { color: var(--ink); margin: 4px 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.card h3 { margin-top: 20px; }

/* ---- manager composer ---- */
.title-row { display: flex; gap: 10px; align-items: center; }
.title-row input { flex: 1; }
.toggle { flex: none; border: 2px solid var(--brown); background: #fff; color: var(--brown-dark); border-radius: 999px; padding: 9px 16px; font: inherit; font-weight: 700; cursor: pointer; }
.toggle[aria-pressed="true"] { background: var(--brown); color: #fff; }
.title-row input:disabled { background: #eee; }
.notice a { color: inherit; font-weight: 700; }
.pf { border-radius: 16px; }
.post .pf { margin-top: 0; }
