/*
 * Pointview's look, from the Pointview Brand Guide: the four brand colours,
 * the status colours, Inter, the type scale, spacing and radii. Everything
 * else in the pages uses these names, so the look changes here and only here.
 *
 * Ochre means "you" and nothing else: your own avatar, and the conversation
 * you are in. Never buttons, links, badges, warnings or errors.
 */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/ui/inter.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;

  --bg: #FAF7F1;            /* Pointview Paper */
  --surface: #FFFDF9;       /* cards, sheets */
  --line: #E8E2D6;          /* the hairline round cards, and dividers */
  --text: #1F1E1C;          /* Pointview Charcoal */
  --text-2: #5E5B55;        /* secondary text */
  --on-text: #FAF7F1;       /* words on a text-coloured fill (primary buttons, badges) */
  --you: #C8912E;           /* Pointview Ochre: graphics only on light backgrounds */
  --error: #A33A2A;         /* Brick */
  --warning: #A8501C;       /* Rust */
  --success: #56662A;       /* Olive */
  --selected: #F1ECE2;      /* the open conversation in the list */
  --bubble-mine: #EFE9DE;
  --card-border: 1px solid var(--line);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Spacing: 4 px steps. */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px; --s12: 48px; --s16: 64px;
  --edge: 16px;             /* screen edges: 16 on the phone, 24 on the desktop */

  --r-chip: 6px; --r-control: 10px; --r-card: 16px;
}

/* Dark: when the person picks Dark, or picks System on a device set to dark.
 * theme.js decides and sets <html data-theme>; nothing here reads the device. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1F1E1C;
  --surface: #2A2926;
  --line: #3A3834;
  --text: #F2EDE4;        /* Pointview Cream */
  --text-2: #A8A398;
  --on-text: #1F1E1C;
  --error: #EC7B68;
  --warning: #E2895A;
  --success: #A9BA6E;
  --selected: #2E2D2A;
  --bubble-mine: #35332F;
  --card-border: 1px solid transparent; /* dark cards are one step lighter, no border */
}

@media (min-width: 720px) {
  :root { --edge: 24px; }
}

/* ---- Type ------------------------------------------------------------------ */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/24px var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, .t-title { font-size: 24px; line-height: 32px; font-weight: 600; margin: 0; }
h2, .t-heading { font-size: 20px; line-height: 28px; font-weight: 500; margin: 0 0 var(--s3); }
h3 { font-size: 16px; line-height: 24px; font-weight: 600; margin: var(--s4) 0 var(--s2); }
.t-display { font-size: 32px; line-height: 40px; font-weight: 600; }
.t-label, label { font-size: 14px; line-height: 20px; font-weight: 500; }
.note, .t-caption { font-size: 13px; line-height: 18px; color: var(--text-2); }
p { margin: 0 0 var(--s3); }

a { color: inherit; text-underline-offset: 2px; }

/* A status is always its colour and its symbol, so it reads without the colour. */
.error { color: var(--error); font-size: 14px; line-height: 20px; }
.error:not(:empty)::before { content: '✕ '; }
.warning { color: var(--warning); font-size: 14px; line-height: 20px; }
.warning:not(:empty)::before { content: '! '; }
.success { color: var(--success); }

[hidden] { display: none !important; }

/* ---- Controls -------------------------------------------------------------- */

button, a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 40px; padding: 0 var(--s4);
  border: 1px solid var(--line); border-radius: var(--r-control);
  background: var(--surface); color: var(--text);
  font: 500 14px/20px var(--font); text-decoration: none; cursor: pointer;
}
button:hover, a.button:hover { border-color: var(--text-2); }
button.primary, a.button.primary { background: var(--text); color: var(--on-text); border-color: var(--text); }
button.quiet, a.button.quiet { background: none; border-color: transparent; }
button.small { min-height: 32px; padding: 0 var(--s3); }
button[disabled] { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

input, textarea {
  font: 400 16px/24px var(--font); color: var(--text);
  width: 100%; padding: var(--s2) var(--s3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control);
}
input:focus, textarea:focus { outline: none; border-color: var(--text); }
input[type=checkbox] { width: auto; accent-color: var(--text); }
label { display: block; margin: var(--s3) 0 var(--s1); }

.card { background: var(--surface); border: var(--card-border); border-radius: var(--r-card); padding: var(--s4); }

/* The unread count: the text colour, never ochre. */
.unread {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--text); color: var(--on-text);
  font: 500 12px/1 var(--font);
}

