/* nulltext — barebones. PT Sans, one accent, square corners, light and dark.
   No gradients, no shadows, no animation beyond the cursor. */

@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/pt-sans-400.woff2') format('woff2');
}
@font-face {
  font-family: 'PT Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/pt-sans-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Ubuntu';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/ubuntu-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Ubuntu';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/ubuntu-700.woff2') format('woff2');
}
/* Roboto ships as a variable font, so one file covers every weight. */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/roboto-400.woff2') format('woff2');
}

/* Dark is the default. Light is applied when the system asks for it, and either can be
   forced by the toggle, which stamps data-theme on the root element. */
:root {
  --bg: #0b0b0d;
  --panel: #101013;
  --text: #ececed;
  --dim: #85858d;
  --line: #26262b;
  --accent: #00c97b;
  --bad: #ff6b60;
  --warn: #e0a44a;
  --mine: #14211c;
  --bubble: #1b1b20;
  --bubble-text: #ececed;
  --bubble-mine: #00c97b;
  --bubble-mine-text: #05130d;

  --sans: 'PT Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

/* Typeface choice. `system` deliberately names no file: it resolves to whatever the
   operating system already uses, so it costs nothing to download and looks native. */
:root[data-font='system'] {
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif;
}
:root[data-font='mono'] { --sans: var(--mono); }
:root[data-font='ubuntu'] { --sans: 'Ubuntu', -apple-system, sans-serif; }
:root[data-font='roboto'] { --sans: 'Roboto', -apple-system, sans-serif; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #ffffff;
    --panel: #f6f6f4;
    --text: #16161a;
    --dim: #6b6b74;
    --line: #dcdcd8;
    --accent: #00794a;
    --bad: #c0332a;
    --warn: #8a5d10;
    --mine: #eaf5ef;
    --bubble: #ececea;
    --bubble-text: #16161a;
    --bubble-mine: #00794a;
    --bubble-mine-text: #ffffff;
  }
}

:root[data-theme='light'] {
  --bg: #ffffff;
  --panel: #f6f6f4;
  --text: #16161a;
  --dim: #6b6b74;
  --line: #dcdcd8;
  --accent: #00794a;
  --bad: #c0332a;
  --warn: #8a5d10;
  --mine: #eaf5ef;
  --bubble: #ececea;
  --bubble-text: #16161a;
  --bubble-mine: #00794a;
  --bubble-mine-text: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* The safety code stays monospace — the whole point is reading it character by
   character to someone else, and a proportional font makes that harder. */
.fp-words, code { font-family: var(--mono); font-size: 0.9em; }

.cursor { color: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }

/* -------------------------------------------------------------------- controls */

button { background: none; border: 1px solid transparent; cursor: pointer; padding: 0; }

button.primary {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0.5rem 1rem;
  width: 100%;
}
button.primary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button.primary:disabled { opacity: 0.45; cursor: default; }

button.link, a.link {
  color: var(--dim);
  text-align: left;
  padding: 0.1rem 0;
  text-decoration: none;
}
button.link:hover, a.link:hover { color: var(--accent); text-decoration: underline; }
button.link.danger:hover { color: var(--bad); }

input, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 0.5rem 0.65rem;
  outline: none;
  resize: none;
  border-radius: 0;
}
input:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--dim); opacity: 0.7; }

/* ------------------------------------------------------------------ auth view */

.auth {
  max-width: 21rem;
  margin: 0 auto;
  padding: 14vh 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.logo { width: 100%; max-width: 17rem; height: auto; display: block; border-radius: 0.4rem; }
.wordmark { font-size: 1.5rem; font-weight: 700; margin: 0; }
.tagline { color: var(--dim); margin: 0 0 1.1rem; font-size: 0.9rem; }

.creed {
  color: var(--dim);
  font-size: 0.8rem;
  line-height: 1.6;
  margin: 1.4rem 0 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--line);
}

.attribution { color: var(--dim); font-size: 0.8rem; margin: 0.9rem 0 0; }

.warn {
  color: var(--warn);
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0.1rem 0;
  border-left: 2px solid var(--warn);
  padding-left: 0.6rem;
}

.footlink { color: var(--dim); font-size: 0.8rem; margin-top: 1.1rem; display: inline-block; }

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

#app.shell { display: grid; grid-template-columns: 15rem 1fr; height: 100%; }

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.brand { padding: 0.8rem 0.9rem; border-bottom: 1px solid var(--line); }
.logo-sm { width: 100%; max-width: 10rem; height: auto; display: block; border-radius: 0.3rem; }
.wordmark-sm { font-size: 1.05rem; font-weight: 700; display: block; }
.me { color: var(--dim); font-size: 0.85rem; }

