/* Pip PWA — design tokens mirror firmware ui_internal.h exactly.
   Fixed dark theme: the product is black-on-AMOLED everywhere. */

@font-face { font-family: Montserrat; font-weight: 400; font-display: swap;
  src: url(fonts/montserrat-400.woff2) format("woff2"); }
@font-face { font-family: Montserrat; font-weight: 600; font-display: swap;
  src: url(fonts/montserrat-600.woff2) format("woff2"); }
@font-face { font-family: Montserrat; font-weight: 700; font-display: swap;
  src: url(fonts/montserrat-700.woff2) format("woff2"); }

:root {
  --bg: #000000;        /* COL_BG      */
  --surface: #16161C;   /* COL_SURFACE */
  --surface2: #24242E;  /* COL_SURFACE2*/
  --text: #F2F0EA;      /* COL_TEXT    */
  --dim: #8B8B96;       /* COL_TEXT_DIM*/
  --accent: #FFB300;    /* COL_ACCENT  */
  --ok: #3DDC84;        /* COL_OK      */
  --danger: #FF5252;    /* COL_DANGER  */
  --fs-small: 16px; --fs-body: 20px; --fs-title: 28px; --fs-big: 40px;
  /* text sitting directly on the background; retinted when a theme is on */
  --onbg: var(--text); --onbg-dim: var(--dim);
}

/* background theme: body.themed only while a bg-showing screen is active
   (home/record - mirrors the device, which keeps settings etc. black) */
body.themed { --onbg: #fff; --onbg-dim: rgba(255, 255, 255, .78); }
body.themed.fg-black { --onbg: #000; --onbg-dim: rgba(0, 0, 0, .62); }
#bg { position: fixed; inset: 0; z-index: -1; display: none;
  background-position: center; background-size: cover;
  background-repeat: no-repeat; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Montserrat, system-ui, sans-serif; font-size: var(--fs-body);
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior-y: none;
  -webkit-user-select: none; user-select: none;
}

section { display: none; max-width: 480px; margin: 0 auto; padding: 0 16px 32px; }
section.on { display: block; }

h1 { font-size: var(--fs-title); font-weight: 600; }
.dim { color: var(--dim); }
.small { font-size: var(--fs-small); }

/* ---------- header (mk_header) ---------- */
header {
  display: flex; align-items: center; height: 56px; gap: 4px;
  margin: 0 -4px;
}
header .back { width: 64px; height: 56px; background: none; border: 0;
  color: var(--onbg); font-size: var(--fs-title); text-align: left;
  padding: 0 0 0 4px; }
header .title { flex: 1; text-align: center; font-size: var(--fs-title);
  font-weight: 600; color: var(--onbg); }
header .spacer { width: 64px; }
header .gear { width: 64px; height: 56px; background: none; border: 0;
  color: var(--onbg-dim); font-size: 24px; text-align: right;
  padding-right: 4px; }

/* ---------- wordmark (splash + login) ---------- */
.wordmark { display: flex; justify-content: center; align-items: baseline;
  gap: 3px; font-size: var(--fs-big); font-weight: 600; }
.wordmark .dot { width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); transform: translateY(-2px); }

#splash { position: fixed; inset: 0; background: var(--bg); z-index: 50;
  display: flex; flex-direction: column; justify-content: center;
  align-items: center; transition: opacity .4s; max-width: none; }
#splash.gone { opacity: 0; pointer-events: none; }
#splash .wordmark { margin-top: -56px; }
#splash .wordmark span { opacity: 0;
  animation: drop .45s cubic-bezier(.34,1.56,.64,1) forwards; }
#splash .wordmark span:nth-child(1) { animation-delay: .08s; }
#splash .wordmark span:nth-child(2) { animation-delay: .22s; }
#splash .wordmark span:nth-child(3) { animation-delay: .36s; }
#splash .wordmark .dot { opacity: 0; animation: dotdrop .65s ease-out .56s forwards; }
#splash .hello { position: absolute; bottom: 56px; color: var(--dim);
  font-size: var(--fs-title); opacity: 0;
  animation: rise .45s ease-out 1s forwards; }