/* ---- Avatars: rings, like the mark ------------------------------------------
   Others: a plain ring, their photo inside it, or their initial.
   You: with no photo, the ochre point inside the ring at the mark's offset;
   with a photo, the ring itself turns ochre. */

.avatar {
  --size: 40px;
  position: relative; flex: none;
  width: var(--size); height: var(--size); border-radius: 50%;
  box-shadow: inset 0 0 0 clamp(2px, calc(var(--size) * .07), 4px) var(--text);
  display: inline-grid; place-items: center;
  font-weight: 500; font-size: calc(var(--size) * .4); color: var(--text-2);
}
/* The photo is always a circle cut from the middle of the picture, whatever its shape.
   Sized from --size, not percentages, which Safari resolves differently inside a grid. */
.avatar img {
  --inner: calc(var(--size) - clamp(4px, var(--size) * .14, 8px) * 2);
  display: block; width: var(--inner); height: var(--inner); min-width: var(--inner); max-width: none;
  aspect-ratio: 1; border-radius: 50%; object-fit: cover; object-position: center;
}
/* A group: the same ring, squared off, so a group reads apart from a person at a glance. */
.avatar.group, .avatar.group img { border-radius: 28%; }
.avatar.mine.photo { box-shadow: inset 0 0 0 clamp(2px, calc(var(--size) * .07), 4px) var(--you); }
.avatar.mine:not(.photo) { box-shadow: inset 0 0 0 calc(var(--size) * .1) var(--text); }
.avatar.mine:not(.photo)::after {
  content: ''; position: absolute; border-radius: 50%; background: var(--you);
  width: calc(var(--size) * .27); height: calc(var(--size) * .27);
  left: calc(var(--size) * .515); top: calc(var(--size) * .215);
}

/* ---- The frame ----------------------------------------------------------------
   Phone: one screen at a time, tabs at the bottom (Chats, Connect, You).
   From 720 px: the list beside the open screen.
   From 1120 px: their page as a third column, open unless closed. */

.app { height: 100%; display: grid; grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
#banner { grid-column: 1 / -1; grid-row: 1; }

#rail, #center, #panel { min-height: 0; min-width: 0; }

#rail { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; background: var(--bg); }
#center { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; overflow: hidden; }
#panel {
  grid-column: 1; grid-row: 1 / 4; z-index: 2;
  background: var(--bg); overflow-y: auto; padding: var(--s4) var(--edge) var(--s8);
}
#tabs {
  grid-column: 1; grid-row: 3;
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line); background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 56px; text-decoration: none; font: 400 14px/20px var(--font); color: var(--text-2);
}
#tabs a[aria-current=page] { color: var(--text); font-weight: 600; }
#tabs a .unread { position: absolute; top: 6px; left: calc(50% + 18px); }

/* Phone: the list is the Chats screen; anything else fills the screen. */
.app[data-route=chats] #center { display: none; }
.app:not([data-route=chats]) #rail { display: none; }
.app[data-route=conversation] #tabs { display: none; }

@media (min-width: 720px) {
  .app { grid-template-columns: 320px 1fr; grid-template-rows: auto 1fr; }
  #rail { display: flex !important; grid-column: 1; border-right: 1px solid var(--line); }
  #center { display: flex !important; grid-column: 2; }
  #tabs { display: none !important; }
  #panel {
    grid-column: 2; grid-row: 2; justify-self: end; width: min(360px, 100%);
    border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgb(0 0 0 / .08);
  }
}

@media (min-width: 1120px) {
  .app.with-panel { grid-template-columns: 320px 1fr 340px; }
  #panel { grid-column: 3; width: auto; box-shadow: none; }
}

