:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #e4e9ee;
  --ink: #14212b;
  --muted: #5b6b78;
  --line: #cfd7de;
  --accent: #0e6b6b;
  --accent-ink: #ffffff;
  --seal: #b3261e;
  --mine: #dcefee;
  --radius: 6px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a22;
    --surface: #16242e;
    --surface-2: #1d2f3b;
    --ink: #e6edf2;
    --muted: #95a6b3;
    --line: #2b3f4d;
    --accent: #4fb8b0;
    --accent-ink: #06201e;
    --seal: #ff8a80;
    --mine: #17383a;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.fatal { margin: 2rem; padding: 1rem; border: 1px solid var(--seal); color: var(--seal); border-radius: var(--radius); }

/* ---------- buttons & inputs ---------- */
.btn {
  font: inherit; cursor: pointer; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  padding: .55rem .9rem; border-radius: var(--radius);
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
input, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .7rem; width: 100%;
}
textarea { resize: vertical; min-height: 3rem; max-height: 10rem; }

/* ---------- auth ---------- */
.auth { max-width: 880px; margin: 0 auto; padding: 4rem 1.25rem 2rem; }
.brand h1 { font: 700 2.6rem/1.1 Georgia, "Times New Roman", serif; letter-spacing: -.01em; }
.brand p { margin-top: .6rem; max-width: 56ch; color: var(--muted); }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; margin-top: 2rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.panel h2 { font: 600 1.15rem/1.3 Georgia, serif; }
.panel form { display: flex; flex-direction: column; gap: .9rem; }
.panel label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
.panel .btn { align-self: flex-start; }
.note { font-size: .85rem; color: var(--muted); }
.msg { margin-top: 1rem; min-height: 1.5rem; color: var(--seal); }
.msg.ok { color: var(--accent); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 320px 1fr; height: 100dvh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-top { padding: 1rem; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: .6rem; }
.me { display: flex; flex-direction: column; }
.lock { font-size: .8rem; color: var(--muted); }
.lock.open { color: var(--accent); }
.side-actions { display: flex; gap: .5rem; }
.side-search { padding: .75rem 1rem; display: flex; flex-direction: column; gap: .5rem; border-bottom: 1px solid var(--line); }
.check { display: flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--muted); }
.check input { width: auto; }
.users { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.users .empty { padding: 1rem; color: var(--muted); font-size: .9rem; }
.user {
  display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left;
  font: inherit; color: inherit; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: .8rem 1rem; cursor: pointer;
}
.user:hover { background: var(--surface-2); }
.user[aria-current="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--line); flex: none; }
.dot.on { background: #2ea36b; }
.user .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--seal); color: var(--surface); font-size: .75rem; font-weight: 700; min-width: 1.4rem; text-align: center; padding: 0 .4rem; border-radius: 1rem; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-top { display: flex; align-items: center; gap: .75rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.back { display: none; }
.peer { display: flex; flex-direction: column; min-width: 0; }
.sn { font: .75rem/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); overflow-wrap: anywhere; }
.warn { display: flex; align-items: center; gap: 1rem; justify-content: space-between; padding: .75rem 1.25rem; background: color-mix(in srgb, var(--seal) 14%, var(--surface)); border-bottom: 1px solid var(--seal); font-size: .9rem; }
.warn.info { background: var(--surface-2); border-bottom-color: var(--line); }
.thread { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.thread .empty { color: var(--muted); max-width: 46ch; margin: auto; text-align: center; }

.msg-item, .msg { position: relative; max-width: min(34rem, 85%); padding: .6rem .8rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.msg.mine { align-self: flex-end; background: var(--mine); }
.msg .meta { display: flex; gap: .6rem; font-size: .75rem; color: var(--muted); margin-bottom: .25rem; padding-right: 1.4rem; }
.msg .body { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.msg .plain { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .cipher { font: .8rem/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); overflow-wrap: anywhere; }
.msg.bad { border-color: var(--seal); }
.msg.bad .plain { color: var(--seal); }
.msg .icon { position: absolute; top: .3rem; right: .35rem; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .8rem; padding: .1rem .3rem; border-radius: 4px; }
.msg .icon:hover { color: var(--seal); }

.composer { display: flex; gap: .75rem; padding: .85rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface); align-items: flex-end; }

/* ---------- dialog & toast ---------- */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 1.5rem; width: min(26rem, 92vw); }
dialog::backdrop { background: rgba(6, 14, 20, .55); }
dialog form { display: flex; flex-direction: column; gap: .8rem; }
dialog h3 { font: 600 1.1rem/1.3 Georgia, serif; }
dialog p { color: var(--muted); font-size: .9rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: var(--radius); max-width: 90vw; z-index: 10; }
.toast.err { background: var(--seal); color: var(--surface); }

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  body.has-chat .side { display: none; }
  body:not(.has-chat) .chat { display: none; }
  .back { display: inline-block; }
  .brand h1 { font-size: 2.1rem; }
  .auth { padding-top: 2rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

a.btn { text-decoration: none; display: inline-block; }
.note a { color: var(--accent); }
.side-actions { flex-wrap: wrap; }

/* ---------- public board ---------- */
.board { max-width: 980px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.board-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.board-top h1 { font: 700 1.8rem/1.2 Georgia, "Times New Roman", serif; }
.board-top p { color: var(--muted); max-width: 60ch; margin-top: .35rem; }
.board-side { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; }
.board-side .row-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.board-tools { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 0; flex-wrap: wrap; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.feed .empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.row { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; align-items: center; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.row.for-me { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.row.bad { border-color: var(--seal); }
.row .meta { grid-column: 1 / -1; display: flex; gap: .75rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.row .meta .who { color: var(--ink); font-weight: 600; }
.row .meta .you { color: var(--accent); }
.row .cipher { font: .8rem/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); overflow-wrap: anywhere; cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.row .plain { white-space: pre-wrap; overflow-wrap: anywhere; }
.row.bad .plain { color: var(--seal); }
.more { display: block; margin: 1rem auto 0; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } .row .btn { justify-self: start; } .board-side { align-items: flex-start; } }

/* ---------- landing page ---------- */
.lp { background: var(--bg); }
.lp a { color: var(--accent); }
.lp a.btn { color: var(--ink); }
.lp a.btn.primary { color: var(--accent-ink); }
.lp-nav { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .75rem max(1.25rem, calc((100% - 980px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.lp-logo { font: 700 1.3rem/1 Georgia, "Times New Roman", serif; text-decoration: none; color: var(--ink) !important; }
.lp-nav nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; font-size: .9rem; }
.lp-nav nav a:not(.btn) { text-decoration: none; color: var(--muted); }
.lp-nav nav a:not(.btn):hover { color: var(--ink); }
main { max-width: 980px; margin: 0 auto; padding: 0 1.25rem 3rem; }
.lp-hero { padding: 4rem 0 2.5rem; }
.lp-badge { display: inline-block; font-size: .8rem; font-weight: 600; letter-spacing: .02em; padding: .3rem .7rem; border: 1px solid var(--seal); color: var(--seal); border-radius: 999px; margin-bottom: 1.25rem; }
.lp-hero h1 { font: 700 clamp(2.2rem, 6vw, 3.6rem)/1.08 Georgia, "Times New Roman", serif; letter-spacing: -.015em; max-width: 18ch; }
.lp-lede { font-size: 1.15rem; max-width: 60ch; margin-top: 1.1rem; color: var(--muted); }
.lp-cta { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.75rem 0 1rem; }
.lp-cta-center { justify-content: center; }
.lp-section { padding: 2.5rem 0; border-top: 1px solid var(--line); }
.lp-section > p, .lp-final > p { max-width: 68ch; margin-top: .9rem; }
.lp-section h2, .lp-final h2 { font: 700 1.7rem/1.2 Georgia, "Times New Roman", serif; }
.lp-h3 { font: 600 1.15rem/1.3 Georgia, serif; margin-top: 2rem; }
.lp-diagram { width: 100%; height: auto; margin: 1.75rem 0; }
.d-box { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.d-server { fill: var(--surface-2); }
.d-title { fill: var(--ink); font: 600 16px system-ui, sans-serif; }
.d-sub { fill: var(--muted); font: 13px system-ui, sans-serif; }
.d-key { fill: var(--accent); font: 600 13px system-ui, sans-serif; }
.d-code { fill: var(--ink); font: 14px ui-monospace, Menlo, Consolas, monospace; }
.d-line { stroke: var(--accent); stroke-width: 2; }
.d-arrowhead { fill: var(--accent); }
.lp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-top: 1rem; }
.lp-cols-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.lp-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.lp-card h3 { font: 600 1.05rem/1.3 Georgia, serif; margin-bottom: .4rem; }
.lp-card p { color: var(--muted); font-size: .95rem; }
.lp-card-accent { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.lp-steps { list-style: none; counter-reset: step; margin: 1.75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.lp-steps > li { counter-increment: step; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem 1.1rem 4rem; }
.lp-steps > li::before { content: counter(step); position: absolute; left: 1.1rem; top: 1.05rem; width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; display: grid; place-items: center; }
.lp-steps h3 { font: 600 1.1rem/1.3 Georgia, serif; margin-bottom: .35rem; }
.lp-steps p + p { margin-top: .5rem; }
.lp-tech { font-size: .85rem; color: var(--muted); padding-left: .75rem; border-left: 2px solid var(--line); }
.lp-tablewrap { overflow-x: auto; margin-top: 1rem; }
.lp-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); font-size: .95rem; }
.lp-table th, .lp-table td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.lp-table th { background: var(--surface-2); font-weight: 600; }
.lp-try { margin: 1rem 0 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: .5rem; max-width: 68ch; }
.lp-warn { max-width: 68ch; margin-top: 1rem; padding: .85rem 1rem; border: 1px solid var(--seal); border-radius: var(--radius); background: color-mix(in srgb, var(--seal) 10%, var(--surface)); }
.lp-faq { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-top: .6rem; padding: .75rem 1rem; max-width: 68ch; }
.lp-faq summary { cursor: pointer; font-weight: 600; }
.lp-faq p { margin-top: .6rem; color: var(--muted); }
.lp-final { text-align: center; padding: 3rem 0 1rem; border-top: 1px solid var(--line); }
.lp-final > p { margin-left: auto; margin-right: auto; }
.lp-foot { padding: 1.5rem 1.25rem 2.5rem; text-align: center; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }
.lp-foot p { max-width: 60ch; margin: 0 auto; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media (max-width: 560px) { .lp-steps > li { padding-left: 1.25rem; padding-top: 3.2rem; } .lp-nav nav a:not(.btn) { display: none; } }
