:root {
  --bg: #F7F5EF;        /* page background — warm cream */
  --main: #B8C9AE;      /* main colour — sage green */
  --card: #E7EDE2;      /* card background — light green */
  --second: #D8C3AE;    /* secondary — pastel sand */
  --button: #5C7053;    /* buttons — dark green */
  --ink: #493B32;       /* text — dark brown */
  --button-ink: #FFFFFF;
  --muted: #85766a;
  --paper: #FCFBF7;
  --field: #FFFFFF;     /* writing areas */
  --ink-strong: #2f2620;
  --shadow: rgba(73, 59, 50, 0.25);
  --crisis-bg: #f3d9cf;
  color-scheme: light;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
}
/* Dark mode: follows the phone/computer setting, or the 🌙 button */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #191C18;
  --paper: #22261F;
  --card: #2B3227;
  --main: #4E5F45;
  --second: #3F3A33;
  --button: #A3BB95;
  --button-ink: #172014;
  --ink: #ECE6DC;
  --ink-strong: #FFFFFF;
  --muted: #A89C8E;
  --field: #1E221B;
  --shadow: rgba(0, 0, 0, 0.5);
  --crisis-bg: #5A3A30;
  color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #191C18;
  --paper: #22261F;
  --card: #2B3227;
  --main: #4E5F45;
  --second: #3F3A33;
  --button: #A3BB95;
  --button-ink: #172014;
  --ink: #ECE6DC;
  --ink-strong: #FFFFFF;
  --muted: #A89C8E;
  --field: #1E221B;
  --shadow: rgba(0, 0, 0, 0.5);
  --crisis-bg: #5A3A30;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); line-height: 1.55; }
.top, main, .foot { max-width: 640px; margin: 0 auto; padding: 0 16px; }
a { color: var(--button); }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 2px solid var(--button); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hp { position: absolute; left: -9999px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Header */
.top { padding-top: 40px; text-align: center; }
.logo {
  font-family: var(--serif); font-weight: 600; font-size: clamp(28px, 7vw, 42px); line-height: 1.1;
  color: var(--ink); text-decoration: none; letter-spacing: -0.02em;
}
.logo { display: inline-flex; align-items: center; gap: 12px; }
.logo-mark { height: 1.15em; width: auto; flex: none; }
.tag { color: var(--muted); margin: 8px 0 0; }
.me {
  display: inline-block; font-size: 13px; color: var(--muted); margin: 14px 0 28px;
  background: var(--card); padding: 4px 12px; border-radius: 999px;
}
.me b { color: var(--button); font-weight: 600; }

/* Cards */
.card {
  background: var(--paper); border: 1px solid var(--second); border-radius: 16px;
  padding: 18px 20px; margin-bottom: 14px;
}

/* Composer */
.composer { border: 1.5px solid var(--button); background: var(--field); }
.composer .prompt { display: block; font-family: var(--serif); font-size: 20px; font-weight: 600; margin-bottom: 10px; }
.composer textarea, .reply textarea {
  width: 100%; resize: vertical; border: 1px solid var(--second); border-radius: 12px;
  background: var(--bg); color: var(--ink); font-family: var(--serif); font-size: 18px; line-height: 1.5;
  padding: 12px 14px; outline: none;
}
.composer textarea:focus, .reply textarea:focus { border-color: var(--button); box-shadow: 0 0 0 3px var(--card); }
.compose-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.composer.done { border-style: dashed; background: var(--card); text-align: center; }
.composer.done p { margin: 4px 0; }
.primary {
  display: inline-block; background: var(--button); color: var(--button-ink); border: none; border-radius: 999px;
  padding: 11px 22px; font-weight: 600; text-decoration: none; text-align: center;
}
.primary:not(:disabled):hover { filter: brightness(1.08); }
.ghost {
  background: transparent; border: 1px solid var(--second); border-radius: 999px; padding: 9px 18px; color: var(--ink);
}
.ghost:hover { background: var(--card); }

/* Topic chips */
.topics { display: flex; flex-wrap: wrap; gap: 6px; border: none; padding: 0; margin: 12px 0 0; }
.topics legend { padding: 0; margin-bottom: 6px; width: 100%; }
.topics.pick label { position: relative; }
.topics.pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.topics.pick span, .topics.filter button {
  display: inline-block; font-size: 13px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--second); background: transparent; color: var(--ink); line-height: 1.5;
}
.topics.pick input:checked + span, .topics.filter button[aria-pressed="true"] {
  background: var(--main); border-color: var(--button); color: var(--ink); font-weight: 500;
}
.topics.pick input:focus-visible + span { outline: 2px solid var(--button); outline-offset: 2px; }
.topics.filter { margin: 0 0 18px; justify-content: center; }