/* ---- The list (rail) --------------------------------------------------------- */

/* Logo, tag and Connect share one row; if a longer tag ever leaves no room,
   Connect moves to its own line rather than covering the tag. */
.rail-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s2);
  padding: var(--s4) var(--edge) var(--s3);
}
/* The list column is 320 px: a compact Connect, and slightly narrower edges, leave the tag room. */
@media (min-width: 720px) {
  .rail-head { padding-left: 20px; padding-right: 20px; }
  .rail-head .connect { min-height: 32px; padding: 0 var(--s3); }
}
/* The site's tag beside the logo ("DEV", "LOCAL"): rust, outlined; never on the real site. */
.site-tag {
  display: inline-flex; align-items: center; flex: none; height: 20px; padding: 0 7px;
  border-radius: var(--r-chip); border: 1.5px solid var(--warning); color: var(--warning);
  font: 600 11px/1 var(--font); letter-spacing: .08em; cursor: default; user-select: none;
}
.brand { display: inline-flex; align-items: center; gap: var(--s2); flex: none; }
/* In a screen's own header: only where the logo isn't on screen (the phone, away from Chats). */
@media (min-width: 720px) { .site-tag.away { display: none !important; } }
.rail-head .home { display: block; border-radius: var(--r-control); }
.welcome .welcome-tag { justify-self: center; margin-top: calc(-1 * var(--s4)); }
.view > header .site-tag, .conv-head .site-tag { margin-left: auto; }
#gate .site-tag { margin-bottom: var(--s3); }
.panel-head .site-tag { margin-left: auto; margin-right: var(--s2); }
/* The logo: the reverse one on the dark theme. */
:root:not([data-theme="dark"]) .logo-dark,
:root[data-theme="dark"] .logo-light { display: none; }

.rail-head .logo { height: 38px; width: auto; display: block; } /* about 120 px wide, as the guide asks */
.rail-head .connect { display: none; flex: none; }
@media (min-width: 720px) { .rail-head .connect { display: inline-flex; } }

.rail-body { flex: 1; overflow-y: auto; padding: 0 var(--s2) var(--s4); }
.rail-body > .note, .rail-body > .warning { padding: 0 var(--s2); }

.list { list-style: none; margin: 0; padding: 0; }
#contactList a.conversation {
  position: relative; display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s2); border-radius: var(--r-card); text-decoration: none;
}
#contactList a.conversation:hover { background: var(--selected); }
#contactList a.conversation[aria-current=page] { background: var(--selected); }
#contactList a.conversation[aria-current=page]::before {
  content: ''; position: absolute; left: -2px; top: 14px; bottom: 14px; width: 3px; border-radius: 2px; background: var(--you);
}
#contactList .who { flex: 1; min-width: 0; display: grid; gap: 2px; }
#contactList .line { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
#contactList .line strong { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#contactList time { flex: none; font-size: 13px; line-height: 18px; color: var(--text-2); }
#contactList .preview { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#contactList .has-new .preview, #contactList .has-new time { color: var(--text); }
#contactList .preview.hello { font-style: italic; }
#searchNone { padding: var(--s2); }

.rail-search { padding: 0 var(--edge) var(--s2); }
.rail-search input { min-height: 40px; padding: var(--s1) var(--s3); }
@media (min-width: 720px) { .rail-search { padding-left: 20px; padding-right: 20px; } }

.rail-you {
  display: none; align-items: center; gap: var(--s3);
  margin: 0 var(--s2) var(--s2); padding: var(--s2); border-radius: var(--r-card); text-decoration: none;
}
.rail-you:hover, .rail-you[aria-current=page] { background: var(--selected); }
@media (min-width: 720px) { .rail-you { display: flex; } }

/* ---- Screens in the middle ----------------------------------------------------- */

.view { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s4) var(--edge) var(--s8); }
.view > header { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s6); }
.view section { margin-bottom: var(--s8); max-width: 560px; }
.view .narrow { max-width: 560px; }
.view .narrow h1 { margin-bottom: var(--s2); }

