/* Brand font: Zekton Regular (Typodermic). A web licence is needed before public hosting, see goodwebsitedesign.md */
@font-face {
  font-family: "3ncrypt";
  src: url("fonts/3ncrypt-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/*
 * Minimal by design: flat colours, no gradients, glows or shadows.
 * Gold is reserved for the brand Ǝ, links, focus rings and "active / unread" markers.
 * Borders only where accessibility needs them (form inputs, WCAG 1.4.11).
 */
:root {
  --bg: #120b0d;          /* not pure black */
  --surface: #1b1114;     /* raised areas are slightly lighter instead of shadowed */
  --surface-2: #26171c;
  --line: #2c1b21;        /* quiet dividers */
  --control: #84606a;     /* input borders: ≥3:1 on every surface */
  --burgundy: #6e1a2e;
  --burgundy-hover: #7d2037;
  --gold: #d4af37;
  --text: #f1e7e9;        /* off-white */
  --muted: #a8939a;       /* ≥6:1 */
  --danger: #e2546d;
  --font: "3ncrypt", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --tap: 40px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); letter-spacing: .01em; -webkit-font-smoothing: antialiased; }
a { color: var(--gold); text-decoration: underline; text-decoration-color: rgba(212, 175, 55, .35); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--gold); }
b, strong { font-weight: 400; color: var(--text); }
h1, h2, h3 { font-weight: 400; }
.hidden { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- focus & a11y ---------- */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; border-radius: 8px; background: var(--gold); color: #1a0c04; text-decoration: none; transform: translateY(-200%); }
.skip-link:focus { transform: none; }
.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; }