/* Sort tabs */
.tabs { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 26px 0 10px; }
.tabs button {
  background: transparent; border: none; padding: 6px 12px; border-radius: 999px; font-size: 15px; color: var(--muted);
}
.tabs button[aria-pressed="true"] { color: var(--ink); background: var(--card); font-weight: 600; }
.tabs button:hover { color: var(--button); }

/* Posts */
.who { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.name { font-weight: 600; color: var(--button); }
.dot { opacity: 0.6; }
.badge { font-size: 11px; background: var(--card); color: var(--button); border-radius: 6px; padding: 1px 6px; font-weight: 500; }
.badge.op { background: var(--main); color: var(--ink); }
.topic-tag {
  font-size: 12px; border: 1px solid var(--second); background: transparent; border-radius: 999px; padding: 0 8px; color: var(--muted);
}
.topic-tag:hover { border-color: var(--button); color: var(--button); }
.flag {
  margin-left: auto; background: none; border: none; color: var(--muted); font-size: 15px; padding: 2px 6px; border-radius: 6px; opacity: 0.6;
}
.flag:hover { opacity: 1; background: var(--card); }
.text {
  display: block; margin: 10px 0 12px; font-family: var(--serif); font-size: 19px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); text-decoration: none;
}
a.text:hover { color: var(--ink-strong); }
.clamp { display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.post-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.reacts { display: flex; gap: 4px; flex-wrap: wrap; }
.react {
  display: inline-flex; align-items: center; gap: 4px; min-height: 34px;
  background: var(--bg); border: 1px solid transparent; border-radius: 999px; padding: 3px 9px; font-size: 13px;
}
.react .emo { font-size: 16px; line-height: 1; }
.react .n { color: var(--muted); font-weight: 500; }
.react:hover { border-color: var(--second); }
.react.on { background: var(--card); border-color: var(--button); }
.react.on .n { color: var(--button); }
.comments-link { font-size: 14px; text-decoration: none; color: var(--muted); white-space: nowrap; }
.comments-link:hover { color: var(--button); }
.care {
  display: block; font-size: 14px; background: var(--card); border-radius: 10px; padding: 8px 12px;
  margin: -2px 0 12px; text-decoration: none; color: var(--button);
}
.care:hover { background: var(--main); color: var(--ink); }
.more-wrap { text-align: center; margin: 10px 0; }

/* Post page */
.back { display: inline-block; margin-bottom: 14px; font-size: 14px; text-decoration: none; color: var(--muted); }
.back:hover { color: var(--button); }
.post .text:not(a) { font-size: 21px; }
.replies h2 { font-size: 14px; font-weight: 500; color: var(--muted); margin: 26px 4px 8px; }
.replies > .muted { margin: 0 4px 12px; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment { padding: 12px 4px; border-top: 1px solid var(--second); }
.comment:last-child { border-bottom: 1px solid var(--second); }
.comment .text { font-size: 17px; margin: 6px 0 0; }
.reply { display: flex; gap: 10px; align-items: flex-end; margin-top: 16px; }
.reply textarea { font-size: 17px; }

/* Help page */
.page h1 { font-family: var(--serif); font-size: 24px; margin: 0 0 8px; }
.lines { list-style: none; margin: 12px 0; padding: 0; }
.lines li { padding: 9px 0; border-top: 1px solid var(--second); display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px; }
.lines li span { color: var(--muted); font-size: 14px; }
.rules { padding-left: 18px; margin: 0; }
.rules li { margin-bottom: 8px; }

/* Support dialog */
dialog {
  border: none; border-radius: 18px; padding: 24px; max-width: min(480px, calc(100% - 32px));
  background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px var(--shadow);
}
dialog::backdrop { background: rgba(20, 16, 12, 0.5); }
dialog h2 { font-family: var(--serif); font-size: 23px; margin: 0 0 10px; line-height: 1.25; }
.dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 8px; }
dialog .lines { margin-bottom: 0; }

.loading, .error { text-align: center; color: var(--muted); padding: 40px 0; }
.foot { color: var(--muted); font-size: 13px; text-align: center; padding: 48px 16px 32px; }
.foot p { margin: 4px 0; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: 0.25s; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 480px) {
  .card { padding: 16px; }
  .text { font-size: 18px; }
  .reply { flex-direction: column; align-items: stretch; }
  .lines li { grid-template-columns: 1fr; gap: 2px; }
}

/* Header links */
.me { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; background: none; padding: 0; }
.me a { text-decoration: none; color: var(--muted); background: var(--card); padding: 4px 12px; border-radius: 999px; }
.me a:hover { background: var(--main); color: var(--ink); }
.inbox-link .count {
  display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--button); color: var(--button-ink); font-size: 11px; font-weight: 600; text-align: center;
}
a.name { text-decoration: none; }
a.name:hover { text-decoration: underline; }