.pick { display: grid; place-items: center; text-align: center; color: var(--text-2); }

/* ---- States (layout step: States) ----------------------------------------------
   Messages: by the control (errors stay, confirmations fade); one banner for the
   whole app; quiet notes with a ×. Screens for not-ready, loading and empty. */

.banner { display: grid; gap: var(--s2); padding: var(--s3) var(--edge) 0; }
.banner-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  background: var(--surface); border: var(--card-border); border-radius: var(--r-card);
}
.banner-text { flex: 1; margin: 0; font-size: 14px; line-height: 20px; }
.banner-text.info::before { content: 'ⓘ '; color: var(--text-2); }
.banner-item .close, .quiet-note .close { min-height: 28px; padding: 0 var(--s2); font-size: 18px; color: var(--text-2); }

.quiet-note { display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  background: var(--surface); border: var(--card-border); border-radius: var(--r-control);
  padding: var(--s1) var(--s1) var(--s1) var(--s3); margin: 0 0 var(--s3); color: var(--text); }
.rail-body > .quiet-note { margin: 0 var(--s2) var(--s3); padding-left: var(--s3); }

.success.faded, .faded { opacity: 0; transition: opacity .4s; }

.welcome-notice { margin: 0; padding: var(--s3) var(--s4); background: var(--surface); border: var(--card-border); border-radius: var(--r-card); font-size: 14px; line-height: 20px; text-align: left; }
.welcome-line { margin: 0; font-size: 18px; line-height: 26px; text-align: center; }
.welcome > .note { margin: 0; text-align: center; }

/* Not ready: one centred card; where setting up has got to; the one fix. */
#gate { display: grid; place-items: start center; }
#gate .gate-card { width: 100%; max-width: 480px; margin-top: var(--s8);
  background: var(--surface); border: var(--card-border); border-radius: var(--r-card); padding: var(--s6); }