.actions {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.rooms { flex: 1; overflow-y: auto; min-height: 0; padding: 0.3rem 0; }

.room {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.9rem;
  color: var(--text);
  border-left: 2px solid transparent;
}
.room:hover { border-left-color: var(--line); }
.room.active { border-left-color: var(--accent); font-weight: 700; }
.room-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-kind { color: var(--dim); font-size: 0.8rem; flex: none; }
.room-unread { color: var(--accent); font-size: 0.8rem; flex: none; }

.sidefoot {
  border-top: 1px solid var(--line);
  padding: 0.55rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

/* ---------------------------------------------------------------------- main */

main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.placeholder { margin: auto; text-align: center; color: var(--dim); max-width: 26rem; padding: 1.25rem; }

.room-header { border-bottom: 1px solid var(--line); padding: 0.75rem 1.1rem; }
.room-title { display: flex; align-items: baseline; gap: 0.9rem; }
.room-title h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }

.fingerprint {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
  font-size: 0.85rem;
}
.fp-label { color: var(--dim); }
.fingerprint.ok .fp-words { color: var(--accent); }
.fp-tick { color: var(--accent); }

.hint { color: var(--dim); font-size: 0.8rem; margin: 0.35rem 0 0; line-height: 1.5; max-width: 46rem; }

.alarm {
  margin-top: 0.5rem;
  border: 1px solid var(--bad);
  color: var(--bad);
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
}

/* ------------------------------------------------------------------ messages */

.messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.empty { color: var(--dim); margin: auto; }

/* Chat bubbles: rounded, tucked into the corner on the sender's side. */
.msg { max-width: min(34rem, 78%); }
.msg.mine { align-self: flex-end; }

.msg .meta { font-size: 0.75rem; color: var(--dim); display: flex; gap: 0.45rem; padding: 0 0.5rem; }
.msg.mine .meta { justify-content: flex-end; }
.msg.mine .who { color: var(--accent); }

.msg .body {
  display: inline-block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 0.45rem 0.75rem;
  margin-top: 0.15rem;
  background: var(--bubble);
  color: var(--bubble-text);
  border-radius: 1.1rem;
  border-bottom-left-radius: 0.25rem;   /* the "tail" corner */
}
.msg.mine .body {
  background: var(--bubble-mine);
  color: var(--bubble-mine-text);
  border-bottom-left-radius: 1.1rem;
  border-bottom-right-radius: 0.25rem;
}

.undecryptable {
  display: inline-block;
  color: var(--warn);
  border: 1px dashed var(--warn);
  padding: 0.45rem 0.75rem;
  margin-top: 0.15rem;
  font-size: 0.85rem;
  border-radius: 1.1rem;
}

/* read receipts */
.receipt { font-size: 0.75rem; color: var(--dim); margin-top: 0.1rem; }
.msg.mine .receipt { text-align: right; }

/* reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.2rem; }
.msg.mine .reactions { justify-content: flex-end; }

.reaction {
  border: 1px solid var(--line);
  padding: 0 0.35rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
.reaction:hover { border-color: var(--accent); }
.reaction.mine { border-color: var(--accent); color: var(--accent); }

.react-open { color: var(--dim); font-size: 0.85rem; padding: 0 0.3rem; border: 1px solid transparent; }
.react-open:hover { color: var(--accent); border-color: var(--line); }

.react-picker { display: flex; gap: 0.15rem; }
.react-picker button { font-size: 1rem; padding: 0 0.25rem; border: 1px solid var(--line); }
.react-picker button:hover { border-color: var(--accent); }

/* attachments */
.attachment { margin-top: 0.2rem; font-size: 0.85rem; }
.msg.mine .attachment { text-align: right; }
.attach-img {
  max-width: min(22rem, 100%);
  max-height: 20rem;
  display: block;
  margin-top: 0.2rem;
  border: 1px solid var(--line);
}
.msg.mine .attach-img { margin-left: auto; }

/* device linking */
.bigcode {
  font-family: var(--mono);
  font-size: 1.9rem;
  letter-spacing: 0.12em;
  text-align: center;
  padding: 0.7rem 0.4rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  margin-top: 0.5rem;
  user-select: all;
}
.bigcode.dead { border-color: var(--line); color: var(--dim); text-decoration: line-through; }
.code-out { display: flex; flex-direction: column; gap: 0.2rem; }
.plate { font-size: 1.1rem; letter-spacing: 0.08em; user-select: all; }

/* burn / disappearing */
.burn { font-size: 0.75rem; color: var(--warn); margin-top: 0.1rem; }
.msg.mine .burn { text-align: right; }

/* typing */
.typing {
  padding: 0 1.1rem;
  height: 1.2rem;
  font-size: 0.8rem;
  color: var(--dim);
  font-style: italic;
}

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

.composer { border-top: 1px solid var(--line); padding: 0.65rem 1.1rem; }
.composer-row { display: flex; gap: 0.55rem; align-items: flex-end; }
.composer textarea { flex: 1; max-height: 10rem; }
.composer button.primary { width: auto; flex: none; }
.composer-opts { display: flex; gap: 0.7rem; align-items: center; margin-top: 0.4rem; flex-wrap: wrap; }
.hint.inline { margin: 0; }

/* Custom dropdown. Native <select> menus cannot be styled on most platforms, so the
   list is built from real buttons instead — which also means it looks identical in
   every browser and inherits the chosen typeface. */
.dd { position: relative; display: inline-block; }

.dd-button {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  padding: 0.25rem 0.55rem;
  font-size: 0.85rem;
  border-radius: 0.35rem;
  white-space: nowrap;
}
.dd-button:hover { border-color: var(--accent); }
.dd-button .caret { color: var(--dim); font-size: 0.65rem; }
.dd.small .dd-button { font-size: 0.8rem; color: var(--dim); padding: 0.15rem 0.45rem; }

.dd-menu {
  position: absolute;
  z-index: 50;
  min-width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  padding: 0.2rem;
  display: flex;
  flex-direction: column;
  max-height: 15rem;
  overflow-y: auto;
}
.dd-menu.up { bottom: calc(100% + 0.25rem); }
.dd-menu.down { top: calc(100% + 0.25rem); }

.dd-option {
  text-align: left;
  padding: 0.3rem 0.5rem;
  border-radius: 0.25rem;
  color: var(--text);
  font-size: 0.85rem;
  white-space: nowrap;
}
.dd-option:hover { background: var(--panel); }
.dd-option[aria-selected='true'] { color: var(--accent); }
.dd-option[aria-selected='true']::after { content: ' ✓'; }

/* settings dialog rows */
.field { display: flex; justify-content: space-between; align-items: center; gap: 0.7rem; }
.field-block { display: flex; flex-direction: column; gap: 0.15rem; }
.field-label { font-weight: 700; }
.rule { border: none; border-top: 1px solid var(--line); margin: 0.4rem 0; width: 100%; }

/* ------------------------------------------------------------------- dialogs */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 20;
}