/* Profile */
.profile { text-align: center; }
.profile h1 { font-family: var(--serif); font-size: 26px; margin: 6px 0 2px; }
.profile p { margin: 4px 0; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center;
  background: var(--main); color: var(--ink); font-family: var(--serif); font-size: 26px; font-weight: 600;
}
.switch { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 14px; margin: 14px 0 4px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--button); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--button); }

/* Write privately */
.dm-box { margin: -4px 0 14px; }
.dm-box summary {
  cursor: pointer; list-style: none; display: inline-block; font-size: 14px; font-weight: 500; color: var(--button);
  border: 1px solid var(--button); border-radius: 999px; padding: 7px 14px;
}
.dm-box summary::-webkit-details-marker { display: none; }
.dm-box summary:hover, .dm-box[open] summary { background: var(--card); }
.dm-form { margin-top: 10px; background: var(--paper); border: 1px solid var(--second); border-radius: 14px; padding: 14px; }
.dm-form p { margin: 0 0 8px; }
.dm-form textarea {
  width: 100%; resize: vertical; border: 1px solid var(--second); border-radius: 12px; background: var(--bg);
  color: var(--ink); font-family: var(--serif); font-size: 17px; padding: 10px 12px; outline: none;
}
.dm-form textarea:focus { border-color: var(--button); }