@keyframes drop { from { opacity: 0; transform: translateY(-240px); }
  60% { opacity: 1; } to { opacity: 1; transform: translateY(0); } }
@keyframes dotdrop {
  0% { opacity: 0; transform: translateY(-260px); }
  18% { opacity: 1; }
  55% { transform: translateY(0); } 70% { transform: translateY(-34px); }
  85% { transform: translateY(0); } 93% { transform: translateY(-10px); }
  100% { opacity: 1; transform: translateY(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); } }

/* ---------- controls (mk_button: radius 16, h 64) ---------- */
button.btn {
  display: block; width: 100%; height: 64px; border: 0; border-radius: 16px;
  font-family: inherit; font-size: var(--fs-body); font-weight: 600;
  background: var(--surface2); color: var(--text); margin: 12px 0;
}
button.btn.accent { background: var(--accent); color: #000; }
button.btn.ok { background: var(--ok); color: #000; }
button.btn.danger { background: var(--danger); color: #000; }
button.btn.ghost { background: none; color: var(--dim); }
button:active { filter: brightness(1.15); }

input {
  display: block; width: 100%; height: 56px; border-radius: 16px;
  border: 1px solid var(--surface2); background: var(--surface2);
  color: var(--text); font-family: inherit; font-size: var(--fs-body);
  padding: 0 16px; margin: 12px 0;
}
input:focus { outline: 2px solid var(--accent); }

.card { background: var(--surface); border-radius: 16px; padding: 16px;
  margin: 14px 0; }

/* ---------- manage device (device admins) ---------- */
.mng-addrow { display: flex; gap: 10px; align-items: center; }
.mng-addrow .mng-input { flex: 1; margin: 12px 0; }
.mng-addrow .mng-add { width: 88px; height: 56px; margin: 12px 0; flex: none; }
.mng-contacts .msg { background: var(--surface2); }
.mng-err { min-height: 20px; }

/* ---------- home ---------- */
#hello { color: var(--onbg-dim); }
#scr-home h1 { color: var(--onbg-dim); }
#inbox-empty { color: var(--onbg-dim); }

/* contact grid mirrors the device home screen (ui_home.c): two columns of
   round avatar buttons, big initial inside, name underneath */
.contacts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px;
  justify-items: center; }
.contact { display: flex; flex-direction: column; align-items: center;
  gap: 8px; background: none; border: 0; padding: 0; color: var(--onbg);
  font-family: inherit; font-size: var(--fs-body); width: 100%; }
.contact .avatar { width: 104px; height: 104px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-big); font-weight: 600; color: var(--bg); }
.contact:active .avatar { filter: brightness(1.15); }
.contact .cname { white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 100%; }

.msg { display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: 16px; padding: 12px 14px;
  margin: 10px 0; border: 2px solid transparent;
  -webkit-touch-callout: none; }   /* long-press opens reactions, not iOS menu */
.msg.unheard { border-color: var(--accent); }
body.themed .msg { background: rgba(22, 22, 28, .82); }  /* faded over bg */
/* sender mini-avatar: colored circle with the sender's initial */
.msg .cdot { width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--bg); font-weight: 600; font-size: var(--fs-small); }
.msg .who { flex: 1; min-width: 0; }
.msg .who .name { font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.msg .who .meta { font-size: var(--fs-small); color: var(--dim); }
.msg.unheard .who .meta { color: var(--accent); }
.msg .play { width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--accent); color: #000; font-size: 20px; flex: none; }
.msg.playing .play { background: var(--surface2); color: var(--text); }
.msg .del { width: 40px; height: 52px; background: none; border: 0;
  color: var(--dim); font-size: 20px; flex: none; }

/* ---------- reactions ---------- */
/* recipient's own reaction on an inbox row */
.msg .react-badge { flex: none; background: var(--surface2);
  border-radius: 14px; padding: 4px 8px; font-size: 18px; }
.msg .react-badge.txt { font-size: 13px; font-weight: 700;
  color: var(--accent); }

/* long-press picker: bottom sheet with the 7 options */
#rsheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .6);
  z-index: 70; display: flex; align-items: flex-end; justify-content: center; }