#gate .gate-card h1 { margin-bottom: var(--s2); }
#gate .actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s4); }
#gate .actions:not(:has(> :not([hidden]))) { display: none; }
#gate .error:empty { display: none; }
#gate .qr { margin-bottom: var(--s3); }
.steps { list-style: none; padding: 0; margin: 0 0 var(--s4); display: flex; gap: var(--s4); flex-wrap: wrap; counter-reset: step; font-size: 13px; color: var(--text-2); }
.steps li { counter-increment: step; display: flex; align-items: center; gap: var(--s2); }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); font-weight: 600; font-size: 12px; }
.steps li.now { color: var(--text); font-weight: 500; }
.steps li.now::before { border-color: var(--text); background: var(--text); color: var(--on-text); }
.steps li.done::before { content: '✓'; border-color: var(--text-2); }
@media (max-width: 719.98px) { #gate .gate-card { margin-top: 0; padding: var(--s4); } }

/* The list: waiting for this device, loading, and no one yet. */
.rail-waiting { padding: var(--s3) var(--s4) !important; }
.empty-card { margin: var(--s2); padding: var(--s4); text-align: center;
  background: var(--surface); border: var(--card-border); border-radius: var(--r-card); }
.empty-card p { margin: 0 0 var(--s2); }
.empty-card .button { margin-top: var(--s2); }
/* Shown only if loading takes more than a moment. */
.list.loading { opacity: 0; animation: appear .2s ease-out .4s forwards; }
.list.loading li { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s2); }
.bone { display: block; background: var(--line); border-radius: 8px; }
.bone.ring { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.bone.line { height: 12px; flex: 1; max-width: 180px; }
@keyframes appear { to { opacity: 1; } }

/* Asked in place (their page's End contact and Block). */
#panel .ask p { font-size: 14px; line-height: 20px; margin: var(--s3) 0 var(--s2); }
#panel .ask .actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* A group's events between messages, and the empty state. */
#messages li.event { align-self: center; text-align: center; font-size: 13px; line-height: 18px; color: var(--text-2); margin: var(--s1) 0; }
#messages li.empty { align-self: center; text-align: center; color: var(--text-2); font-size: 14px; max-width: 320px; margin: var(--s3) auto; }
#messages li.empty p { margin: 0 0 var(--s2); }

/* A group's panel: its people (admins act on each), editing, your page, leaving. */
.people.group li { border-radius: var(--r-card); }
.people.group li.open { background: var(--selected); }
.person-row {
  display: flex; align-items: center; justify-content: flex-start; gap: var(--s3); width: 100%; padding: var(--s2); border: 0; border-radius: var(--r-card);
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; min-height: 0;
}
.person-row:hover { background: var(--selected); }
.person-row .who { min-width: 0; }
.people.group .person-acts, .people.group .ask { display: flex; flex-wrap: wrap; gap: var(--s2); padding: 0 var(--s2) var(--s3) calc(40px + var(--s3) + var(--s2)); }
.people.group .ask { display: block; }
.people.group .ask p { margin: 0 0 var(--s2); font-size: 14px; line-height: 20px; }
.people.group .ask .actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.group-edit { margin: var(--s3) 0; }
.group-edit summary { cursor: pointer; font-weight: 500; padding: var(--s2) 0; }
.group-edit .actions { display: flex; align-items: center; gap: var(--s2); }
.group-mine { margin: var(--s3) 0; }
.group-mine .switch-row { padding: var(--s2) 0; }
#groupLeave { color: var(--error); padding-left: 0; }

.rows { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.rows > li { background: var(--surface); border: var(--card-border); border-radius: var(--r-card); padding: var(--s3) var(--s4); }
.rows > li .actions { margin-top: var(--s2); display: flex; gap: var(--s2); flex-wrap: wrap; }

.code { font: 600 26px/32px ui-monospace, Menlo, monospace; letter-spacing: .08em; margin: var(--s2) 0; }
.qr svg { width: 192px; height: 192px; border-radius: var(--r-control); }

.back, a.button.back { display: none; }
@media (max-width: 719.98px) { .back, a.button.back { display: inline-flex; } }

/* ---- A conversation ----------------------------------------------------------- */

#conversation { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
#conversation .conv-head {
  display: flex; align-items: center; gap: var(--s2); margin: 0;
  padding: var(--s3) var(--edge); border-bottom: 1px solid var(--line);
}
#conversation .conv-head .who {
  flex: 1; min-width: 0; justify-content: flex-start; gap: var(--s3);
  border: 0; background: none; padding: 0; min-height: 48px; text-align: left;
}
/* Back to Chats, on a phone: big enough for a thumb (44 px and more), with a word. */
#conversation .conv-head .back {
  align-items: center; gap: 2px; min-height: 44px; min-width: 44px; padding: 0 var(--s2) 0 var(--s1);
  margin-left: calc(-1 * var(--s2)); border: 0; font-size: 16px; font-weight: 500; flex: none;
}
#conversation .conv-head .back svg { flex: none; }
#conversation #name { font: 600 18px/24px var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#scroller { flex: 1; overflow-y: auto; padding: var(--s4) var(--edge); }
#messages { list-style: none; padding: 0; margin: 0 auto; max-width: 760px; display: flex; flex-direction: column; gap: var(--s2); }
#messages li { max-width: 80%; align-self: flex-start; }
#messages li.mine { align-self: flex-end; text-align: right; }
/* A group: the writer's picture beside their words, once per run. */
#messages li.from { display: flex; align-items: flex-start; gap: var(--s2); }
#messages li.from > div { min-width: 0; }
#messages li.from .avatar, #messages li.from .avatar-space { flex: none; width: 32px; height: 32px; margin-top: 2px; }
#messages .bubble {
  display: inline-block; text-align: left; padding: var(--s2) var(--s3);
  border-radius: var(--r-card); background: var(--surface); border: var(--card-border);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