/* Inbox */
.page-title { font-family: var(--serif); font-size: 28px; margin: 0 0 14px; }
.chat-list { padding: 0; overflow: hidden; }
.chat-row { display: block; padding: 14px 18px; border-top: 1px solid var(--second); text-decoration: none; color: var(--ink); }
.chat-row:first-child { border-top: none; }
.chat-row:hover { background: var(--card); }
.chat-row .preview { margin: 4px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.unread .preview { font-weight: 600; }
.chat-row .about { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot-new { width: 8px; height: 8px; border-radius: 50%; background: var(--button); margin-left: auto; }

/* Chat */
.chat-head { margin-bottom: 10px; }
.chat-head h1 { font-family: var(--serif); font-size: 26px; margin: 0; }
.chat-head h1 a { color: var(--ink); text-decoration: none; }
.chat-head .about { display: block; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.small-btns .ghost { font-size: 13px; padding: 5px 12px; }
.msgs { list-style: none; margin: 18px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.msg {
  max-width: 82%; align-self: flex-start; background: var(--paper); border: 1px solid var(--second);
  border-radius: 16px 16px 16px 4px; padding: 9px 13px;
}
.msg.mine { align-self: flex-end; background: var(--card); border-color: var(--main); border-radius: 16px 16px 4px 16px; }
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--serif); font-size: 17px; }
.msg.gone p { font-family: var(--sans); font-size: 13px; color: var(--muted); font-style: italic; }
.msg-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 3px; }
.msg-meta .flag { font-size: 13px; padding: 0 4px; }
.msg .care { margin: 8px 0 0; font-size: 13px; }
.banner { border-color: var(--button); }
.banner p { margin: 0 0 4px; }
.banner-note { text-align: center; color: var(--muted); font-size: 14px; background: var(--card); border-radius: 12px; padding: 10px; }
.chat-compose { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; margin-top: 0; }
.center { text-align: center; }

/* Live chat */
.live-intro h1 { font-family: var(--serif); font-size: 26px; margin: 0 0 6px; }
.live-intro p { margin: 0 0 8px; }
.live-intro .compose-row { margin-top: 16px; }
.optional { margin-top: 12px; }
.optional summary { cursor: pointer; }
.stage {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; min-height: 360px;
  background: var(--paper); border: 1px solid var(--second); border-radius: 18px; overflow: hidden;
}
.side { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 34px 16px 22px; text-align: center; }
.side.you { background: var(--card); }
.side-label { position: absolute; top: 12px; left: 0; right: 0; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stage-logo {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px; background: var(--paper); border: 2px solid var(--button); z-index: 1;
}
.stage-logo img { width: 30px; height: auto; }
.avatar.big { width: 72px; height: 72px; font-size: 32px; margin: 0 auto 8px; }
.cand { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.cand-name { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; margin: 6px 0; }
.tags span { font-size: 12px; border: 1px solid var(--second); border-radius: 8px; padding: 1px 8px; background: var(--paper); }
.reel .cand-name { filter: blur(0.3px); }
#reel-name { display: inline-block; }
#reel-name.tick { animation: tick 0.11s ease-out; }
@keyframes tick { from { transform: translateY(-60%); opacity: 0.2; } to { transform: none; opacity: 1; } }
.decide { display: flex; gap: 28px; justify-content: center; margin: 12px 0 4px; }
.round { width: 58px; height: 58px; border-radius: 50%; font-size: 24px; border: 2px solid var(--ink); background: var(--paper); }
.round.yes { background: var(--button); border-color: var(--button); color: var(--button-ink); }
.round:hover { transform: scale(1.06); }
.center-row { justify-content: center; }
@media (prefers-reduced-motion: reduce) { #reel-name.tick { animation: none; } .round:hover { transform: none; } }
@media (max-width: 560px) {
  .stage { grid-template-columns: 1fr; }
  .stage-logo { position: relative; left: auto; top: auto; transform: none; margin: -26px auto; }
  .side.them { padding-top: 48px; }
  .side.them .side-label { top: 32px; }
  .side { padding: 30px 16px 26px; }
}
.live-head { background: var(--card); border-radius: 14px; padding: 12px 14px; }
.live-who { display: flex; gap: 12px; align-items: center; }
.live-who .avatar.big { width: 46px; height: 46px; font-size: 20px; margin: 0; flex: none; }
.live-who .tags { justify-content: flex-start; margin: 4px 0 0; }
.typing { margin: -8px 0 8px 4px; }

/* Theme button */
.theme-btn { background: var(--card); border: none; border-radius: 999px; padding: 4px 10px; font-size: 14px; line-height: 1.5; }
.theme-btn:hover { background: var(--main); }

/* Language menu */
.lang-pick select { appearance: none; -webkit-appearance: none; background: var(--card); color: var(--ink); border: none; border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13px; line-height: 1.5; cursor: pointer; }
.lang-pick select:hover { background: var(--main); }