/* ---------- brand: gold mirrored E + "ncrypted", nothing else ---------- */
.wordmark { display: inline-flex; align-items: baseline; margin: 0; font-size: 22px; letter-spacing: .03em; color: var(--text); white-space: nowrap; }
.wordmark .e { display: inline-block; color: var(--gold); transform: scaleX(-1); }
.wordmark.big { font-size: 40px; }
.wordmark.inline { font-size: inherit; letter-spacing: inherit; }
.empty-logo { display: block; margin: 0 auto 16px; } /* no border-radius: the logo has its own rounded corners */
/* header on the legal pages: logo + wordmark, links home */
.legal-brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.legal-brand img { display: block; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; background: var(--surface-2); color: var(--text);
  min-height: var(--tap); padding: 8px 16px; border-radius: 8px; font: inherit; letter-spacing: .03em; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; transition: background .15s, color .15s;
}
.btn:hover { background: #321e25; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--burgundy); color: var(--text); }
.btn.primary:hover { background: var(--burgundy-hover); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); padding-left: 10px; padding-right: 10px; }
.btn.danger:hover { background: #2a1015; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.icon-btn { appearance: none; background: none; border: 0; color: var(--muted); width: var(--tap); height: var(--tap); border-radius: 8px; cursor: pointer; display: grid; place-items: center; flex: none; }
.icon-btn:hover { color: var(--text); background: var(--surface); }

/* ---------- forms ---------- */
input, textarea, select {
  width: 100%; background: transparent; color: var(--text); border: 1px solid var(--control); border-radius: 8px;
  min-height: 44px; padding: 10px 12px; font: inherit; font-size: 16px; /* no iOS zoom */
}
select { background: var(--bg); }
input:focus, textarea:focus, select:focus { border-color: var(--gold); outline: none; }
input::placeholder, textarea::placeholder { color: #8d7880; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; flex: none; accent-color: var(--burgundy); margin: 2px 0 0; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
label.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); }
.hint { color: var(--muted); font-size: 13px; margin-top: -6px; }
.warn { background: var(--surface); color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.form { display: grid; gap: 14px; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }
.form-error:not(:empty)::before { content: "⚠ "; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.row.end { justify-content: flex-end; }
.row.selects { align-items: flex-end; }
.row.selects > label, .row.selects > select, .row.selects > input { flex: 1 1 140px; width: auto; min-width: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.pw { position: relative; display: block; }
.pw input { padding-right: 70px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 36px; padding: 0 10px; background: none; border: 0; border-radius: 6px; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.pw-toggle:hover { color: var(--text); }

/* ---------- auth: no card, just a centred column ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .wordmark { display: flex; justify-content: center; }
.tagline { text-align: center; color: var(--muted); margin: 8px 0 28px; font-size: 15px; }
.tabs { display: flex; gap: 24px; justify-content: center; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tab { appearance: none; border: 0; background: none; color: var(--muted); min-height: 44px; padding: 0 2px; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-selected=true] { color: var(--text); border-bottom-color: var(--gold); }
.auth-foot { text-align: center; margin-top: 24px; font-size: 13px; color: var(--muted); }

/* ---------- app layout ---------- */
.app { display: grid; grid-template-columns: 280px 1fr; height: 100%; height: 100dvh; }
.sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 10px 2px 16px; }
.side-head .tools { display: flex; }
.me-line { padding: 0 16px; color: var(--muted); font-size: 13px; }
.side-actions { display: flex; gap: 8px; padding: 14px 16px 10px; }
.side-actions .btn { flex: 1; }
.side-scroll { overflow-y: auto; flex: 1; padding: 0 8px 12px; }
.side-title { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 18px 10px 4px; }
.side-foot { padding: 12px 16px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.link-btn { appearance: none; background: none; border: 0; padding: 0; min-height: 24px; color: var(--gold); font: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(212, 175, 55, .35); text-underline-offset: 3px; }
.link-btn:hover { text-decoration-color: var(--gold); }
/* installed app on phones: keep content clear of the notch / home indicator */
@supports (padding: env(safe-area-inset-bottom)) {
  .composer, .side-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.list li { display: flex; align-items: center; gap: 8px; border-radius: 8px; }
.list li.req { padding: 4px 10px; min-height: 48px; }
.item { appearance: none; background: none; border: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 8px; }
.item:hover { background: var(--surface); }
.item[aria-current=true] { background: var(--surface); box-shadow: inset 2px 0 0 var(--gold); }
.list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .empty-note { color: var(--muted); font-size: 14px; padding: 6px 10px; }
.group-mark { color: var(--muted); width: 1em; text-align: center; flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; }
.req-actions { display: flex; gap: 4px; }

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.conn-bar { background: var(--surface-2); color: var(--text); text-align: center; font-size: 14px; padding: 6px 12px; }
.empty { flex: 1; display: grid; place-items: center; text-align: center; padding: 24px; }
.empty h2 { margin: 0 0 6px; font-size: 22px; }
.empty p { color: var(--muted); max-width: 44ch; margin: 0 auto 18px; }
.conv { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.conv-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.conv-title { flex: 1; min-width: 0; }
#conv-name { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.sub { font-size: 13px; color: var(--muted); }
.back { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 3px; }
.msg { max-width: min(72%, 560px); display: flex; flex-direction: column; align-self: flex-start; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.burst-end { margin-bottom: 8px; } /* messages in one burst sit close together */
.msg .who { font-size: 13px; color: var(--muted); margin: 6px 4px 2px; }
.msg-row { display: flex; align-items: center; gap: 4px; max-width: 100%; }
.msg.mine .msg-row { flex-direction: row-reverse; } /* delete button on the inner side */
.bubble { background: var(--surface-2); padding: 7px 12px; border-radius: 12px; line-height: 1.45; min-width: 0; }
.bubble .text { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--burgundy); }
.bubble.broken .text { font-style: italic; color: var(--muted); }
/* time sits in the bubble's bottom corner that faces the other person */
.stamp { display: block; font-size: 11px; line-height: 1; margin-top: 3px; color: var(--muted); text-align: right; }
.msg.mine .stamp { text-align: left; color: #d6bcc4; }
.del { appearance: none; background: none; border: 0; color: var(--muted); cursor: pointer; width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; flex: none; opacity: 0; }
.del svg { width: 16px; height: 16px; }
.msg:hover .del, .del:focus-visible { opacity: 1; }
.del:hover { color: var(--danger); background: var(--surface); }
.day { align-self: center; font-size: 12px; color: var(--muted); margin: 14px 0 6px; text-align: center; }
.load-more { align-self: center; margin-bottom: 8px; }
.composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { resize: none; max-height: 160px; overflow-y: hidden; line-height: 1.4; }
.composer .btn { min-height: 44px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(8, 4, 5, .78); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-card { position: relative; width: 100%; max-width: 460px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border-radius: 12px; padding: 24px 22px; }
.modal-close { position: absolute; top: 8px; right: 8px; }
.modal h2 { margin: 0 40px 14px 0; font-size: 22px; line-height: 1.25; }
.modal h3 { margin: 22px 0 8px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.modal p { color: var(--muted); margin: 0 0 12px; font-size: 15px; }
.modal .stack { display: grid; gap: 12px; }
.modal ol, .modal ul.help { color: var(--muted); padding-left: 20px; margin: 0 0 12px; font-size: 15px; }
.modal li + li { margin-top: 4px; }
kbd { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border-radius: 4px; padding: 1px 6px; color: var(--text); }
.qr { background: #fff; padding: 12px; border-radius: 8px; width: 216px; max-width: 100%; margin: 8px auto 12px; }
.qr svg { width: 100%; height: auto; display: block; }
.linkbox { display: flex; gap: 8px; align-items: center; }
.linkbox input { font-family: var(--mono); font-size: 14px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: var(--mono); background: var(--bg); padding: 12px; border-radius: 8px; }
.safety { font-family: var(--mono); font-size: 18px; letter-spacing: 1px; text-align: center; background: var(--bg); padding: 12px; border-radius: 8px; }
.members { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.members li { display: flex; align-items: center; gap: 10px; padding: 6px 0; min-height: 44px; }
.members .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tag { font-size: 13px; color: var(--muted); }
.secret { word-break: break-all; text-align: center; font-family: var(--mono); font-size: 14px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ---------- toast / loading ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--surface-2); color: var(--text); padding: 10px 16px; border-radius: 8px; z-index: 40; max-width: calc(100% - 32px); }
.toast.error::before { content: "⚠ "; color: var(--danger); }
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(8, 4, 5, .6); z-index: 50; }
.spinner { width: 32px; height: 32px; border: 2px solid var(--surface-2); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- legal pages ---------- */
.legal { max-width: 68ch; margin: 0 auto; padding: 40px 16px 80px; line-height: 1.65; }
.legal h1 { font-size: 34px; margin: 24px 0 4px; line-height: 1.2; }
.legal h2 { margin-top: 36px; font-size: 22px; line-height: 1.25; }
.legal p, .legal li { color: #ddd0d3; }
.legal li + li { margin-top: 6px; }
.legal .table-wrap { overflow-x: auto; margin: 12px 0; }
.legal table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; line-height: 1.5; }
.legal th, .legal td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.legal th { color: var(--muted); font-weight: 400; }
.legal .updated { color: var(--muted); font-size: 14px; }
.legal .callout { background: var(--surface); padding: 12px 16px; border-radius: 8px; }
.legal code { font-family: var(--mono); font-size: 14px; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  :root { --tap: 44px; }
  .btn.small { min-height: 44px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; }
  .app .chat { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .chat { display: flex; }
  .back { display: grid; }
  .msg { max-width: 86%; }
  .del { opacity: .7; width: 36px; height: 36px; } /* no hover on touch screens */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 1.5s !important; scroll-behavior: auto !important; }
}

/* download-the-app button */
.install-btn { width: 100%; margin-top: 16px; }
.side-foot .install-btn { margin: 0 0 10px; }

/* screenshot deterrent: content hidden when the window isn't focused, during screenshot keys and when printing */
.shield { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--bg); color: var(--muted); text-align: center; padding: 16px; }
.shield.hidden { display: none; }
body.shielded > :not(.shield) { filter: blur(24px); }
@media print { body > * { display: none !important; } body::after { content: "Printing is disabled."; display: block; padding: 40px; color: #000; } }