#messages li.mine .bubble { background: var(--bubble-mine); border-color: transparent; }
#messages .meta { font-size: 13px; line-height: 18px; color: var(--text-2); margin-top: 2px; }
#messages .meta button { min-height: 0; padding: 0 var(--s2); margin-left: var(--s1); font-size: 13px; }
#messages li.gap, #messages li.day { align-self: center; max-width: 100%; font-size: 13px; color: var(--text-2); }
#messages li.start { align-self: center; max-width: 100%; font-size: 13px; color: var(--text-2); text-align: center; margin-bottom: var(--s2); }
#compose { padding: var(--s2) var(--edge) var(--s3); border-top: 1px solid var(--line); background: var(--bg); }
#compose .row { display: flex; gap: var(--s2); align-items: flex-end; max-width: 760px; margin: 0 auto; }
#compose textarea { min-height: 44px; max-height: 40vh; resize: none; }
#compose .under { max-width: 760px; margin: 0 auto; display: flex; justify-content: space-between; }
#compose .under p { margin: var(--s1) 0 0; }

/* ---- Their page (the panel) --------------------------------------------------- */

#panel .panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s4); }
#panel .person { display: grid; justify-items: center; text-align: center; gap: var(--s2); margin-bottom: var(--s6); }
#panel .person .avatar { --size: 96px; font-size: 36px; }
#panel details { margin-top: var(--s6); }
#panel details summary { cursor: pointer; color: var(--text-2); font-size: 14px; }
#panel details .actions { display: grid; gap: var(--s2); margin-top: var(--s3); }

/* ---- Signed out ------------------------------------------------------------------ */

.welcome { min-height: 100%; display: grid; place-content: center; gap: var(--s4); padding: var(--s8) var(--edge); max-width: 400px; margin: 0 auto; }
.welcome .logo { width: 240px; height: auto; margin-bottom: var(--s6); }
.welcome .button { width: 100%; }

#notice { margin: var(--s3) var(--edge) 0; }

/* ---- Connect -------------------------------------------------------------------- */

.invite-card { display: flex; gap: var(--s6); align-items: center; flex-wrap: wrap; margin: var(--s4) 0; }
.invite-side { flex: 1; min-width: 220px; }
.invite-side label { margin-top: 0; }
.invite-side .actions { display: flex; gap: var(--s2); margin: var(--s3) 0; }
#peopleSearch { margin-bottom: var(--s3); }
.people a {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s2); border-radius: var(--r-card); text-decoration: none;
}
.people a:hover { background: var(--selected); }
.people .who strong { display: block; font-weight: 500; }
.people .who span { display: block; font-size: 13px; line-height: 18px; color: var(--text-2); }

/* ---- The invite sheet: over the current screen; a bottom sheet on the phone. ---- */

.sheet {
  position: fixed; inset: 0; z-index: 10; display: grid; align-items: end; justify-items: center;
  background: rgb(31 30 28 / .45);
}
.sheet-card {
  width: 100%; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: var(--r-card) var(--r-card) 0 0;
  padding: var(--s4) var(--edge) calc(var(--s6) + env(safe-area-inset-bottom));
}
@media (min-width: 720px) {
  .sheet { align-items: center; }
  .sheet-card { width: 420px; border-radius: var(--r-card); padding: var(--s4) var(--s6) var(--s6); }
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s2); }
.sheet .person { display: grid; justify-items: center; text-align: center; gap: var(--s1); margin-bottom: var(--s4); }
.sheet .person .t-heading { margin: var(--s2) 0 0; }
.sheet .person .note { margin: 0; }
.center { text-align: center; }
.button.wide, button.wide { width: 100%; margin-bottom: var(--s2); }

/* ---- Pages (layout step 4) ---------------------------------------------------- */

.page-card .person { display: grid; justify-items: center; text-align: center; gap: var(--s1); margin-bottom: var(--s3); }
.page-card .person .avatar { --size: 96px; }
.page-card .person h2, .page-card .person p, #panel .person h2, #panel .person p { margin: 0; }
.page-card .actions, #you .actions { display: flex; gap: var(--s2); flex-wrap: wrap; }

/* ---- You: every section alike --------------------------------------------------
   A small heading, one line saying what it is, then its rows in one card. */

