:root {
  --bg: #f4f1ec;
  --panel: #fffdf9;
  --ink: #2b2620;
  --muted: #8a8278;
  --line: #e7e1d7;
  --soft: #f8f5ef;
  --mine: #f0e7f7;
  --mine-ink: #4a3a5c;
  --theirs: #e6eef4;
  --theirs-ink: #284152;
  --ai: #fbf5e9;
  --ai-line: #eadfc4;
  --ai-ink: #6b5a35;
  --accent: #c8654e;
  --accent-ink: #fff;
  --ok: #3f8f6b;
  --warn: #c0873a;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(43, 38, 32, .08);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- brand ---------- */

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(135deg, #d7a3c8, #8fb6cf);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px;
}
.brand__name { font-size: 20px; letter-spacing: .2px; }
.brand--sm .brand__mark { width: 32px; height: 32px; font-size: 16px; border-radius: 10px; }
.brand--sm .brand__name { font-size: 17px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; padding: 12px 22px;
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(200, 101, 78, .25); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }
.btn--big { padding: 15px 34px; font-size: 17px; border-radius: 16px; }
.btn--small { padding: 9px 16px; font-size: 14px; border-radius: 12px; }
.btn--ghost { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }

.link {
  border: none; background: none; color: var(--accent);
  font: inherit; cursor: pointer; padding: 4px 2px; border-radius: 6px;
}
.link:hover { text-decoration: underline; }

.note { font-size: 13px; color: var(--muted); min-height: 1em; }
.note.is-error { color: var(--accent); }

.field {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font: inherit; background: var(--soft); resize: none; color: var(--ink);
}
.field:focus { outline: none; border-color: #c9bda8; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- landing ---------- */

.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px; }
.top { padding: 22px 0; }

.landing { padding: 24px 0 60px; }
.hero { text-align: center; padding: 30px 0 44px; }
.hero h1 { font-size: 34px; line-height: 1.15; margin: 0 0 16px; letter-spacing: -.4px; }
.hero__sub { font-size: 17px; color: #5f584e; max-width: 560px; margin: 0 auto 26px; }
.hero__cta { margin-bottom: 12px; }
.hero__fine { font-size: 13px; color: var(--muted); margin-top: 14px; }

.how { margin-top: 30px; }
.how h2 { font-size: 20px; margin: 0 0 18px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps li {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px 16px 54px; position: relative; font-size: 15px;
}
.steps b { display: block; margin-bottom: 2px; }
.steps__n {
  position: absolute; left: 16px; top: 16px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--soft); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--accent);
}

.recent { margin-top: 34px; }
.recent h2 { font-size: 18px; margin: 0 0 12px; }
.recent__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recent__item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; color: var(--ink);
}
.recent__item:hover { text-decoration: none; border-color: #d7cfc2; }
.recent__meta { color: var(--muted); font-size: 13px; }

.foot { border-top: 1px solid var(--line); padding: 22px 0 40px; }
.foot p { font-size: 12.5px; color: var(--muted); margin: 0; }

/* ---------- room shell ---------- */

.page--room { background: var(--bg); }

.room {
  max-width: 560px; margin: 0 auto; min-height: 100vh;
  background: var(--panel); display: flex; flex-direction: column;
  box-shadow: 0 0 60px rgba(43, 38, 32, .06);
}

.rtop {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.rtop__sub { font-size: 12px; color: var(--muted); margin: 0; }
.rtop .brand { flex: none; }
.rtop__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.presence { font-size: 11.5px; color: var(--muted); text-align: right; max-width: 130px; }
.presence.is-online { color: var(--ok); }

/* menu */
.menu { position: relative; }
.menu__btn {
  border: 1px solid var(--line); background: var(--soft); color: var(--ink);
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 18px; line-height: 1;
}
.menu__btn:hover { border-color: #d7cfc2; }
.menu__pop {
  position: absolute; right: 0; top: 40px; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; min-width: 210px;
}
.menu__item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  font: inherit; padding: 10px 12px; border-radius: 8px; cursor: pointer; color: var(--ink);
}
.menu__item:hover { background: var(--soft); }
.menu__item--danger { color: var(--accent); }

/* ---------- feed ---------- */

.feed {
  flex: 1; overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex; flex-direction: column; gap: 14px;
}

.turn { display: flex; flex-direction: column; }
.turn--mine { align-items: flex-end; }
.turn--theirs { align-items: flex-start; }
.turn .msg { max-width: 82%; }

.bubble {
  padding: 11px 14px; border-radius: var(--radius); font-size: 15px; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word;
  animation: pop .28s ease;
}
.turn--mine .bubble { background: var(--mine); color: var(--mine-ink); border-bottom-right-radius: 5px; }
.turn--theirs .bubble { background: var(--theirs); color: var(--theirs-ink); border-bottom-left-radius: 5px; }
.turn--complaint.turn--theirs .bubble { box-shadow: inset 3px 0 0 var(--warn); }
.bubble--typing { background: var(--soft); color: var(--muted); }

@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.orig { margin: 5px 4px 0; font-size: 12px; color: var(--muted); }
.orig summary { cursor: pointer; font-style: italic; }
.orig p { margin: 6px 0 0; }
.orig__q { color: var(--warn); }

/* mediator coach note */
.coach {
  align-self: center; max-width: 94%;
  background: var(--ai); border: 1px solid var(--ai-line); border-radius: 14px;
  padding: 11px 14px; color: var(--ai-ink); animation: pop .28s ease;
}
.coach__who {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--warn); margin-bottom: 5px;
}
.coach__who::before {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, #e6c34d, #c8654e);
}
.coach__text { margin: 0; font-size: 14px; line-height: 1.5; }

/* alert */
.alert {
  align-self: center; max-width: 94%;
  background: #fbeeea; border: 1px solid #e9cdc4; border-radius: 14px; padding: 12px 14px;
}
.alert strong { display: block; color: var(--accent); margin-bottom: 4px; font-size: 13px; }
.alert p { margin: 0; font-size: 14px; }

/* ---------- cards (proposal / invite / link) ---------- */

.card {
  align-self: stretch; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.card__title { margin: 0 0 4px; font-weight: 700; font-size: 15px; }
.card__note { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.card__why { margin: 0 0 8px; font-size: 14px; color: var(--ai-ink); }
.card__ask { margin: 0 0 10px; font-size: 14.5px; font-weight: 600; }
.card.is-agreed { border-color: #bfe0cf; background: #f4faf6; }
.card.is-replaced { opacity: .6; }

.deal { margin: 0; display: grid; gap: 10px; }
.deal dt { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.deal dd { margin: 2px 0 0; font-size: 14.5px; }

.confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.vote {
  border: 1px solid #bfe0cf; background: #eef7f1; color: var(--ok);
  border-radius: 12px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.vote[aria-pressed="true"] { background: var(--ok); color: #fff; border-color: var(--ok); }
.vote:disabled { opacity: .5; cursor: default; }
.vote-state { font-size: 13px; color: var(--muted); }

.objection { margin-top: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }

.invite__row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.invite__link {
  flex: 1; min-width: 180px; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font: inherit; font-size: 13px; background: var(--soft); color: var(--ink);
}

.copy {
  border: 1px solid var(--line); background: var(--soft); color: var(--ink);
  border-radius: 12px; padding: 9px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
.copy:hover { border-color: #d7cfc2; }

/* ---------- composer ---------- */

.composer {
  position: sticky; bottom: 0; background: var(--panel);
  border-top: 1px solid var(--line); padding: 10px 12px 12px;
}
.composer__stance { padding: 4px 4px 10px; }
.stance__q { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.stance__row { display: flex; gap: 8px; }
.chip {
  flex: 1; padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--soft); font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; color: var(--ink); transition: transform .15s, box-shadow .15s;
}
.chip:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, .06); }
.chip:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }
.chip:nth-child(1) { border-color: #bfe0cf; color: var(--ok); }
.chip:nth-child(2) { border-color: #e4d0b3; color: var(--warn); }
.chip:nth-child(3) { border-color: #e4c3bb; color: var(--accent); }
.chip.is-on { color: #fff; }
.chip.is-on:nth-child(1) { background: var(--ok); border-color: var(--ok); }
.chip.is-on:nth-child(2) { background: var(--warn); border-color: var(--warn); }
.chip.is-on:nth-child(3) { background: var(--accent); border-color: var(--accent); }

.composer__row { display: flex; gap: 8px; align-items: flex-end; }
.composer__field {
  flex: 1; border: 1px solid var(--line); border-radius: 18px;
  padding: 11px 15px; font: inherit; font-size: 15px; resize: none;
  background: var(--soft); color: var(--ink); max-height: 160px; overflow-y: auto;
}
.composer__field:focus { outline: none; border-color: #c9bda8; }
.composer__send {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff; font-size: 18px; cursor: pointer;
}
.composer__send:disabled { opacity: .5; cursor: default; }

.composer__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 4px 0; flex-wrap: wrap;
}

/* ---------- typing indicator ---------- */

.typing { display: inline-flex; align-items: center; gap: 8px; }
.dots { display: inline-flex; gap: 3px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5;
  animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: .9; } }

.caret {
  display: inline-block; width: 2px; height: 1em; margin-left: 2px;
  background: currentColor; vertical-align: -2px; animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* ---------- gate ---------- */

.state {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.state__box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px 28px; max-width: 420px; text-align: center; box-shadow: var(--shadow);
}
.state__box h1 { font-size: 22px; margin: 0 0 10px; }
.state__box p { color: var(--muted); margin: 0 0 20px; }

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

@media (max-width: 600px) {
  .hero h1 { font-size: 27px; }
  .hero__sub { font-size: 16px; }
  .room { box-shadow: none; }
}
