/* secureth — quiet, monochrome, one column. */

:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --ink: #0a0a0a;
  --ink-2: #6b6b73;
  --ink-3: #a1a1aa;
  --line: #ececef;
  --accent: #0a0a0a;
  --on-accent: #ffffff;
  --ok: #18794e;
  --warn: #b42318;
  --radius: 14px;
  --pad: 20px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #141417;
    --ink: #fafafa;
    --ink-2: #8e8e96;
    --ink-3: #5c5c64;
    --line: #1e1e22;
    --accent: #fafafa;
    --on-accent: #0a0a0a;
    --ok: #4ade80;
    --warn: #fca5a5;
  }
}

:root[data-theme="dark"] {
  --bg: #000000; --surface: #141417; --ink: #fafafa; --ink-2: #8e8e96;
  --ink-3: #5c5c64; --line: #1e1e22; --accent: #fafafa; --on-accent: #0a0a0a;
  --ok: #4ade80; --warn: #fca5a5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { overflow: hidden; }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 460px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

@media (min-width: 560px) and (min-height: 640px) {
  body { background: var(--surface); padding: 24px 0; }
  .app {
    height: calc(100% - 48px);
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--bg);
  }
}

h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.025em; }
h2 { margin: 0 0 6px; font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
p { margin: 0; }
.muted { color: var(--ink-2); font-size: 14px; }
.sub { display: block; color: var(--ink-2); font-size: 12.5px; letter-spacing: -0.005em; }
.sub.ok { color: var(--ok); }

.screen { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.screen[hidden] { display: none; }
.center { align-items: center; justify-content: center; }
.pad { padding: 0 var(--pad) max(var(--pad), env(safe-area-inset-bottom)); }

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

.mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
}

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

#auth { justify-content: center; gap: 36px; }
.auth-top { display: flex; flex-direction: column; gap: 14px; }
.auth-top h1 { margin-top: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.field {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}
.field::placeholder { color: var(--ink-3); }
.field:focus { border-color: var(--ink); }
.field[hidden] { display: none; }

.primary {
  height: 52px;
  margin-top: 6px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
}
.primary:disabled { opacity: .45; }
.primary:active { transform: scale(.995); }

.link {
  border: 0; background: none; color: var(--ink-2);
  font: inherit; font-size: 14px; padding: 12px; cursor: pointer;
}
.link:hover { color: var(--ink); }
.link[hidden] { display: none; }

.fineprint {
  color: var(--ink-3);
  font-size: 11.5px;
  letter-spacing: .01em;
  text-align: center;
}

/* --------------------------------------------------------------------- bar */

.bar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px;
  padding: max(18px, env(safe-area-inset-top)) var(--pad) 14px;
  border-bottom: 1px solid var(--line);
}
.bar-actions { display: flex; align-items: center; gap: 10px; }

.icon {
  display: grid; place-items: center;
  width: 36px; height: 36px; margin: -6px;
  border: 0; border-radius: 50%;
  background: none; color: var(--ink); cursor: pointer;
}
.icon:hover { background: var(--surface); }

.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-3);
}
.dot.on { background: var(--ok); }

/* ------------------------------------------------------------------- lists */

.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.row {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px var(--pad);
  border: 0; border-bottom: 1px solid var(--line);
  background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer;
}
.row:hover { background: var(--surface); }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.row-name { font-weight: 600; letter-spacing: -0.01em; }
.row-time { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.row-prev {
  color: var(--ink-2); font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 2px;
}

.avatar {
  flex: none;
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px; font-weight: 600; letter-spacing: .02em;
}

.empty { padding: 56px var(--pad); text-align: center; display: grid; gap: 6px; }
.empty p:first-child { font-weight: 600; letter-spacing: -0.01em; }

.fab {
  position: absolute; right: var(--pad); bottom: max(var(--pad), env(safe-area-inset-bottom));
  display: grid; place-items: center;
  width: 52px; height: 52px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  cursor: pointer;
}
.fab:active { transform: scale(.96); }

/* -------------------------------------------------------------------- chat */

.chat-bar { align-items: center; gap: 6px; padding-bottom: 12px; }
.peer {
  flex: 1; min-width: 0;
  border: 0; background: none; color: inherit;
  padding: 2px 6px; text-align: left; cursor: pointer;
}
.peer-name { display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }

.log {
  flex: 1; min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
  padding: 16px var(--pad) 8px;
}
/* Keep the conversation resting on the composer, as a short thread should. */
.log > *:first-child { margin-top: auto; }

.day {
  align-self: center;
  margin: 12px 0 10px;
  color: var(--ink-3);
  font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
}

.bubble {
  position: relative;
  max-width: 78%;
  padding: 9px 13px 9px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.38;
  word-wrap: break-word;
  white-space: pre-wrap;
  display: flex; align-items: flex-end; gap: 8px;
}
.bubble .text { min-width: 0; }
.bubble .stamp {
  flex: none;
  font-size: 10.5px; line-height: 1.6;
  font-variant-numeric: tabular-nums;
  opacity: .5;
}
.bubble.out {
  align-self: flex-end;
  background: var(--accent); color: var(--on-accent);
  border-bottom-right-radius: 5px;
}
.bubble.in {
  align-self: flex-start;
  background: var(--surface); color: var(--ink);
  border-bottom-left-radius: 5px;
}
.bubble.in + .bubble.in { border-top-left-radius: 7px; }
.bubble.out + .bubble.out { border-top-right-radius: 7px; }
.bubble.warn {
  background: none; color: var(--warn);
  border: 1px solid var(--line);
  align-self: center; max-width: 92%;
  font-size: 12.5px; text-align: center;
}

.composer {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 10px var(--pad) max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
#compose {
  flex: 1;
  min-height: 42px; max-height: 120px;
  padding: 11px 14px;
  border: 0; border-radius: 21px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px;
  resize: none; outline: none;
}
#compose::placeholder { color: var(--ink-3); }
.send {
  flex: none;
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  cursor: pointer;
}
.send:active { transform: scale(.94); }

/* ------------------------------------------------------------------ sheets */

.scrim {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 10;
}
.scrim[hidden], .sheet[hidden] { display: none; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  z-index: 11;
  display: flex; flex-direction: column; gap: 12px;
  padding: 10px var(--pad) max(20px, env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
  animation: rise .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes rise { from { transform: translateY(14px); opacity: .6; } }

.grab {
  align-self: center;
  width: 34px; height: 4px; margin-bottom: 8px;
  border-radius: 2px; background: var(--line);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 13px;
  border: 1px solid var(--line); border-radius: 999px;
  background: none; color: var(--ink);
  font: inherit; font-size: 13.5px; cursor: pointer;
}
.chip:hover { background: var(--surface); }

.safety {
  margin: 4px 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  font: 600 16px/1.75 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .06em;
  text-align: center;
  white-space: pre;
}

.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

.toast {
  position: absolute; left: var(--pad); right: var(--pad); bottom: 84px;
  z-index: 20;
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--ink); color: var(--bg);
  font-size: 13.5px; line-height: 1.35;
  text-align: center;
}
.toast[hidden] { display: none; }