#you > section > h2, #you > section > header h2 {
  font-size: 13px; line-height: 18px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-2); margin: 0 0 var(--s2);
}
#you .group { background: var(--surface); border: var(--card-border); border-radius: var(--r-card); overflow: hidden; }
#you .group .rows { gap: 0; }
#you .group .rows > li {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  background: none; border: 0; border-radius: 0; padding: var(--s3) var(--s4);
}
#you .group .rows > li + li, #you .group .rows:not(:empty) + .group-foot { border-top: 1px solid var(--line); }
#you .group .rows > li .what { flex: 1 1 200px; min-width: 0; }
#you .group .rows > li > .actions { margin: 0; }
#you .group .email { color: var(--text-2); overflow-wrap: anywhere; }
#you .ask { flex-basis: 100%; }
#you .ask p { margin: 0 0 var(--s2); font-size: 14px; line-height: 20px; }
#you .rename { flex-basis: 100%; display: grid; gap: var(--s2); }
#you .group-foot { padding: var(--s1) var(--s2); }
#you .group-foot form, #you .group-foot .ask { padding: var(--s2) var(--s2) var(--s3); }
#you .group-foot form label { margin-top: 0; }
#you .group-foot .actions { margin-top: var(--s3); }
#you .note.after { margin: var(--s2) 0 0; }
#you .error:empty { display: none; }
#you .error:not(:empty) { margin: var(--s2) 0 0; }
#you #signInAdd { margin-top: var(--s3); }
#you section.signout { padding-top: var(--s4); border-top: 1px solid var(--line); }
#you section.signout button { width: 100%; }

button.danger { color: var(--error); }
button.danger:hover { border-color: var(--error); }

/* An on/off switch: a checkbox drawn as a track and a knob. */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin: 0; padding: var(--s3) var(--s4); font-weight: 400; font-size: 15px; cursor: pointer; }
input.switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0; cursor: pointer;
  width: 44px; height: 26px; border-radius: 13px; background: var(--line); border: 0; padding: 0;
  transition: background .15s;
}
input.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-2); box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s;
}
input.switch:checked { background: var(--text); }
input.switch:checked::after { transform: translateX(18px); background: var(--on-text); }
input.switch:disabled { opacity: .5; cursor: default; }
input.switch:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.page-card .actions.center { justify-content: center; }
#pageLink { font-weight: 500; overflow-wrap: anywhere; }

/* Appearance: three buttons on one line, even on the phone. The chosen one is
 * filled like a primary button (never ochre). */
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); max-width: 360px; }
.choices button[aria-pressed="true"] { background: var(--text); color: var(--on-text); border-color: var(--text); }
/* Who sees your page: four stops, two by two on the phone. */
.choices.four { grid-template-columns: repeat(2, 1fr); max-width: 480px; }
@media (min-width: 720px) { .choices.four { grid-template-columns: repeat(4, 1fr); } }
#personWebsite, #meWebsite { font-size: 14px; overflow-wrap: anywhere; }
.on-wide { display: none; }
@media (min-width: 720px) { .on-phone { display: none; } .on-wide { display: inline; } }

/* ---- Sign-in methods ---------------------------------------------------------- */
#signInAdd { display: flex; gap: var(--s2); flex-wrap: wrap; }
#signInResult.result { margin-bottom: var(--s3); background: var(--surface); border: var(--card-border); border-radius: var(--r-card); padding: var(--s3) var(--s4); font-size: 14px; }
#signInResult.success::before { content: '✓ '; }
.signin-changed { color: var(--text); background: var(--surface); border: var(--card-border); border-radius: var(--r-card); padding: var(--s3) var(--s4); }

/* ---- The test-phase notice, agreed once by accounts made before it ------------------ */
#agreeGate { display: grid; place-items: start center; }
#agreeGate .gate-card { width: 100%; max-width: 520px; margin-top: var(--s8);
  background: var(--surface); border: var(--card-border); border-radius: var(--r-card); padding: var(--s6); }