.dialog {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 1rem;
  width: 100%;
  max-width: 24rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.dialog h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.dialog-buttons { display: flex; gap: 0.7rem; align-items: center; margin-top: 0.15rem; }
.dialog-buttons .primary { width: auto; }

.members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.members li { display: flex; justify-content: space-between; gap: 0.7rem; align-items: center; }

/* ------------------------------------------------------------ status / toast */

#status {
  position: fixed;
  bottom: 0.5rem;
  right: 0.9rem;
  font-size: 0.8rem;
  color: var(--dim);
  background: var(--bg);
  padding: 0.1rem 0.4rem;
  z-index: 15;
  pointer-events: none;
}
#status:empty { display: none; }

#toast {
  position: fixed;
  bottom: 0.9rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 32rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--bad);
  background: var(--bg);
  color: var(--bad);
  font-size: 0.85rem;
  opacity: 0;
  visibility: hidden;
  z-index: 30;
}
#toast.show { opacity: 1; visibility: visible; }

/* -------------------------------------------------------------------- mobile */

@media (max-width: 44rem) {
  #app.shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .msg { max-width: 100%; }
}

/* ----------------------------------------------------------------- prose page */

.prose { max-width: 40rem; margin: 0 auto; padding: 3rem 1.25rem 5rem; }
.prose h1 { font-size: 1.4rem; font-weight: 700; margin: 0 0 0.3rem; }
.prose h2 { font-size: 1.05rem; font-weight: 700; margin: 2.2rem 0 0.5rem; color: var(--accent); }
.prose p, .prose li { margin: 0.6rem 0; }
.prose li { margin: 0.3rem 0; }
.prose strong { font-weight: 700; }
.prose .lede { color: var(--dim); margin-bottom: 2rem; }
.prose ul { padding-left: 1.15rem; }
.prose .creed { margin: 1.5rem 0; font-size: 0.95rem; }

/* ------------------------------------------------------------- theme toggle */

.theme-toggle { position: fixed; top: 0.6rem; right: 0.8rem; z-index: 40; font-size: 0.8rem; }