#rsheet-panel { background: var(--surface2); border-radius: 20px 20px 0 0;
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  width: 100%; max-width: 480px; }
.ropt { width: 56px; height: 56px; border-radius: 50%; padding: 0;
  border: 2px solid transparent; background: var(--surface);
  font-size: 26px; font-family: inherit; }
.ropt.txt { width: auto; min-width: 56px; padding: 0 16px;
  border-radius: 28px; font-size: var(--fs-small); font-weight: 700;
  color: var(--accent); }
.ropt.sel { border-color: var(--accent); }

/* unseen reaction to a message you sent: chip on the contact tile */
.contact .avatar { position: relative; }
.rchip { position: absolute; top: -4px; right: -4px; min-width: 36px;
  height: 36px; padding: 0 8px; border-radius: 18px;
  background: var(--surface2); color: var(--text); display: flex;
  align-items: center; justify-content: center; font-size: 17px; }
.rchip.txt { font-size: 12px; font-weight: 700; color: var(--accent); }

/* ---------- peer recording indicator ---------- */
#peer-rec { align-items: center; gap: 8px; margin-top: 18px;
  color: var(--danger); font-size: var(--fs-small); font-weight: 600; }
.pdot { width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- record ---------- */
#recwrap { display: flex; flex-direction: column; align-items: center;
  padding-top: 24px; }
#rectimer { font-size: var(--fs-big); font-weight: 600; margin: 24px 0;
  font-variant-numeric: tabular-nums; color: var(--onbg); }
#rectimer.live { color: var(--danger); }
#recbtn { width: 160px; height: 160px; border-radius: 50%; border: 0;
  background: var(--accent); color: #000; font-size: var(--fs-body);
  font-weight: 700; font-family: inherit; touch-action: none;
  transition: transform .1s; }
#recbtn.rec { transform: scale(1.12); background: var(--danger); }
#rechint { color: var(--onbg-dim); font-size: var(--fs-small);
  margin-top: 22px; text-align: center; }
#preview { width: 100%; }

/* ---------- background picker (settings) ---------- */
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-opt { aspect-ratio: 368 / 448; border-radius: 12px; padding: 0;
  border: 3px solid transparent; color: var(--dim); font-family: inherit;
  font-size: var(--fs-small); font-weight: 600;
  background: var(--surface2) center/cover no-repeat; }
.theme-opt.sel { border-color: var(--accent); }

/* ---------- install instructions (install.html) ---------- */
.steps { counter-reset: s; padding: 0; margin: 16px 0; list-style: none; }
.steps li { counter-increment: s; display: flex; gap: 14px; margin: 18px 0;
  align-items: flex-start; }
/* one flex item for the whole sentence: without this every <b>/<svg>/text
   run becomes its own flex item and the gap scatters the line */
.steps li > span { flex: 1; min-width: 0; }
.steps li::before { content: counter(s); flex: none; width: 32px; height: 32px;
  border-radius: 50%; background: var(--surface2); color: var(--accent);
  font-weight: 700; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-small); }
.glyph { display: inline-block; vertical-align: -4px; }

/* ---------- toast (ui_toast) ---------- */
#toast { position: fixed; top: calc(12px + env(safe-area-inset-top));
  left: 20px; right: 20px; background: var(--surface2); border-radius: 14px;
  border: 2px solid var(--accent); padding: 14px; text-align: center;
  z-index: 60; transition: opacity .25s, transform .25s; opacity: 0;
  transform: translateY(-12px); pointer-events: none; max-width: 440px;
  margin: 0 auto; }
#toast.show { opacity: 1; transform: none; pointer-events: auto; }
#toast.ok { border-color: var(--ok); }
#toast.danger { border-color: var(--danger); }

.badge { display: inline-flex; min-width: 26px; height: 26px; padding: 0 7px;
  border-radius: 13px; background: var(--accent); color: #000;
  font-size: var(--fs-small); font-weight: 700; align-items: center;
  justify-content: center; margin-left: 8px; vertical-align: 2px; }