#agreeGate h1 { margin-bottom: var(--s2); }
#agreeGate .notice { margin: var(--s4) 0 0; padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r-control); }
#agreeGate .notice h2 { font-size: 16px; line-height: 24px; font-weight: 600; margin: 0 0 var(--s2); }
#agreeGate .notice ul { margin: var(--s2) 0 var(--s3); padding-left: 20px; }
#agreeGate .notice li { margin-bottom: var(--s1); }
#agreeGate .notice p, #agreeGate .notice li { font-size: 14px; line-height: 20px; }
#agreeGate .agree { display: flex; gap: var(--s3); align-items: flex-start; margin: var(--s4) 0 0; font-weight: 500; }
#agreeGate .agree input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
#agreeGate .actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s4); }
#agreeGate .error:empty { display: none; }
@media (max-width: 719.98px) { #agreeGate .gate-card { margin-top: 0; padding: var(--s4); } }
/* Until then, the list holds back too. */
.app.notice-needed #contacts, .app.notice-needed #search, .app.notice-needed #railLoading { display: none !important; }

/* ---- Your picture: choose, then crop inside the ring ---------------------------------- */
.picture-edit { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s2); }
.picture-edit .actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.picture-edit label.button { margin: 0; cursor: pointer; }
.crop { display: grid; justify-items: center; gap: var(--s2); margin-bottom: var(--s4); }
.crop label { margin: var(--s2) 0 0; }
.crop input[type=range] { width: 240px; padding: 0; accent-color: var(--text); }
.crop .actions { display: flex; gap: var(--s2); }
.crop-stage { position: relative; width: 240px; height: 240px; border-radius: var(--r-control); overflow: hidden; touch-action: none; cursor: grab; background: var(--line); }
.crop-stage:active { cursor: grabbing; }
.crop-stage canvas { width: 240px; height: 240px; display: block; }
/* Outside the ring is dimmed: what shows inside is what others see. */
.crop-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgb(0 0 0 / .45); outline: 2px solid rgb(255 255 255 / .9); outline-offset: -2px; pointer-events: none; }

/* ---- Groups (Phase 2 slice 1) -------------------------------------------------------- */
#groupPeople { margin: 0 0 var(--s4); }
#groupPeople h3 { margin: 0 0 var(--s2); color: var(--text-2); }
#newGroup form label:first-child { margin-top: 0; }
#groupInvite { margin: 0 0 var(--s4); display: grid; gap: var(--s2); }
#groupInviteNew { display: grid; gap: var(--s2); justify-items: start; }
#groupInviteNew label { margin: 0; }
#groupInviteNew .actions { display: flex; gap: var(--s2); }
#groupInvite .error:empty { display: none; }

/* Contact cards, step 1: your details, personas, and what a contact sees. */
#detailsForm fieldset { border: 0; padding: 0; margin: var(--s4) 0 0; }
#detailsForm legend { font-weight: 600; padding: 0; }
#detailsForm .pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
#detailsForm .bday { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--s2); }
#detailsForm .error:empty { display: none; }
#detailsList .value { overflow-wrap: anywhere; }
.persona-fields { flex-basis: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s1) var(--s3); margin: var(--s2) 0 0; }
.persona-fields label { display: flex; gap: var(--s2); align-items: center; margin: 0; font-weight: 400; }
.persona-fields input:disabled + span { color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s2) 0; }
.chips button { padding: 4px 12px; border-radius: 999px; font-size: 14px; }
.chips button[aria-pressed="true"] { background: var(--text); color: var(--on-text); border-color: var(--text); }
.sees { margin: var(--s4) 0; }
.sees-list { list-style: none; padding: 0; margin: var(--s2) 0; display: grid; gap: var(--s1); font-size: 14px; line-height: 20px; }
.sees-list .k { color: var(--text-2); margin-right: var(--s2); }
.sees-list .missing { color: var(--text-2); font-style: italic; }
.sees .error:empty { display: none; }
#detailsState .warning, #detailsState .note { margin: var(--s2) 0; }
#detailsState .ask { margin-top: var(--s2); }
.details-before { margin: var(--s3) 0; }
.details-before p { margin: 0 0 var(--s2); }
#detailsBeforeError:empty { display: none; }
