/* Insight Outpatient - Treatment Plan Tracker
   Dark "liquid glass" theme. Deep ocean blues from The Insight Program's
   palette (#259ED7 sky / #2A3779 navy), animated flowing background,
   frosted glass surfaces. Mobile-first, built for Add-to-Home-Screen. */

:root {
  /* The notch and the home-indicator strip, read once so everything else can
     use a variable. Nothing below should call env() directly: a test browser
     always reports zero for it, which meant none of the layout that depends on
     these could be checked before it reached somebody's phone. */
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --bg0: #0b1430;
  --bg1: #13275c;
  --cyan: #4ec9ff;
  --blue: #2f8fe8;
  --ink: #eef5fd;
  --muted: #94aacb;
  --glass: rgba(255, 255, 255, 0.07);
  --glass-2: rgba(255, 255, 255, 0.11);
  --line: rgba(255, 255, 255, 0.13);
  --amber: #ffce7a;
  --violet: #c9bcff;
  --red: #ff8080;
  --red-deep: #e25555;
  --green: #3ddc84;
  --radius: 20px;
  --radius-sm: 14px;
  --grad: linear-gradient(135deg, #58d2ff, #2f8fe8 55%, #3d63e0);
  --glow: 0 6px 22px rgba(63, 170, 255, 0.35);
  --tabbar-h: 66px;
  /* How much room the tab bar ACTUALLY takes at the bottom of the screen,
     home-indicator inset and all. --tabbar-h above is only a guess at the bar's
     own height, and the real bar - icons, labels, inset - comes out taller on
     most phones, so anything reserving space from the guess reserved too
     little. measureTabbar() in app.js writes the measured number here once the
     bar is on screen; this value is the fallback until it does. */
  --tabbar-real: calc(var(--tabbar-h) + var(--sab));
  /* The height of the screen, measured. Every CSS way of asking is wrong
     somewhere: 100vh ignores the browser's own bars, 100dvh moves when the
     keyboard opens, and 100svh comes back 59px short in a home-screen install
     because iOS takes the notch off it. window.innerHeight is right in all
     three cases and does not move for the keyboard, so measureTabbar() writes
     it here. The svh below is only what is used until it does. */
  --vph: 100svh;
  /* How much of the screen the on-screen keyboard is covering. Kept at 0 by
     default and set from JS while a keyboard is up (see trackKeyboard). */
  --kb: 0px;
  /* The notch, measured at startup (see measureSafeTop). env() is only the
     starting guess: iOS reports it as ZERO while a keyboard is up, which put
     the chat header underneath the clock. */
  --safe-top: var(--sat);
}

/* USE --safe-top, NOT --sat, for anything holding content off the top of the
   screen. --sat is env(safe-area-inset-top), which iOS reports as ZERO in a
   home-screen app often enough that it cannot be trusted; --safe-top is that
   value after measureSafeTop() has checked it and substituted the real 44pt
   when it comes back empty. The chat header was moved over when the name and
   the Back button ended up under the clock. The photo viewer was not, so a
   memory opened full screen put its close button at y=10 - behind the clock -
   and ran a tall photograph up under the status bar. */

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Tell the browser we're a dark app so native widgets (select dropdowns,
   date pickers, scrollbars) render dark instead of white-on-white. */
:root { color-scheme: dark; }

html {
  -webkit-text-size-adjust: 100%;
  /* A sideways drag the app does not want must not become the browser's.
     Chromium answers a rightward drag that nothing claimed by going back a
     page - out of the app altogether - and the property that stops it is read
     from the ROOT element for the viewport. It was set on <body> only, where
     Chrome stopped looking some versions ago, so it held for as long as the
     app's own handlers claimed every drag and failed the moment they did not:
     with a sheet open, where they rightly stand aside. Both now. */
  overscroll-behavior-x: none;
  /* The page's own background is attached to the viewport, which leaves the
     strip behind the home indicator unpainted - a black band under the tab
     bar. Giving the root a solid colour of its own puts a floor under
     everything, so there is nowhere left for the phone to show through. */
  background: #0a1330;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: linear-gradient(165deg, #0c1636 0%, #14295f 45%, #0d1d4b 75%, #0a1330 100%) fixed;
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  /* Sideways too, now that swiping between tabs is a gesture. Without this the
     browser treats a horizontal drag as its own back-navigation and leaves the
     app mid-swipe. The touch handlers call preventDefault as well; this is the
     half that works even when a passive listener somewhere gets there first. */
  overscroll-behavior-x: contain;
}

/* ---- liquid background: two glowing blobs drifting slowly ---- */
body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 65vmax; height: 65vmax;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
}
body::before {
  top: -28vmax; right: -20vmax;
  background: radial-gradient(circle at 50% 50%, rgba(78, 201, 255, 0.34), rgba(78, 201, 255, 0.06) 55%, transparent 70%);
  animation: drift1 26s ease-in-out infinite alternate;
}
body::after {
  bottom: -30vmax; left: -22vmax;
  background: radial-gradient(circle at 50% 50%, rgba(97, 108, 255, 0.30), rgba(97, 108, 255, 0.05) 55%, transparent 70%);
  animation: drift2 32s ease-in-out infinite alternate;
}
@keyframes drift1 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-9vmax, 7vmax) scale(1.15); }
  100% { transform: translate(4vmax, 13vmax) scale(0.95); }
}
@keyframes drift2 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(10vmax, -6vmax) scale(1.12); }
  100% { transform: translate(2vmax, -12vmax) scale(1.02); }
}
@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
}

.hidden { display: none !important; }

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 14px
           calc(var(--tabbar-h) + var(--sab) + 26px);
}

.boot { text-align: center; padding: 40vh 0; color: var(--muted); }

/* Subtle entrance, applied ONLY when the user actually navigates somewhere.
   As a blanket rule it replayed on every DOM write - including the 45-second
   background refresh - and that replay was the flash. `.entering` is added by
   go() and removed a moment later, so a refresh redraws in silence. */
/* One quick fade for the whole page rather than every card sliding up on its
   own. Animating each card meant a dozen elements moving at once on every
   navigation, which is what read as jumpy - and any of them still moving when
   a finger landed made the page feel like it was fighting back. */
@keyframes rise { from { opacity: 0; } to { opacity: 1; } }
#app.entering { animation: rise .16s ease-out both; }

/* Anyone who has asked their phone to keep still gets no animation at all. */
@media (prefers-reduced-motion: reduce) {
  #app.entering { animation: none; }
}

/* ---------- header ---------- */
.pagehead { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 16px; gap: 10px; }
.pagehead h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; color: #fff; }
.pagehead .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ---------- buttons & inputs (big touch targets) ---------- */
button, .btn {
  font: inherit; border: none; cursor: pointer;
  border-radius: var(--radius);
  min-height: 48px;
  padding: 12px 18px;
  font-weight: 700; font-size: 16px;
  background: var(--grad); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--glow);
  transition: transform .14s cubic-bezier(.34,1.56,.64,1), opacity .15s, box-shadow .2s;
  touch-action: manipulation;
}
button:active { transform: scale(.955); box-shadow: 0 3px 10px rgba(63, 170, 255, 0.28); }
button:disabled { opacity: .45; }
.btn-block { width: 100%; }
.btn-ghost {
  background: var(--glass-2); color: var(--cyan);
  border: 1px solid rgba(78, 201, 255, 0.4); box-shadow: none;
}
.btn-quiet { background: var(--glass-2); color: var(--ink); font-weight: 600; box-shadow: none; border: 1px solid var(--line); }
.btn-danger { background: rgba(255, 128, 128, 0.12); color: var(--red); border: 1px solid rgba(255, 128, 128, 0.35); box-shadow: none; }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: 14px; border-radius: 13px; }

/* Every text-ish field the app uses. A type missing from this list gets no
   styling at all and falls back to the browser's own - which is how the phone
   box ended up a narrow black pill next to a properly dressed Nickname. */
input[type=text], input[type=password], input[type=search], input[type=date],
input[type=time], input[type=tel], input[type=email], input[type=number],
input[type=url], textarea, select {
  font: inherit; width: 100%;
  min-height: 48px;
  padding: 12px 15px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: rgba(9, 18, 44, 0.55); color: var(--ink);
  font-size: 16px; /* prevents iOS zoom-on-focus */
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: rgba(148, 170, 203, 0.75); }

/* iOS and Chrome paint any field they have offered to autofill with a
   background of their own - a yellow bar on iOS, and it ignores every normal
   way of setting a background. It turned up first on the Step 8 name box and
   again on the phone number, and it will turn up on anything else the phone
   recognises, so the answer belongs here rather than on one field at a time.
   The absurd transition is the trick: the colour is only applied after the
   delay, which never arrives. text-fill-color keeps the typing readable in the
   meantime. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  transition: background-color 100000s ease-in-out 0s;
}
select { background: #16224d; }
select option { background: #16224d; color: var(--ink); }
input[type=date], input[type=time] { color-scheme: dark; }
input[type=date]::-webkit-calendar-picker-indicator,
input[type=time]::-webkit-calendar-picker-indicator { filter: invert(0.8); }

/* A time is four characters, so it gets a box four characters wide instead of
   the full width of the card. Stretched across the whole card, Safari centres
   the value in the middle of all that emptiness and the thing reads as a
   broken text field rather than something to tap. */
input[type=time], input[type=date] {
  width: auto; max-width: 100%;
  text-align: left; font-variant-numeric: tabular-nums;
}
input[type=time] { min-width: 128px; }
input[type=date] { min-width: 172px; }
/* Safari centres the value inside these fields on its own; put it back to the
   left so it lines up with everything else on the page. */
input[type=time]::-webkit-date-and-time-value,
input[type=date]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type=time]::-webkit-datetime-edit,
input[type=date]::-webkit-datetime-edit { padding: 0; }
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--cyan);
  background: rgba(9, 18, 44, 0.75);
  box-shadow: 0 0 0 3.5px rgba(78, 201, 255, 0.22);
}

label.fieldlabel { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- auth ---------- */
.auth-wrap { max-width: 420px; margin: 0 auto; padding-top: 5vh; }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo .mark {
  width: 84px; height: 84px; border-radius: 26px; margin: 0 auto 14px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 42px; font-weight: 900;
  box-shadow: 0 12px 36px rgba(63, 170, 255, .45);
}
.auth-logo h1 { font-size: 26px; letter-spacing: -.02em; color: #fff; }
.auth-logo p { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* THERE IS NO backdrop-filter IN THIS FILE, AND IT SHOULD STAY THAT WAY.
   It is easy to add back without thinking, and it is expensive.

   It used to be on every card, every message bubble, every thread row and
   every small button: 129 separately blurred layers on one screen of the Feed,
   80 in a conversation. Each has to be re-blurred every frame as it moves.
   Measured, same scroll, same session, blur on then off: the worst frame in a
   150-message chat went from 33ms to 17ms and four missed frames became none -
   on a desktop GPU, which absorbs this far better than a phone does. Taking it
   off the last few fixed surfaces removed the remaining three.

   Almost nothing was lost, and the reason is worth knowing: what sits behind a
   card is the page's own flat gradient, not other content, and blurring a flat
   surface gives back the same flat surface. The surfaces that DO overlap
   moving content - the tab bar, the chat header, the drawer, the sheets, the
   composer - are simply opaque now instead of frosted. */
.card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  box-shadow: 0 8px 32px rgba(4, 10, 30, 0.35);
  margin-bottom: 14px;
}

.seg { display: flex; background: rgba(9, 18, 44, 0.5); border-radius: var(--radius-sm); padding: 4px; gap: 4px; border: 1px solid var(--line); }
.seg button {
  flex: 1; min-height: 46px; background: transparent; color: var(--muted);
  font-size: 13.5px; font-weight: 700; padding: 8px 4px; border-radius: 11px;
  box-shadow: none;
}
.seg button.on { background: var(--grad); color: #fff; box-shadow: 0 3px 12px rgba(63,170,255,.35); }
/* Four choices rather than two, which will not sit on one row of a 320px
   phone. Two by two instead, and each still fills its half. */
.seg-wrap { flex-wrap: wrap; }
.seg-wrap button { flex: 1 1 calc(50% - 4px); min-width: calc(50% - 4px); }

.hint { font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 10px; }
.hint b { color: var(--ink); }
.error-box { background: rgba(226, 85, 85, 0.16); border: 1px solid rgba(255,128,128,.3); color: var(--red); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; margin-top: 12px; }
.ok-box { background: rgba(78, 201, 255, 0.12); border: 1px solid rgba(78, 201, 255, 0.3); color: var(--cyan); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; margin-top: 12px; line-height: 1.5; }
.linkline { text-align: center; margin-top: 16px; font-size: 15px; color: var(--muted); }
.linkline a { color: var(--cyan); font-weight: 700; text-decoration: none; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; padding: 3.5px 9px; border-radius: 99px; letter-spacing: .03em; vertical-align: middle; }
.badge.OG { background: rgba(150, 130, 255, 0.16); color: var(--violet); border: 1px solid rgba(150, 130, 255, 0.3); }
.badge.YG { background: rgba(255, 190, 100, 0.14); color: var(--amber); border: 1px solid rgba(255, 190, 100, 0.3); }
.badge.COUNSELOR { background: rgba(78, 201, 255, 0.14); color: var(--cyan); border: 1px solid rgba(78, 201, 255, 0.32); }
.badge.YOU { background: var(--glass-2); color: var(--muted); border: 1px solid var(--line); }
/* Director wears the same gold as Admin - it's the other role that carries
   authority, and it should read that way at a glance. */
.badge.ADMIN, .badge.DIRECTOR {
  background: rgba(255, 200, 64, 0.14); color: #ffc840;
  border: 1px solid rgba(255, 200, 64, 0.45);
  box-shadow: 0 0 8px rgba(255, 200, 64, 0.25);
}

/* Outpatient's own tag. Sits BESIDE the OG/YG tag, never instead of it. */
.badge.OP { background: rgba(61, 220, 132, 0.14); color: var(--green); border: 1px solid rgba(61, 220, 132, 0.32); }
/* Which city's group somebody is in: ATL, CLT, RAL or TPA. Violet so it reads
   as a different KIND of fact from the green OP tag beside it - one is what
   you are doing in the program, this is where you are. */
.badge.GRP {
  background: rgba(201, 188, 255, 0.14); color: var(--violet);
  border: 1px solid rgba(201, 188, 255, 0.32);
}
/* In a chat, the chip sits after the name on the line above the words. */
.bubble-who .badge.GRP { margin-left: 6px; }

/* Special-role marks that attach to a name (steering wheel, coffee cup).
   Drawn as inline SVG so they stay sharp at any size and take their colour
   from here rather than depending on an emoji font being installed. */
.sp-icon { display: inline-block; vertical-align: -3px; line-height: 0; }
.sp-icon svg { width: 100%; height: 100%; display: block; }
.sp-steering { color: var(--cyan); filter: drop-shadow(0 0 3px rgba(78, 201, 255, 0.45)); }
.sp-outpatient { color: var(--green); filter: drop-shadow(0 0 3px rgba(61, 220, 132, 0.45)); }
/* Gold, and warmer than the rest on purpose - it is the one that marks
   something finished. */
.sp-graduate { color: #f5c451; filter: drop-shadow(0 0 4px rgba(245, 196, 81, 0.55)); }

/* Counselor identifier: monkey's fist knot (The Insight Program's logo mark) */
.cicon { display: inline-block; vertical-align: -3px; object-fit: contain; }

/* Sobriety milestone knots:
   bronze 30 days · green 3 months · silver 6 months · purple 9 months · gold 1 year */
.knot-bronze { filter: drop-shadow(0 0 3px rgba(193, 122, 65, 0.55)); }
.knot-silver { filter: drop-shadow(0 0 3px rgba(203, 213, 225, 0.55)); }
.knot-green  { filter: drop-shadow(0 0 3px rgba(132, 168, 62, 0.60)); }
.knot-purple { filter: drop-shadow(0 0 3px rgba(157, 123, 232, 0.60)); }
.knot-gold   { filter: drop-shadow(0 0 4px rgba(255, 200, 64, 0.65)); }

/* Sobriety tab */
.sober-hero { padding: 22px 16px; }
.sober-hero img { display: block; margin: 0 auto 8px; }
.sober-hero-label { font-size: 16px; font-weight: 800; color: #fff; letter-spacing: .01em; }
/* Sobriety totals: one row per unit, each showing the whole elapsed time
   expressed in that unit. Stacked rather than tiled because the seconds
   count runs to seven digits and won't fit in a narrow tile. */
.sober-list { padding: 2px 18px; }
.sober-row {
  display: flex; align-items: baseline; justify-content: center; gap: 9px;
  padding: 13px 4px; border-bottom: 1px solid var(--line);
}
.sober-row:last-child { border-bottom: none; }
.sober-row b {
  font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sober-row span { font-size: 15px; color: var(--muted); font-weight: 600; }
/* fixed-width digits so ticking numbers don't shift their row */
.stat b { font-variant-numeric: tabular-nums; }

/* ---------- plan cards ---------- */
.plan-card { padding: 0; overflow: hidden; }
.plan-head { padding: 14px 16px 10px; display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--grad);
  color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px;
  box-shadow: 0 4px 14px rgba(63, 170, 255, .35);
}
.plan-who { flex: 1; min-width: 0; }
.plan-who .who-name { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; color: #fff; }
.plan-who .who-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.progress { height: 9px; background: rgba(255, 255, 255, 0.09); border-radius: 99px; overflow: hidden; margin: 0 16px 4px; }
.progress > div { height: 100%; background: var(--grad); border-radius: 99px; transition: width .5s cubic-bezier(.22,1,.36,1); box-shadow: 0 0 12px rgba(78, 201, 255, 0.55); }
.progress-label { font-size: 12px; color: var(--muted); padding: 4px 16px 8px; }

.items { list-style: none; }
.item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.item .tick {
  flex: none; width: 30px; height: 30px; margin-top: 1px;
  border: 2px solid rgba(78, 201, 255, 0.45); border-radius: 10px;
  background: rgba(9, 18, 44, 0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: transparent; padding: 0; min-height: 0; box-shadow: none;
  transition: background .18s, border-color .18s, transform .14s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
.item.done .tick { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 0 14px rgba(78, 201, 255, 0.5); }
.item .tick:active { transform: scale(.85); }
.item.readonly .tick { pointer-events: none; }
.item-main { flex: 1; min-width: 0; }
.item-text { font-size: 15.5px; line-height: 1.45; word-wrap: break-word; }
.item.done .item-text { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(148,170,203,.5); }
.item-note { font-size: 13.5px; color: #bcd2ec; margin-top: 5px; padding: 8px 11px; background: rgba(78, 201, 255, 0.09); border-left: 2.5px solid rgba(78, 201, 255, 0.45); border-radius: 8px; white-space: pre-wrap; }
.item-comment {
  font-size: 13px; color: #bcd2ec; margin-top: 5px; padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05); border-left: 2.5px solid rgba(148, 170, 203, 0.4);
  border-radius: 8px; word-wrap: break-word;
}
.item-comment b { color: var(--cyan); font-weight: 700; }
.item-cbtn {
  flex: none; min-height: 0; width: 34px; height: 34px; padding: 0; margin-top: 0;
  background: var(--glass-2); border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; box-shadow: none; opacity: .8;
}
.item-actions { display: flex; gap: 16px; margin-top: 6px; }
.item-actions button { background: none; color: var(--cyan); font-size: 13px; font-weight: 700; padding: 4px 0; min-height: 0; box-shadow: none; }

.note-edit textarea { margin-top: 6px; }
.note-edit .row { display: flex; gap: 8px; margin-top: 8px; }

/* ---------- comments ---------- */
.comments { border-top: 1px solid rgba(255,255,255,.07); background: rgba(6, 12, 32, 0.35); padding: 12px 16px; }
.comments h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 9px; }
.comment { display: flex; gap: 9px; margin-bottom: 10px; }
.comment .cavatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: rgba(78, 201, 255, 0.14); border: 1px solid rgba(78, 201, 255, 0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: var(--cyan);
}
.comment-body { background: var(--glass-2); border: 1px solid var(--line); border-radius: 5px 16px 16px 16px; padding: 8px 12px; font-size: 14px; flex: 1; }
.comment-body .cname { font-weight: 800; font-size: 12.5px; color: var(--cyan); margin-bottom: 2px; display: flex; align-items: center; gap: 4px; }
.comment-body .ctime { font-size: 11px; color: var(--muted); margin-top: 3px; }
.comment-form { display: flex; gap: 8px; margin-top: 4px; }
.comment-form input { min-height: 44px; }
.comment-form button { min-height: 44px; padding: 0 16px; flex: none; }

.card-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.07); display: flex; gap: 10px; }

/* ---------- scan / new plan ---------- */
.scan-zone {
  border: 1.5px dashed rgba(78, 201, 255, 0.4); border-radius: var(--radius);
  background: var(--glass); padding: 36px 18px; text-align: center; color: var(--muted);
}
.scan-zone .big { font-size: 46px; margin-bottom: 8px; }
.scan-zone b { color: #fff; font-size: 17px; }
.scan-zone p { font-size: 14px; margin: 8px 0 18px; line-height: 1.5; }
.preview-img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.edit-item-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.edit-item-row input { flex: 1; }
.edit-item-row .del { flex: none; width: 44px; min-height: 44px; padding: 0; background: rgba(226, 85, 85, 0.14); color: var(--red); font-size: 18px; border-radius: var(--radius-sm); box-shadow: none; border: 1px solid rgba(255,128,128,.25); }
.spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
.spin.dark { border-color: rgba(78,201,255,.25); border-top-color: var(--cyan); }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }

.ocr-progress { height: 7px; background: rgba(255,255,255,.1); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.ocr-progress > div { height: 100%; background: var(--grad); border-radius: 99px; transition: width .25s ease; box-shadow: 0 0 10px rgba(78,201,255,.5); }

/* The Daily Reflection is fetched after the page is drawn, so its slot starts
   empty. Empty and at the top of the Feed means everything below it jumps down
   when the card lands - measured at 153px, the largest single movement in the
   app. The card is kept on the phone for the day so this is normally filled
   before the first paint; this holds the space open on the one morning a
   phone has nothing saved, and is dropped the moment the slot is filled or
   the fetch comes back with nothing. */
#reflection-slot.reserving { min-height: 152px; }

/* ---------- messages ---------- */
.thread-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; margin-bottom: 10px; color: var(--ink); font: inherit; text-align: left;
  box-shadow: 0 4px 18px rgba(4, 10, 30, 0.25);
}
.thread-row:active { transform: scale(.985); }
.thread-row .tmeta { flex: 1; min-width: 0; }
.thread-row .tname { font-weight: 800; font-size: 15px; display: flex; gap: 7px; align-items: center; color: #fff; }
.thread-row .tlast { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.unread-dot { min-width: 22px; height: 22px; border-radius: 99px; background: var(--red-deep); color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 6px; box-shadow: 0 0 10px rgba(226,85,85,.5); }

.chat { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 19px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.bubble.mine { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 4px 14px rgba(63,170,255,.3); }
.bubble.theirs { align-self: flex-start; background: var(--glass-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble .btime { display: block; font-size: 10.5px; opacity: .7; margin-top: 3px; }

/* ------------------------------------------------------------------ replying */
/* The message a reply is answering, quoted above it inside the same bubble.
   A bar down the leading edge and the quoted words a shade quieter than the
   reply itself - so it reads as something being pointed at rather than as a
   second message.

   display:block with its own normal white-space, because .bubble is pre-wrap:
   without that, the line breaks in this template would print inside the quote.
   The text itself has its newlines collapsed before it ever gets here. */
.bubble-quote {
  display: block; white-space: normal;
  margin: 0 0 6px; padding: 5px 9px;
  border-left: 3px solid currentColor;
  border-radius: 4px 11px 11px 4px;
  font-size: 12.5px; line-height: 1.35;
  background: rgba(255, 255, 255, .13);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  text-align: left;
}
.bubble.theirs .bubble-quote { background: rgba(255, 255, 255, .07); }
.bubble-quote:active { background: rgba(255, 255, 255, .2); }
.bubble-quote .q-who { display: block; font-weight: 800; opacity: .95; }
/* Two lines of the quoted message and no more. A long paragraph quoted in full
   would bury the reply underneath it. */
.bubble-quote .q-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; opacity: .82;
}
/* The original is gone - unsent by whoever wrote it, or deleted out of this
   reader's own copy. Said plainly rather than left as a reply to nothing. */
.bubble-quote.gone {
  cursor: default; font-style: italic; border-left-color: var(--muted);
}

/* Tapping a quote goes to the message it quotes, and that message says so for
   a second and a half. Outline rather than background: it must be visible on
   both kinds of bubble without repainting either of them. */
@keyframes quote-lit {
  0%   { box-shadow: 0 0 0 0 rgba(78, 201, 255, 0); }
  18%  { box-shadow: 0 0 0 3px rgba(78, 201, 255, .85); }
  100% { box-shadow: 0 0 0 3px rgba(78, 201, 255, 0); }
}
.bubble-wrap.quote-lit > .bubble { border-radius: 19px; animation: quote-lit 1.5s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .bubble-wrap.quote-lit > .bubble { animation: none; outline: 2px solid var(--cyan); }
}

/* What you are answering, while you are answering it. A row of the chat
   panel's own column, directly above the composer - so it being there simply
   makes the message list that much shorter, and nothing has to be measured or
   positioned. */
.replybar {
  display: flex; align-items: center; gap: 10px; flex: none;
  margin: 0 14px; padding: 7px 10px;
  border-left: 3px solid var(--cyan);
  border-radius: 4px 12px 12px 4px;
  background: var(--glass-2);
  font-size: 12.5px; line-height: 1.35;
}
.replybar .rb-body { min-width: 0; flex: 1; }
.replybar .rb-who { display: block; font-weight: 800; color: var(--cyan); }
.replybar .rb-text {
  display: block; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Big enough to hit with a thumb without being the loudest thing in the row. */
.replybar .rb-x {
  flex: none; background: none; border: 0; box-shadow: none;
  color: var(--muted); font-size: 15px; line-height: 1;
  min-height: 34px; min-width: 34px; padding: 0;
}

/* A message arriving - yours the instant you hit send, or somebody else's when
   it turns up. Before this, every bubble simply existed from one frame to the
   next and the list teleported to the bottom underneath it.

   Transform and opacity ONLY. The bubble takes up its full height from the
   first frame, so the list is already its final height and the glide to the
   bottom knows where it is going; animating the height instead would have the
   scroll chasing a box that was still growing, which is the thing this is
   meant to stop. Both are composited, so neither costs a layout.

   It grows from the corner it is anchored to, which is what makes it read as
   coming out of the edge of the screen rather than fading in on the spot. */
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(9px) scale(.94); }
  to   { opacity: 1; transform: none; }
}
.bubble-wrap.just-in { animation: bubble-in .2s cubic-bezier(.22, .92, .3, 1) both; }
.bubble-wrap.just-in { transform-origin: bottom left; }
.bubble-wrap.just-in.mine { transform-origin: bottom right; }
@media (prefers-reduced-motion: reduce) {
  .bubble-wrap.just-in { animation: none; }
}

.chatbar {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--sab));
  background: rgba(11, 20, 48, 0.96);
  padding: 8px 14px; display: flex; gap: 8px;
  max-width: 640px; margin: 0 auto;
}
.chatbar input { flex: 1; }

/* The typing box. A textarea rather than a single-line input, so a long
   message stacks up instead of scrolling sideways through a slot one line
   high. Its height is set in script from what has been typed; everything here
   is what it looks like and what stops it fighting that.

   resize:none because the drag handle a textarea comes with has no business on
   a phone, and field-sizing is not in Safari yet - hence the script. */
.chatbar textarea {
  flex: 1;
  resize: none;
  overflow-y: hidden;          /* script turns this on past five lines */
  min-height: 0;
  max-height: 40vh;            /* a hard ceiling, whatever the line maths says */
  line-height: 1.35;
  font: inherit;
  /* A textarea sits on the text baseline by default and would ride high next
     to the buttons beside it. */
  vertical-align: middle;
}
.chatbar button { flex: none; }
/* Photo button sits left of the text field, sized to match the send button. */
.chatbar .photo-btn { font-size: 19px; padding: 0 12px; line-height: 1; }

/* Several pictures sent in one go, shown as one thing. Two across: wide enough
   on a phone to tell what each one is, and it keeps a batch of six to three
   tidy rows instead of a column you have to scroll past. The tiles are square
   so the grid stays a grid whatever shape the pictures are - but the pictures
   are fitted inside them rather than cropped to them, same as a single photo:
   the tile being square is a layout decision and should not decide how much of
   somebody's picture you get to see. */
.photo-set {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  border-radius: 13px; overflow: hidden; margin-bottom: 4px;
  max-width: 300px;
}
.photo-set .set-photo {
  width: 100%; aspect-ratio: 1; object-fit: contain; display: block;
  background: var(--glass); cursor: zoom-in;
}
/* Three reads better as one big one over two than as two and a lonely third. */
.photo-set.of-three .set-photo:first-child { grid-column: 1 / -1; aspect-ratio: 4 / 3; }

/* A photo in a bubble shows the WHOLE picture, in a box that is the same size
   before it loads and after. Both halves of that matter.
   The box has to be fixed. The database stores the bytes of a photo but not
   its shape, so there is nothing to predict with: with nothing reserved the
   element was zero by zero until the picture arrived and then jumped to
   whatever shape it turned out to be, the conversation changed height, and the
   list corrected its scroll - which is the jitter, once per photo, even while
   nobody was doing anything. A guessed box is right for nothing, so guessing
   only moves the jump rather than removing it.
   But the fixed box was being FILLED, with object-fit: cover, and cover crops.
   A portrait photo from a phone came out as a short landscape strip through
   the middle of itself, so you could not see what somebody had sent you
   without opening it. contain keeps the box exactly as fixed as cover did and
   fits the whole picture inside it instead - the same thing .chat-gif already
   does, for the same reason, and the faint background is what shows in the
   margins. The box is taller than it is wide because photos from a phone
   mostly are. Tapping it still opens the picture full size. */
.chat-photo {
  display: block; width: 240px; max-width: 100%; aspect-ratio: 4 / 5;
  object-fit: contain;
  border-radius: 13px; margin-bottom: 4px; cursor: zoom-in; background: var(--glass-2);
}
/* A clip in a bubble. Same shape as a photo, but it keeps its own controls
   rather than opening a viewer - scrubbing where it sits is what people
   expect, and a tap-to-open would fight the play button. */
.chat-video {
  display: block; max-width: 100%; max-height: 320px; width: auto;
  border-radius: 13px; margin-bottom: 4px; background: #000;
}

/* Shown in place of a photo KV has already aged out. */
.photo-gone {
  font-size: 13px; opacity: .75; padding: 14px 16px; text-align: center;
  border: 1px dashed var(--line); border-radius: 13px; margin-bottom: 4px;
}

/* Search box above the thread list */
.searchbar { margin-bottom: 12px; }
.searchbar input { width: 100%; }

/* ---------- acceptable use policy (bottom of the auth screen) ---------- */
/* Deliberately quiet and collapsed: present on every sign-up and log-in
   without competing with the two fields people came to fill in. */
.aup { margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line); }
.aup > summary {
  cursor: pointer; list-style: none;
  font-size: 12px; line-height: 1.5; color: var(--muted); text-align: center;
  padding: 4px 2px;
}
.aup > summary::-webkit-details-marker { display: none; }
.aup > summary::after { content: ' ▾'; opacity: .7; }
.aup[open] > summary::after { content: ' ▴'; }
.aup > summary:hover { color: var(--ink); }
.aup-body {
  margin-top: 12px; max-height: 46vh; overflow-y: auto;
  font-size: 12.5px; line-height: 1.6; color: var(--muted);
  background: var(--glass); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 15px;
}
.aup-body h4 {
  margin: 15px 0 5px; font-size: 12.5px; color: var(--ink);
  text-transform: uppercase; letter-spacing: .05em;
}
.aup-body h4:first-of-type { margin-top: 6px; }
.aup-body p { margin: 0 0 8px; }
.aup-body b { color: var(--ink); }
.aup-body ul { margin: 0 0 8px; padding-left: 18px; }
.aup-body li { margin-bottom: 6px; }

/* ---------- profile pictures ---------- */
/* An <img> avatar has to sit exactly where the initials <div> did. */
.avatar-img { object-fit: cover; padding: 0; }
.avatar-sm { width: 36px; height: 36px; font-size: 13px; }
.avatar-lg { width: 96px; height: 96px; font-size: 30px; margin: 0 auto 10px; }
.avatar-btn { background: none; border: 0; padding: 0; min-height: 0; cursor: pointer; }

/* A name that behaves like a link without looking like a button */
.linkish {
  background: none; border: 0; padding: 0; min-height: 0; cursor: pointer;
  font: inherit; color: inherit; text-align: left;
}
.linkish:active { opacity: .6; }

/* Nickname beside a real name - quieter, never a replacement for it */
.nick { color: var(--muted); font-weight: 600; }

/* ---------- profile page ---------- */
.profile-head { padding: 22px 18px 18px; }
.profile-name { font-size: 21px; font-weight: 800; color: #fff; }
.profile-nick { color: var(--muted); font-size: 15px; margin-top: 2px; }
.profile-tags {
  display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
  justify-content: center; margin-top: 11px;
}
.profile-actions { margin-top: 14px; }
/* Bio sits under the name/tags. Preserves the line breaks people type. */
.profile-bio {
  margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--line);
  font-size: 14.5px; line-height: 1.5; color: var(--ink);
  white-space: pre-wrap; word-wrap: break-word; text-align: left;
}
/* Buttons side by side (Save / Cancel) */
.row { display: flex; gap: 9px; align-items: center; }
.row > button { flex: 1; }
.profile-stats { grid-template-columns: repeat(3, 1fr); }
.prof-line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.prof-line:last-child { border-bottom: none; }
.prof-line span { color: var(--muted); }
.prof-line b { color: var(--ink); text-align: right; }

/* ---------- role chips on the Manage user list ---------- */
/* Lit = they hold it. Tap toggles, so granting a role is one tap from the
   list rather than a trip through a separate form. */
.mgmt-roles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.rolechip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--glass); border: 1px solid var(--line); color: var(--muted);
  font-size: 11.5px; font-weight: 700; padding: 5px 10px; border-radius: 99px;
  min-height: 0; cursor: pointer;
}
.rolechip.on { background: rgba(78, 201, 255, 0.14); border-color: rgba(78, 201, 255, 0.4); color: var(--cyan); }
.rolechip .sp-icon { width: 13px; height: 13px; }

/* Manage tab: who currently holds each special role */
.sp-group { margin-top: 15px; }
.sp-group-head { font-size: 13px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.sp-holder {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink);
}
.sp-holder:last-child { border-bottom: none; }

/* ---------- archive ---------- */
.arch-meta { flex: 1; min-width: 0; }
.arch-title { font-weight: 800; font-size: 15px; color: #fff; }
.arch-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.pill-done { background: rgba(61, 220, 132, 0.14); color: var(--green); border: 1px solid rgba(61, 220, 132, 0.32); font-size: 11px; font-weight: 800; padding: 3.5px 9px; border-radius: 99px; flex: none; }
.pill-replaced { background: var(--glass-2); color: var(--muted); border: 1px solid var(--line); font-size: 11px; font-weight: 800; padding: 3.5px 9px; border-radius: 99px; flex: none; }

/* The tab either side of you while you swipe: a picture of it, taken the last
   time you were there. Only ever looked at, never touched. */
.swipe-card {
  position: fixed; inset: 0; z-index: 40;
  overflow: hidden; pointer-events: none;
  background: #0a1330;
  will-change: transform;
}
/* Finishing the journey the finger started - short, because most of the
   distance has already been covered by hand. */
.glide-swipe { transition: transform 0.19s cubic-bezier(0.25, 0.85, 0.3, 1); }
@media (prefers-reduced-motion: reduce) { .glide-swipe { transition: none; } }
/* No overflow:hidden here, however much it looks like the right idea. The
   moment the body stops overflowing the browser clamps the scroll to the top,
   which yanks the screen you are on up to its first line as the swipe starts -
   that was the bounce, and it happened on every swipe of any scrolled page.
   The touch handler already calls preventDefault once the gesture is judged
   horizontal, so nothing scrolls vertically anyway. */
body.swiping { touch-action: pan-y; }

/* ---------- sub-tabs across the top of a section ----------
   Plans uses these: your own plan, or the group's. Deliberately not the same
   shape as the bottom bar - these move you WITHIN a section, and looking like
   the thing that moves you BETWEEN sections would be a lie. */
.subtabs {
  display: flex; gap: 6px; margin: 0 0 14px;
  background: var(--glass-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px;
}
.subtab {
  flex: 1; min-width: 0; background: none; border: 0; color: var(--muted);
  font: inherit; font-size: 13.5px; font-weight: 700;
  padding: 9px 10px; border-radius: 999px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background 0.16s ease-out, color 0.16s ease-out;
}
.subtab.on { background: var(--grad); color: #fff; box-shadow: 0 3px 12px rgba(63, 170, 255, 0.28); }

/* Something on that feed this person has not seen.
   Inline rather than floated into a corner: the chips are flexible width and
   sit shoulder to shoulder, so anything positioned absolutely would end up
   over the next one's text on a narrow phone. Sitting in the flow means the
   chip simply gets a little wider, which it has room for - and the label is
   allowed to ellipsis before the count does, because "3" is the part worth
   keeping when space runs out. */
.subtab { display: flex; align-items: center; justify-content: center; gap: 6px; }
.subtab-dot {
  flex: none;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 99px;
  background: var(--red-deep); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 17px;
  display: inline-flex; align-items: center; justify-content: center;
}
/* On the selected chip it would be red on blue, which is loud and means
   nothing - you are already looking at that feed. It never has a count
   anyway; this is for the frame before a redraw catches up. */
.subtab.on .subtab-dot { background: rgba(255, 255, 255, .28); }

/* Whatever the section's own heading was carrying - New scan, and the like. */
.head-acts { display: flex; gap: 8px; align-items: center; flex: none; }

/* A round button that is only its icon. Used where an action belongs in the
   corner rather than in the page: editing your profile, opening settings.
   44px because that is the smallest thing a thumb reliably hits. */
.iconbtn {
  flex: none; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center;
  font-size: 18px; line-height: 1;
  background: var(--glass-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 50%;
  cursor: pointer;
  transition: background 0.16s ease-out, transform 0.12s ease-out;
}
.iconbtn:active { transform: scale(0.94); }

/* A button that reads as a link, for somewhere a whole button would shout. */
.linkbtn {
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--cyan); text-decoration: underline; cursor: pointer;
}
.version-line { margin-top: 18px; text-align: center; opacity: 0.75; }

/* ---------- bottom tab bar ---------- */
.tabbar {
  /* Plain bottom: 0. This is right in every case except a keyboard being up,
     which the viewport meta (interactive-widget=resizes-content) handles, and
     which body.kb-open handles below by getting the bar out of the way
     entirely. Positioning it from a measured value was worse than the problem:
     one stale measurement and the bar floats in the middle of the screen. */
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  /* Kept on its own compositing layer. Without this iOS drops a fixed bar out
     of position partway through a momentum scroll and leaves it there. */
  transform: translateZ(0); -webkit-backface-visibility: hidden; backface-visibility: hidden;
  display: flex; justify-content: space-around;
  /* Installed to the home screen there is no Safari toolbar beneath the bar,
     so the bar has to carry its own bottom edge. At rgba(10,18,44,.97) it sat
     7 channel steps off the page behind it - invisible - and the strip over
     the home indicator read as empty space under a floating bar. Lifted to a
     surface you can actually see, with an edge and a shadow to sell it. */
  background: #182958;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.35), 0 -10px 24px rgba(4, 10, 30, 0.45);
  padding: 6px 4px calc(var(--sab) + 6px);
}
/* A slab of the bar's own colour hanging below it.
   The bar used to reach under the home indicator with a negative bottom margin
   and double the padding to make up for it. That was a guess at one cause of
   bare page showing below the bar, and it covered only that one: it is a fixed
   34px, and after a keyboard the layout viewport comes back 59px short, so
   `bottom: 0` is 59px up the screen and the page shows through beneath. That is
   the gap. keepTabbarDown() now measures the real floor and pushes the bar onto
   it, but it cannot run before the frame that moved it, and anything it
   declines to correct would show through in the meantime.
   Absolutely positioned, so it is out of the flow and not a flex item: it
   shifts nothing and is in no measurement. Whatever the viewport does, the
   screen below the bar is the bar's colour. It cannot be out by a measurement
   because it does not depend on one. */
.tabbar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%;
  height: 220px; background: #182958; pointer-events: none;
}
.tabbar button {
  /* Seven of these now, and the narrowest phone the matrix covers is 320px -
     so about 44px each. flex-basis 0 with min-width 0 lets them share the row
     evenly however many there are, and the sizes scale with the viewport
     rather than being fixed and clipping the labels on a small screen. */
  flex: 1 1 0; min-width: 0; max-width: 110px;
  background: none; color: var(--muted);
  display: flex; flex-direction: column; gap: 2px; align-items: center;
  font-size: clamp(8.5px, 2.6vw, 10.5px); font-weight: 700;
  min-height: 52px; padding: 4px 1px; position: relative;
  box-shadow: none; border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: color .15s;
}
.tabbar button .ticon { font-size: clamp(18px, 5.4vw, 22px); line-height: 1; }
.tabbar button.on { color: var(--cyan); }
.tabbar button.on::after {
  content: ""; position: absolute; bottom: 0; width: 22px; height: 3.5px;
  border-radius: 99px; background: var(--grad); box-shadow: 0 0 10px rgba(78,201,255,.6);
}
.tabbar .tbadge {
  position: absolute; top: 0; right: calc(50% - 22px);
  min-width: 17px; height: 17px; border-radius: 99px; background: var(--red-deep); color: #fff;
  font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--sab) + 16px);
  background: rgba(20, 34, 74, 0.98); color: #fff;
  border: 1px solid rgba(78, 201, 255, 0.35);
  padding: 11px 18px; border-radius: 99px;
  font-size: 14px; font-weight: 600; z-index: 100; max-width: 90vw; text-align: center;
  box-shadow: 0 8px 28px rgba(4, 10, 30, .55), 0 0 18px rgba(78, 201, 255, .25);
}

/* ---------- admin: manage ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 10px; text-align: center;
}
.stat b { display: block; font-size: 24px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat span { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.35; font-weight: 600; }
.cardtitle { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.weekline { font-size: 14px; color: var(--ink); padding: 4px 0; }
.healthline { font-size: 14px; color: var(--ink); padding: 4px 0; display: flex; gap: 7px; align-items: baseline; }
.healthline span { color: var(--muted); font-size: 13px; }
.mgmt-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid rgba(255,255,255,.07); }
.mgmt-row:first-of-type { border-top: none; }
.mgmt-meta { flex: 1; min-width: 0; }
.mgmt-name { font-weight: 700; font-size: 14px; color: #fff; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mgmt-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.mgmt-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.mgmt-actions select {
  min-height: 38px; width: auto; padding: 6px 8px; font-size: 13px; font-weight: 700;
  background: #16224d; color: var(--ink); border: 1px solid var(--line); border-radius: 11px;
}
.mgmt-actions button { min-height: 38px; width: 40px; padding: 0; font-size: 15px; }
@media (max-width: 420px) {
  .mgmt-row { flex-wrap: wrap; }
  .mgmt-actions { width: 100%; justify-content: flex-end; }
}

.empty { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 15px; line-height: 1.55; }
.empty .big { font-size: 44px; margin-bottom: 10px; }
.empty b { color: var(--ink); }

@media (min-width: 641px) {
  .tabbar { max-width: 640px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 18px 18px 0 0; }
}

/* ---------- navigation drawer ---------- */
/* Built once and only toggled, so opening/closing is a pure CSS transition on
   an element already in the DOM - nothing to rebuild, nothing to get stuck. */
.navsheet { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.navsheet.open { pointer-events: auto; }
.navsheet-scrim {
  position: absolute; inset: 0; background: rgba(4, 9, 24, 0.55);
  opacity: 0; transition: opacity .22s ease;
}
.navsheet.open .navsheet-scrim { opacity: 1; }
.navsheet-panel {
  /* Anchored the same way as the tab bar - fixed to bottom: 0 - rather than to
     the .navsheet box. On iOS a fixed inset:0 element is the LAYOUT viewport,
     which is taller than what you can actually see while the URL bar is up, so
     positioning against its bottom put this panel below the fold. The tab bar
     never had that problem, so the panel now shares its anchor and simply pads
     itself clear of it. */
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  background: rgba(13, 24, 56, 0.99);
  border-top: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 8px 10px calc(var(--tabbar-h) + var(--sab) + 12px);
  /* --drawer-drift is measured in JS. `bottom: 0` on a fixed element means the
     bottom of the LAYOUT viewport, which on iOS is not the same thing as the
     bottom of what you can see - the tab bar has the same fault and is
     corrected the same way, every couple of seconds, by keepTabbarDown(). The
     drawer is only on screen for a moment, so it measures itself as it opens.
     Without this the panel can sit entirely below the fold: the scrim darkens
     the page, and the menu itself is nowhere. */
  transform: translateY(calc(100% + var(--drawer-drift, 0px)));
  visibility: hidden;
  transition: transform .26s cubic-bezier(.32,.72,0,1), visibility 0s linear .26s;
  /* Never taller than the screen minus the notch. The menu grew - Manage and
     the rest - and a panel that outgrows the viewport has nowhere to go but
     up, behind the status bar. It scrolls inside itself instead. */
  max-height: calc(82vh - var(--safe-top));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* dvh tracks the visible viewport as the URL bar shows and hides. */
@supports (height: 100dvh) {
  .navsheet-panel { max-height: calc(88dvh - var(--safe-top)); }
}
.navsheet.open .navsheet-panel {
  transform: translateY(var(--drawer-drift, 0px)); visibility: visible;
  transition: transform .26s cubic-bezier(.32,.72,0,1), visibility 0s;
}
.navsheet-grab {
  width: 38px; height: 4px; border-radius: 99px; background: var(--line);
  margin: 4px auto 10px;
}
.navsheet-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 0 8px 6px; font-weight: 700;
}
.navlink {
  display: flex; align-items: center; justify-content: flex-start; gap: 13px; width: 100%;
  background: none; border: 0; border-radius: var(--radius-sm);
  padding: 13px 12px; color: var(--ink); font-size: 15.5px; font-weight: 600;
  text-align: left; min-height: 0; cursor: pointer;
}
.navlink:active { background: var(--glass); }
.navlink.on { background: var(--glass-2); color: #fff; }
.navlink-icon { font-size: 19px; width: 24px; text-align: center; }
.navlink-badge { position: static; margin-left: auto; }
/* The arrow on a link that leaves this app - the shop is its own app, and the
   drawer should say so before it is tapped rather than after. */
.navlink-out { margin-left: auto; color: var(--muted); font-size: 15px; }
.navlink[href] { text-decoration: none; }

/* ---------- the phone list ----------
   Every row is a call button. Nothing else on this page matters as much as
   the number being easy to hit with a thumb, in a car park, at night. */
.phone-sec + .phone-sec { margin-top: 22px; }
.phone-sec .cardtitle { margin-bottom: 6px; }
.phone-row {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 4px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--ink); min-height: 52px;
}
.phone-row:last-child { border-bottom: 0; }
.phone-row:active { background: var(--glass); border-radius: 10px; }
.ph-name { font-weight: 700; font-size: 16px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-num { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ph-call {
  flex: none; font-size: 12.5px; font-weight: 800; color: #fff;
  background: var(--grad); border-radius: 999px; padding: 6px 13px;
  box-shadow: 0 4px 12px rgba(63, 170, 255, .28);
}

/* ---------- feed posts ---------- */
/* position: relative so the three-dot menu in the corner is placed against
   the card rather than against whatever ancestor happens to be positioned. */
.post-card { padding: 15px 16px; position: relative; }
.post-card.pinned { border-color: rgba(255, 200, 64, 0.32); }
.pin-flag { font-size: 11px; font-weight: 800; color: #ffc840; margin-bottom: 8px; letter-spacing: .04em; }
.post-head { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.post-body { font-size: 15px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; word-wrap: break-word; }
.post-actions { display: flex; gap: 7px; margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }

/* A Feed post dropped into a chat by Steering. Inside the bubble, but it is
   plainly a different thing from the message around it - a card you press,
   not words somebody typed. */
.sharedpost {
  display: block; white-space: normal; text-align: left;
  margin: 6px 0 2px; padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .18); border-radius: 13px;
  background: rgba(255, 255, 255, .10);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.bubble.theirs .sharedpost { background: rgba(255, 255, 255, .06); }
.sharedpost:active { background: rgba(255, 255, 255, .2); }
.sharedpost .sp-kicker {
  display: block; font-size: 11px; font-weight: 800;
  letter-spacing: .03em; opacity: .85; margin-bottom: 4px;
}
/* The post's first line, and nothing else. The card is a pointer to the thing
   rather than a copy of it - the post itself is one tap away, formatted the
   way it was written, and repeating it here was both unreadable and pointless.
   Two lines is the ceiling, for a long title on a narrow phone. */
.sharedpost .sp-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14.5px; font-weight: 700; line-height: 1.35;
}
.sharedpost .sp-go {
  display: block; margin-top: 7px; font-size: 12px; font-weight: 800;
  color: var(--cyan);
}
.bubble.mine .sharedpost .sp-go { color: #fff; }
.sharedpost.gone { cursor: default; font-style: italic; opacity: .75; }

/* The post somebody was sent to, when they arrive from a chat. Same flash a
   quoted message gets, for the same reason: say which one without moving it. */
@keyframes post-lit {
  0%   { box-shadow: 0 0 0 0 rgba(78, 201, 255, 0); }
  18%  { box-shadow: 0 0 0 3px rgba(78, 201, 255, .85); }
  100% { box-shadow: 0 0 0 3px rgba(78, 201, 255, 0); }
}
.post-card.post-lit { animation: post-lit 1.6s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .post-card.post-lit { animation: none; outline: 2px solid var(--cyan); }
}

/* The list of chats to put a post into. */
.stc-list { margin-top: 12px; max-height: 46vh; overflow-y: auto; }
.stc-room {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: none; box-shadow: none; color: var(--ink);
  text-align: left; padding: 10px 6px; min-height: 0; border-radius: 12px;
  border-bottom: 1px solid var(--line);
}
.stc-room:last-child { border-bottom: 0; }
.stc-room:active { background: var(--glass-2); }
.stc-name {
  flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stc-go { flex: none; color: var(--muted); font-size: 18px; }

/* ---------- daily reflection card ---------- */
.reflection { display: block; text-decoration: none; border-color: rgba(78, 201, 255, 0.3); }
.reflection-tag { font-size: 11px; font-weight: 800; color: var(--cyan); letter-spacing: .05em; }
.reflection-title { font-size: 17px; font-weight: 800; color: #fff; margin-top: 6px; }
.reflection-excerpt { font-size: 14.5px; line-height: 1.55; color: var(--ink); margin-top: 7px; }
.reflection-cta { font-size: 13.5px; font-weight: 700; color: var(--cyan); margin-top: 10px; }
.reflection-copy { font-size: 10.5px; line-height: 1.45; color: var(--muted); margin-top: 11px; padding-top: 9px; border-top: 1px solid var(--line); }

/* ---------- tappable row that looks like a card ---------- */
.linkrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
}
.linkrow-chev { color: var(--muted); font-size: 22px; }

/* The one-time "are you in Outpatient?" question, and the way back out. */
.op-ask { border-color: rgba(61, 220, 132, 0.3); }
.op-ask b { color: #fff; font-size: 16px; }
.op-grad { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }

/* A paused account is visibly marked in the Manage list. */
.mgmt-row.paused { opacity: .62; }
.rolechip.pausechip.on { background: rgba(255, 128, 128, 0.14); border-color: rgba(255, 128, 128, 0.4); color: var(--red); }

/* Group chats sit above direct messages in the Messages list. */
.room-list { margin-bottom: 6px; }
.room-avatar { background: var(--glass-2); border: 1px solid var(--line); box-shadow: none; font-size: 19px; }
/* Who said what, in a room where it isn't obvious. */
.bubble-who { font-size: 11.5px; font-weight: 800; opacity: .8; margin-bottom: 3px; }

/* A <select> has a wide intrinsic size; without this it refuses to shrink and
   pushes the button in the same row off the edge of the card. */
.edit-item-row { min-width: 0; }
.edit-item-row > select, .edit-item-row > input { min-width: 0; }

/* Search fields: same glass treatment as every other input, plus a magnifier
   so they read as search at a glance. Safari puts its own decorations on
   type=search, which have to be turned off or they sit on top of ours. */
input[type=search] {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394aacb' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.6-3.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px 50%;
  background-size: 18px 18px;
  padding-left: 42px;
}
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* New-chat picker: a tappable list of people with a tick when selected. */
.pick-row {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: none; border: 0; border-radius: var(--radius-sm);
  padding: 10px 12px; color: var(--ink); font-size: 15px; font-weight: 600;
  text-align: left; min-height: 0; cursor: pointer; justify-content: flex-start;
}
.pick-row:active { background: var(--glass); }
.pick-row.on { background: rgba(78, 201, 255, 0.14); color: #fff; }
.pick-tick {
  margin-left: auto; width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--line); display: flex; align-items: center;
  justify-content: center; font-size: 13px; color: transparent;
}
.pick-row.on .pick-tick { background: var(--grad); border-color: transparent; color: #fff; }
.pick-count { font-size: 12.5px; color: var(--muted); margin: 10px 2px 0; }

/* Five items across has to stay readable on a 390px phone. */
.tabbar button { max-width: none; font-size: 10px; padding: 4px 1px; }
.tabbar button .ticon { font-size: 21px; }

/* Sender line inside a group-chat bubble. */
.bubble-who { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 800; opacity: .85; margin-bottom: 4px; }
/* Tapping the name above a message opens that person's profile. */
.bubble-who[data-who] {
  cursor: pointer; border-radius: 9px; padding: 1px 4px; margin-left: -4px;
  align-self: flex-start; -webkit-tap-highlight-color: transparent;
}
.bubble-who[data-who]:active { background: rgba(255, 255, 255, .12); }
.bubble-who.mine-who { justify-content: flex-end; opacity: .7; }
.avatar-xs { width: 20px; height: 20px; font-size: 9px; box-shadow: none; }


/* Add-to-home-screen guide: shown once, then dismissed for good. */
.install-tip { position: relative; border-color: rgba(78, 201, 255, 0.3); padding-right: 46px; }
.install-tip b { color: #fff; font-size: 15.5px; }
.tip-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  min-height: 0; padding: 0; border-radius: 50%; font-size: 14px;
  background: var(--glass-2); color: var(--muted); box-shadow: none; border: 1px solid var(--line);
}
.tip-steps { margin-top: 10px; display: grid; gap: 7px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.tip-steps b { color: var(--ink); font-size: inherit; }
.tip-key { font-family: -apple-system, sans-serif; }

/* The Profile tab wears the user's own picture. */
.tab-avatar {
  width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
}
.tab-initials { background: var(--grad); color: #fff; font-size: 9px; font-weight: 800; }

/* ---------- toolkit ---------- */
.tool-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0; padding: 13px 2px; color: var(--ink);
  font-size: 15.5px; font-weight: 600; text-align: left; min-height: 0;
  justify-content: flex-start; cursor: pointer; box-shadow: none;
}
.tool-row:last-child { border-bottom: none; }
.tool-row:active { background: var(--glass); }
.tool-icon {
  width: 34px; height: 34px; flex: none; border-radius: 9px;
  background: var(--glass-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.prayer-icon { background: rgba(150, 130, 255, 0.18); border-color: rgba(150, 130, 255, 0.35); }
.tool-name { flex: 1; min-width: 0; }

/* Prayer text: preserve the line breaks it was written with. */
.prayer-text { font-size: 16px; line-height: 1.65; color: var(--ink); white-space: pre-wrap; }
.prayer-heading { font-size: 19px; font-weight: 700; color: #fff; margin-bottom: 12px; }
/* The lead-in some prayers carry in the literature, before the prayer itself. */
.prayer-lead { font-size: 16px; line-height: 1.65; color: var(--ink); margin-bottom: 14px; }
/* Citations sit right-aligned and italic, the way they read on the page. */
.prayer-source {
  margin-top: 16px; font-size: 13px; line-height: 1.45; color: var(--muted);
  font-style: italic; text-align: right;
}

/* Saved entries */
.entry-list { padding: 4px 16px; }
.entry-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  padding: 13px 0; text-align: left; min-height: 0; justify-content: flex-start;
  color: var(--ink); cursor: pointer; box-shadow: none;
}
.entry-row:last-child { border-bottom: none; }
.entry-meta { flex: 1; min-width: 0; }
.entry-date { font-size: 15.5px; font-weight: 700; color: #fff; }
.entry-preview {
  font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Nightly wizard */
.wiz-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 12px; }
.wiz-count { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.wiz-title { font-size: 26px; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.wiz-bar { height: 4px; border-radius: 99px; background: var(--glass-2); margin: 12px 0 18px; overflow: hidden; }
.wiz-bar > div { height: 100%; background: var(--grad); border-radius: 99px; transition: width .25s ease; }
.wiz-date { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.wiz-date span { color: var(--muted); font-size: 14px; }
.wiz-date input { width: auto; min-height: 40px; }
.wiz-q { font-size: 20px; font-weight: 800; color: #fff; line-height: 1.35; margin-bottom: 16px; }
.wiz-yn { display: flex; gap: 12px; margin-bottom: 18px; }
.yn {
  flex: 1; background: var(--glass); border: 1px solid var(--line); color: var(--ink);
  box-shadow: none; font-size: 17px; font-weight: 700; gap: 10px;
}
.yn.on { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--glow); }
.yn-dot {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; display: flex; align-items: center;
  justify-content: center; font-size: 12px;
}
.yn.on .yn-dot { background: #fff; color: var(--blue); border-color: #fff; }
.wiz-label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.wiz-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }
.wiz-foot button { flex: 1; }

/* Spot check "Affects My" */
.affect-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  padding: 13px 2px; color: var(--ink); font-size: 15.5px; font-weight: 600;
  min-height: 0; cursor: pointer; box-shadow: none;
}
.affect-dot { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); flex: none; }
.affect-row.on .affect-dot { background: var(--grad); border-color: transparent; }
.affect-row.on { color: #fff; }

/* Gratitude lines */
.grat-list { padding: 6px 16px; }
.grat-line {
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: none; padding: 13px 2px; min-height: 0;
}
.grat-line:focus { box-shadow: none; border-bottom-color: var(--cyan); background: none; }

/* Saved gratitude lists read out in full, with their share button. */
.grat-card { padding: 16px; }
.grat-open {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 0 0 12px; min-height: 0; color: var(--ink); box-shadow: none; cursor: pointer;
}
.grat-items { font-size: 15px; line-height: 1.6; color: var(--ink); margin-top: 6px; }
.share-panel { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.share-results { margin-top: 8px; }

/* Spot check kind selector: four across, so the labels need to be tight. */
.sc-seg { margin-bottom: 6px; }
.sc-seg button { font-size: 12.5px; padding: 8px 2px; min-height: 42px; }

.insight-icon { background: rgba(255, 200, 64, 0.16); border-color: rgba(255, 200, 64, 0.3); }
.aa-icon { background: rgba(90, 200, 250, 0.15); border-color: rgba(90, 200, 250, 0.3); }

/* ---------------------------------------------------------------- settings */
/* Two buttons in a page header: on a narrow phone they wrap under each other
   rather than squeezing the title. */
.head-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

/* ------------------------------------------- reports, blocking, and leaving */
/* A card whose contents are either serious or irreversible: open reports, and
   deleting your own account. Marked by its edge rather than by its background,
   so it reads as "pay attention" without the text inside becoming harder to
   read than the rest of the screen. */
.danger-card { border-color: rgba(255, 128, 128, .32); }

/* Somebody this person has blocked, in Settings. */
.blockrow {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.blockrow:last-child { border-bottom: 0; }
.blockname {
  flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* One report, in Manage. What was said is quoted plainly and is NOT styled to
   look like a message - it is evidence being read, not a conversation. */
.reportrow {
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.reportrow:last-child { border-bottom: 0; }
.reportwho { display: flex; flex-direction: column; gap: 1px; font-size: 14.5px; }
.reportwho .hint { font-size: 11.5px; }
.reportsaid {
  margin-top: 7px; padding: 8px 10px;
  background: var(--glass-2); border-left: 3px solid var(--muted);
  border-radius: 4px 10px 10px 4px;
  font-size: 13.5px; line-height: 1.4;
  white-space: pre-wrap; word-wrap: break-word;
  /* Four lines of it. Enough to see what the report is about; Steering can
     open the conversation itself for the rest. */
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden;
}
.reportwhy { margin-top: 6px; font-size: 13px; color: var(--muted); font-style: italic; }

.notice-box {
  background: rgba(255, 200, 64, 0.1); border: 1px solid rgba(255, 200, 64, 0.28);
  border-radius: 12px; padding: 12px 14px; font-size: 14px;
}
.set-state { font-size: 15px; }
.set-state.on b { color: #7ee2a8; }

/* The preference cards stay readable but visibly inactive until notifications
   are actually switched on, so nobody sets a reminder that can't arrive. */
.set-dim { opacity: 0.55; }

.checkrow {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; cursor: pointer;
  font-size: 14px; line-height: 1.45;
}
.checkrow + .checkrow { border-top: 1px solid rgba(255, 255, 255, 0.06); }
.checkrow input[type=checkbox] { width: 20px; height: 20px; flex: none; margin-top: 1px; accent-color: var(--accent); }

/* Prayer page actions run the full width, the way they read on a phone. */
.prayer-actions { display: flex; flex-direction: column; gap: 10px; }
.prayer-actions > button { width: 100%; justify-content: center; }

/* ------------------------------------------------------- insight meeting sheet */
/* Read aloud at meetings, so it is set for reading at arm's length: generous
   line height, and step numbers that stay put in their own column while the
   text wraps beside them. */
.sheet-para { font-size: 16px; line-height: 1.65; color: var(--ink); }
.sheet-para + .sheet-para { margin-top: 14px; }
.sheet-steps + .sheet-para, .sheet-bullets + .sheet-para { margin-top: 16px; }

/* Bullets in a meeting guide: read from the chair, so they want room. */
.sheet-bullets { margin: 12px 0 4px; padding: 0 0 0 20px; list-style: none; }
.sheet-bullets li {
  position: relative; padding: 0 0 10px 0; font-size: 16px; line-height: 1.6; color: var(--ink);
}
.sheet-bullets li::before {
  content: "\2022"; position: absolute; left: -18px; top: 0; color: var(--accent); font-weight: 700;
}

/* A blank to be said aloud - a name, on the night. A rule rather than a row
   of underscores, so it can never run off the side of a narrow screen. */
.blank {
  display: inline-block; min-width: 92px; max-width: 100%;
  border-bottom: 1.5px solid var(--muted); margin: 0 3px; vertical-align: baseline;
}
.sheet-steps { margin: 18px 0 4px; padding: 0; list-style: none; counter-reset: step; }
.sheet-steps li {
  counter-increment: step; position: relative; padding: 0 0 14px 34px;
  font-size: 16px; line-height: 1.6; color: var(--ink);
}
.sheet-steps li::before {
  content: counter(step) "."; position: absolute; left: 0; top: 0;
  width: 28px; text-align: right; font-weight: 700; color: var(--accent);
}
.sheet-closing {
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 15px; line-height: 1.65; color: var(--ink);
}
.sheet-closing + .sheet-closing { border-top: 0; padding-top: 0; margin-top: 12px; }

/* Where a step is read in different words than the source prints it, the page
   says so rather than leaving the reader to notice. */
.sheet-note {
  margin-top: 16px; padding: 10px 12px; border-radius: 10px;
  background: rgba(255, 200, 64, 0.09); border: 1px solid rgba(255, 200, 64, 0.22);
  font-size: 12.5px; line-height: 1.5; color: var(--ink);
}
/* Copyright and the pointer back to the book, as printed on the sheet. */
.sheet-credit {
  margin-top: 12px; font-size: 11px; line-height: 1.5; color: var(--muted); text-align: center;
}
.sheet-credit + .sheet-credit { margin-top: 6px; }

/* A memo's To / From, and the stacked lines inside one - the powers given, the
   choices offered, the laws repeated back. Lines, not a list: they are read
   down the page rather than counted off. */
.sheet-memohead {
  display: grid; gap: 4px; margin-bottom: 18px; padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 15px; color: var(--ink);
}
.sheet-memohead span {
  display: inline-block; min-width: 54px;
  color: var(--muted); font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  font-size: 11.5px;
}
.sheet-lines {
  margin: 14px 0; padding-left: 14px; border-left: 2px solid var(--line);
  display: grid; gap: 7px;
  font-size: 15.5px; line-height: 1.5; color: var(--ink);
}
.sheet-big {
  margin: 22px 0 6px; padding: 16px 14px; border-radius: 14px;
  background: var(--glass-2); border: 1px solid var(--line);
  text-align: center; font-size: 15px; font-weight: 800;
  letter-spacing: .03em; color: #fff;
}

/* ---------------------------------------------------------------- markdown */
/* Feed posts. Kept close to the surrounding text so a formatted post reads as
   a post and not as a web page that wandered in. */
.post-body.md > *:first-child { margin-top: 0; }
.post-body.md > *:last-child { margin-bottom: 0; }
.post-body.md p { margin: 0 0 10px; line-height: 1.6; }
.post-body.md .md-h { color: #fff; font-weight: 700; margin: 14px 0 8px; line-height: 1.35; }
.post-body.md h3.md-h { font-size: 19px; }
.post-body.md h4.md-h { font-size: 17px; }
.post-body.md h5.md-h { font-size: 15px; }
.post-body.md .md-list { margin: 0 0 10px; padding-left: 22px; }
.post-body.md .md-list li { margin-bottom: 5px; line-height: 1.55; }
.post-body.md .md-quote {
  margin: 0 0 10px; padding: 4px 0 4px 12px; border-left: 3px solid var(--accent);
  color: var(--muted); font-style: italic;
}
.post-body.md .md-hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.post-body.md code {
  background: rgba(255, 255, 255, 0.09); border-radius: 5px; padding: 1px 5px;
  font-size: 0.92em; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.post-body.md a { color: var(--accent); text-decoration: underline; overflow-wrap: anywhere; }

/* The same formatting inside a message. A bubble is not a post: only the
   inline marks reach it, so this is only what those need.
   Your own bubbles are a bright blue gradient and everyone else's are dark
   glass, so a link cannot be one colour. It takes the text colour it is
   sitting on and earns its underline instead - readable on both, and never
   the accent blue on a blue bubble, which is close to invisible. */
.bubble code {
  background: rgba(255, 255, 255, 0.16); border-radius: 5px; padding: 1px 5px;
  font-size: 0.92em; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.bubble a { color: inherit; text-decoration: underline; overflow-wrap: anywhere; }
.bubble.theirs a { color: var(--accent); }
.bubble s { opacity: 0.75; }

/* Formatting cheat sheet under the composer. */
.md-help {
  margin-top: 8px; font-size: 11.5px; line-height: 1.6; color: var(--muted);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ post pictures */
.post-imgs { margin-top: 12px; display: grid; gap: 6px; }
.post-imgs.one { grid-template-columns: 1fr; }
.post-imgs.many { grid-template-columns: 1fr 1fr; }
.post-imgs img {
  width: 100%; border-radius: 12px; display: block;
  background: rgba(255, 255, 255, 0.04);
}
.post-imgs.one img { max-height: 460px; object-fit: contain; }
.post-imgs.many img { aspect-ratio: 1; object-fit: cover; }

.post-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.post-thumb { position: relative; width: 74px; height: 74px; }
.post-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; display: block; }
.thumb-x {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; min-height: 0;
  border-radius: 50%; padding: 0; font-size: 12px; line-height: 1;
  background: #1b2547; border: 1px solid var(--line); color: var(--ink); box-shadow: none;
}

/* ---------------------------------------------------------- post requests */
.req-avatar { background: rgba(255, 200, 64, 0.16); font-size: 18px; }
.ok-tag { color: #7ee2a8; }
.no-tag { color: #ff8f8f; }

/* --------------------------------------------------- toolkit: select/view */
.pick-box {
  flex: none; width: 22px; height: 22px; border-radius: 6px; margin-right: 10px;
  border: 1.5px solid var(--line); background: rgba(255, 255, 255, 0.05);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--accent); font-weight: 700;
}
.entry-row.picked .pick-box, .grat-card.picked .pick-box {
  border-color: var(--accent); background: rgba(90, 160, 255, 0.18);
}
.grat-card.picked, .entry-row.picked { background: rgba(90, 160, 255, 0.07); }

/* A saved entry read in full. */
.view-list { margin: 0; padding-left: 24px; }
.view-list li { padding: 5px 0; font-size: 16px; line-height: 1.55; color: var(--ink); }
.view-q { padding: 12px 0; border-bottom: 1px solid var(--line); }
.view-q:last-child { border-bottom: 0; }
.view-qtext { font-size: 13px; color: var(--muted); margin-bottom: 5px; line-height: 1.45; }
.view-note { font-size: 16px; line-height: 1.6; color: var(--ink); white-space: pre-wrap; }
.view-ans { font-size: 15px; font-weight: 700; margin-bottom: 5px; }
.view-ans.yes { color: #ffcf6b; }
.view-ans.no { color: #7ee2a8; }
.view-type {
  display: inline-block; margin-bottom: 10px; padding: 3px 10px; border-radius: 999px;
  background: rgba(90, 160, 255, 0.16); border: 1px solid rgba(90, 160, 255, 0.3);
  font-size: 12px; font-weight: 700; color: var(--ink);
}

/* ------------------------------------------------------- goal checklist */
/* Three parts of a life, divided by rules the way the sheet divides the page. */
.goal-sheet { margin-top: 4px; }
.goal-sec { padding: 14px 0; border-bottom: 1px solid var(--line); }
.goal-sec:first-child { padding-top: 4px; }
.goal-sec:last-child { border-bottom: 0; padding-bottom: 2px; }
.goal-sec-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 9px;
}
.goal-items { list-style: none; margin: 0; padding: 0; }
.goal-items li {
  display: flex; align-items: flex-start; gap: 9px; padding: 5px 0;
  font-size: 16px; line-height: 1.5; color: var(--ink);
}
.goal-items li.done .goal-text { color: var(--muted); text-decoration: line-through; }
.goal-tick {
  flex: none; width: 20px; height: 20px; border-radius: 6px; margin-top: 1px;
  border: 1.5px solid var(--line); display: inline-flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700; color: var(--accent);
}
.goal-items li.done .goal-tick { border-color: var(--accent); background: rgba(90, 160, 255, 0.18); }
.goal-text { min-width: 0; overflow-wrap: anywhere; }
.goal-empty { padding: 2px 0; }

.goal-term {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  background: rgba(90, 160, 255, 0.16); border: 1px solid rgba(90, 160, 255, 0.3);
  font-size: 12px; font-weight: 700; color: var(--ink);
}
.goal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* The editor */
.goal-edit .cardtitle { margin-bottom: 4px; }
.goal-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.goal-row .goal-input { flex: 1; min-width: 0; margin: 0; }
.goal-tick-btn {
  flex: none; width: 30px; height: 30px; min-height: 0; padding: 0; border-radius: 8px;
  background: rgba(255, 255, 255, 0.05); border: 1.5px solid var(--line);
  color: var(--accent); font-size: 14px; font-weight: 700; box-shadow: none;
}
.goal-tick-btn.on { border-color: var(--accent); background: rgba(90, 160, 255, 0.2); }
.goal-x {
  flex: none; width: 30px; height: 30px; min-height: 0; padding: 0; border-radius: 8px;
  background: none; border: 0; color: var(--muted); font-size: 14px; box-shadow: none;
}
.goal-add { margin-top: 4px; }
.card-inline.goal-date { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.card-inline.goal-date input { margin: 0; }
.on-profile {
  font-size: 11px; font-weight: 700; color: var(--accent); margin-left: 6px;
  text-transform: uppercase; letter-spacing: 0.04em;
}

/* ------------------------------------------------- the notifications ask */
/* Shown once per device, just after signing in. A sheet rather than a banner:
   it wants an answer, and the answer has to come from a real tap. */
.ask-back {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end;
  justify-content: center; background: rgba(4, 8, 22, 0.66);
  padding: 16px; padding-bottom: calc(16px + var(--sab));
  animation: askin 0.22s ease-out;
}
@keyframes askin { from { opacity: 0; } to { opacity: 1; } }
.ask-card {
  width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px 20px; text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
.ask-card b { color: #fff; font-size: 18px; }
.ask-icon { font-size: 34px; margin-bottom: 8px; }
@media (min-width: 560px) { .ask-back { align-items: center; } }

/* ---------------------------------------------------------------- chat head */
/* Pinned to the top of the window so the name of whoever you are talking to -
   and the way into a group's members and logo - stays reachable however far
   down the conversation you are. Sticky rather than fixed, so it scrolls with
   the page's own max-width column instead of fighting the iOS viewport. */
/* One compact row: back, who you are talking to, and that is all. The screen
   belongs to the conversation, so the header takes as little of it as it can.
   The notch clearance goes on the TOP - it was going on the bottom as well,
   which is where sixty pixels of empty space in the middle of the screen was
   coming from. */
.chathead {
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top, 0px) + 7px) 12px 7px;
  background: rgba(11, 20, 48, 0.98);
  border-bottom: 1px solid var(--line);
}
/* The whole block is the way to their profile, so it behaves like one thing
   you can press rather than a name with a picture beside it. */
.chathead-main {
  display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1;
  cursor: pointer; border-radius: 12px; padding: 2px 4px; margin: -2px -4px;
  -webkit-tap-highlight-color: transparent;
}
.chathead-main:active { background: var(--glass-2); }
.chathead-text { min-width: 0; }
.chathead-name {
  background: none; border: 0; padding: 0; box-shadow: none; min-height: 0;
  font-size: 16.5px; font-weight: 700; letter-spacing: -0.01em; color: #fff;
  text-align: left; display: block; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chathead-sub {
  font-size: 11px; color: var(--muted); margin-top: 1px;
  display: flex; align-items: center; gap: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chathead-actions { display: flex; gap: 6px; flex: none; }
/* The header's own buttons are small and quiet - they are not the point of
   the screen. */
.chathead .btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.chathead .avatar-sm, .chathead .avatar { width: 34px; height: 34px; font-size: 12px; }

/* -------------------------------------------------------------- reactions */
/* A bubble and its reactions travel together, so a chip sits under the message
   it belongs to and on the same side of the conversation. */
.bubble-wrap { display: flex; flex-direction: column; max-width: 82%; }
.bubble-wrap.mine { align-self: flex-end; align-items: flex-end; }
.bubble-wrap.theirs { align-self: flex-start; align-items: flex-start; }
.bubble-wrap:has(.react-row) { margin-bottom: 4px; }

/* A message on its way to the server, and one that did not make it. */
.bubble-wrap.pending .bubble { opacity: 0.62; }
.bubble-wrap.failed .bubble { opacity: 1; background: rgba(255, 120, 120, 0.22); border: 1px solid rgba(255, 120, 120, 0.5); box-shadow: none; }
.bubble-wrap .bubble { max-width: 100%; align-self: auto; }
/* Stops iOS offering "Copy / Look Up" over a long press we are handling. */
.bubble-wrap .bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* Sits UNDER its bubble with room to breathe. A negative margin here tucked
   the chips up over the message above and into the one below. */
.react-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 4px 2px; }
.react-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 0;
  padding: 2px 8px; border-radius: 999px; font-size: 13px; line-height: 1.5;
  background: var(--glass-2); border: 1px solid var(--line); color: var(--ink);
  box-shadow: none;
}
.react-chip.mine { border-color: var(--accent); background: rgba(90, 160, 255, 0.2); }
.react-chip span { font-size: 11px; font-weight: 700; opacity: 0.85; }

/* The picker a long press opens. */
.react-pop {
  position: fixed; z-index: 70; display: flex; gap: 2px; padding: 6px;
  /* Ten of them will not sit on one line on a narrow phone, so it wraps to a
     second row rather than running off the side. The radius is kept modest so
     it still looks right either way. */
  flex-wrap: wrap; justify-content: center;
  max-width: min(336px, calc(100vw - 24px));
  background: #1a2450; border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: scale(0.86); transform-origin: center bottom;
  transition: opacity 0.14s ease-out, transform 0.14s ease-out;
}
.react-pop.in { opacity: 1; transform: scale(1); }
.react-pop button {
  background: none; border: 0; box-shadow: none; min-height: 0;
  padding: 5px 6px; font-size: 23px; line-height: 1; border-radius: 50%;
}
.react-pop button:active { background: rgba(255, 255, 255, 0.12); }

/* --------------------------------------------------------- suggestion box */
.suggest-row { text-align: left; }
.suggest-row b { color: #fff; }

/* The pointer to the Questions and Answers page. Same shape as the install
   tip - a card you can put away for good. No chevron and no outward arrow on
   the right: the dismiss button already lives in that corner, and two marks
   fighting over one edge is both cluttered and easy to mis-tap. The wrapper
   exists only to hang that button off, since a button cannot legally live
   inside a link. */
.qna-wrap { position: relative; }
.qna-tip {
  display: block; text-decoration: none; padding-right: 52px;
  border-color: rgba(78, 201, 255, 0.3);
}
.qna-tip b { color: #fff; font-size: 15px; }

/* The Messages badge announcing itself as a message lands, rather than just
   appearing at the next repaint. */
@keyframes badgepop {
  0%   { transform: scale(0.4); opacity: 0; }
  55%  { transform: scale(1.28); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.tbadge.pop { animation: badgepop 0.42s cubic-bezier(0.2, 1.3, 0.4, 1); }


/* ---------------------------------------------------------- the chat screen */
/* iOS reports the layout viewport at the wrong size while a keyboard is up, so
   ANY element told to sit at `bottom: 0` ends up stranded in the middle of the
   screen. There is no arguing with it, so the chat screen stops asking: it is
   one box, sized and placed from the visible viewport (the only measurement
   iOS gets right), laid out as a column. The composer is at the bottom because
   it is the last child of that column - not because it was told where the
   bottom is. The message list is the part that scrolls. */
/* The chat is an ordinary page that scrolls, not a fixed box.
   That is the whole point. On this phone iOS neither shrinks the viewport for
   the keyboard nor reports it through visualViewport, so there is NOTHING to
   measure and no arithmetic that can place the composer above it. But iOS has
   always done one thing reliably: when you focus an input in a normal
   scrolling document, it scrolls that input into view above the keyboard.
   So the composer is simply the last thing on the page, and iOS puts it where
   it belongs. No measuring, no fixed positioning, nothing to get wrong. */
/* A column at least as tall as the screen. With only a message or two in it the
   conversation used to end wherever the last bubble did, leaving the composer
   stranded near the top with a field of empty blue under it. The message list
   takes up whatever slack is left, so the composer lands at the bottom without
   anything here being told where the bottom is - it is still simply the last
   child, exactly as described above.
   svh rather than dvh on purpose: the small viewport height does not move when
   the keyboard opens, so this is a constant. A height that changed with the
   keyboard would restart the very layout fight this whole section exists to
   avoid. */
/* A conversation is a PANEL, not a long page.
   It used to be a tall block that the window scrolled, which meant the app had
   to keep working out how tall the window really was (--vph), where iOS had
   put the tab bar, how far the layout ran on past the bottom of the screen,
   and where the keyboard was - and then scroll the page to the right place
   three times over half a second in case any of that moved. Every one of those
   corrections is a thing that can be seen happening.

   Pinned to the window instead, with the message list scrolling inside it, all
   of that goes away: the page has no scroll of its own to get wrong, the
   composer sits at the bottom because it is the last row of a flex column, and
   going to the newest message is one assignment on an element. */
.chatscreen {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.chatscreen .chathead { flex: none; }

/* The only thing on the screen that scrolls. min-height:0 is what lets a flex
   child actually be shorter than its contents - without it the list refuses to
   shrink and pushes the composer off the bottom. */
.chatscroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* A flick that reaches the top of the conversation stops there rather than
     dragging the page behind it about. */
  overscroll-behavior: contain;
  /* Scroll anchoring off. Left on, the browser moves scrollTop ITSELF whenever
     the list changes height, in the same frame, before any of this code gets a
     look in. Measured: appending the placeholder bubble on send moved the list
     3400 -> 3465 on its own, so the glide that was supposed to carry those 65px
     found 3px left to do and the send still read as a jump.
     Nothing is lost by turning it off. Keeping your place when earlier messages
     load in above is the one thing anchoring is for here, and loadOlder already
     does that by hand - so the two were correcting the same scroll twice. */
  overflow-anchor: none;
  display: flex;
  flex-direction: column;
}

/* A short conversation sits at the BOTTOM, against the box you type into,
   which is where every other chat app puts it. margin-top:auto rather than
   justify-content:flex-end on the scroller - flex-end on a scrolling box puts
   the overflow out of the top where it cannot be reached. */
.chatinner { margin-top: auto; }

.chatscreen .chatbar { flex: none; }

/* The name is simply the first row of the panel now. It stays put because
   nothing under it moves it - no stickiness, no z-index, no scrolling past. */
.chatscreen .chathead { margin: 0 0 4px; }
.chatscreen .chat { padding: 8px 14px 10px; }

/* Sits above the oldest message on screen, and only when there is something
   older to fetch. A conversation arrives a page at a time however long it has
   been going on, so this is the way back through the years of it. */
.chat-older {
  display: block; width: calc(100% - 28px); margin: 10px 14px 0;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--glass-2); color: var(--muted);
  font-size: 13px; font-weight: 600; text-align: center;
}
.chat-older:disabled { opacity: .6; }

/* The foot of a list that arrives a page at a time - the archive, and the
   saved inventories and lists. Nothing is ever out of reach; it is only not
   all fetched at once. */
.list-more {
  display: block; width: 100%; margin: 4px 0 10px;
  padding: 12px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--glass-2); color: var(--muted);
  font-size: 14px; font-weight: 600; text-align: center;
}
.list-more:disabled { opacity: .6; }
.chatscreen .chatbar {
  position: static; max-width: none; margin: 0;
  /* No home-indicator inset here. The tab bar sits below the composer and its
     reserved strip already covers that inset - adding it again is what left
     the composer floating a finger's width above the bar. */
  padding: 8px 14px;
  background: none;}

/* Room for the tab bar under the composer, so the last thing on the page is
   not hidden behind it - plus --below, which is how far the layout runs on past
   the bottom of the screen when it does (see fitToScreen). Without that term
   the end of a long chat can only ever scroll to the bottom of the LAYOUT,
   which is off the screen, and the composer cannot be reached at all. */
/* Pinned to the window, ending where the tab bar begins. Nothing here scrolls;
   the list inside does. */
body.in-chat #app {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: calc(var(--tabbar-real) + var(--below, 0px));
  padding: 0;
  overflow: hidden;
}
/* While the keyboard is up, the panel is laid over exactly what can be seen -
   read from the browser, not worked out. See trackKeyboard(): --vv-top is
   where the visible area starts and --vv-h is how tall it is.

   Pinning to the layout viewport is not enough here. With a field focused and
   nothing left on the page to scroll, iOS slides the VISUAL viewport to reveal
   the field, and a fixed panel - anchored to the layout viewport, which did not
   move - goes up off the top of the screen. That is the missing chat header and
   the composer stranded above the keyboard.

   Setting top and height from the visible area covers both kinds of phone with
   one rule: where iOS shrinks the layout viewport for the keyboard, the top is
   0 and the height is what is left; where it does not, the top is however far
   it panned and the height already excludes the keyboard. --kb is not needed
   for the panel any more - vv.height has the keyboard taken off it either way. */
body.kb-open.in-chat #app {
  top: var(--vv-top, 0px);
  bottom: auto;
  height: var(--vv-h, 100%);
}
body.kb-open .tabbar { display: none; }

/* And with the bar gone, nothing is covering the screen underneath any more.
   .behind is a still of the screen you pushed in FROM - the list of
   conversations - kept full-screen so it can slide as you drag a chat back
   off. The chat panel does not cover all of it; the tab bar did, which is why
   this was never visible until the keyboard hid the bar. Then 336px of the
   Messages list appeared below the composer, which is what "why is it doing
   this" was a picture of.
   Nobody is dragging a conversation off the stack while they are typing into
   it, so while the keyboard is up the still has no job. */
body.kb-open .behind { display: none; }

/* --------------------------------------------- room to type, on every screen */
/* iOS lifts a focused field above the keyboard by SCROLLING the page. If the
   page has no scroll range left - and a short one has none - there is nothing
   for it to scroll, so the field simply stays where it is and the keyboard
   covers it. That is one bug, not several: it was the composer you could not
   see while typing in a chat, and it was every other form in the app too.
   trackKeyboard has always measured the keyboard into --kb; nothing used it.
   Now everything does.
   --kb is 0 on phones where iOS shrinks the layout viewport itself, and on
   those innerHeight (and so --vph) has already come down by the same amount -
   so both cases arrive at the same answer without needing to be told apart. */
/* ...but NOT in a conversation. A conversation is a pinned panel that is laid
   over the visible area itself, so the composer is already sitting on top of
   the keyboard - and this padding would lift it off by 28px plus the height of
   the keyboard, which is the composer left stranded in the middle of the
   screen with a band of empty page under it. This rule is for the ordinary
   scrolling screens, which is where it was always aimed. */
body.kb-open:not(.in-chat) #app {
  padding-bottom: calc(var(--kb, 0px) + 28px);
}

/* The chat screen no longer sizes itself from measurements at all. It is
   pinned to the window and the list inside it scrolls, so where the keyboard
   is only decides where the panel ends - see body.kb-open.in-chat #app above. */


/* ---------------------------------------------------------- inline editing */
/* Editing happens where the text already is, in a box the size of what is
   being written - not in a one-line browser prompt with the rest of the post
   hidden behind an ellipsis. Deliberately built to look like the composer, so
   editing something feels like writing it did. */
.inline-edit {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 2px 0;
}
.inline-edit .ie-text {
  width: 100%; margin: 0; resize: none; overflow-y: auto;
  min-height: 76px; line-height: 1.55;
}
.inline-edit .md-help { margin-top: 8px; }
.inline-edit .row { flex-wrap: wrap; }
.inline-edit .ie-save { flex: 1; min-width: 130px; }

/* The time and what it means, on one line. */
.time-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.time-row .hint { margin: 0; }

/* ---------------------------------------------------------------- lightbox */
/* A photo full size over the app. Opening one in a new window was a dead end:
   a home-screen app has no address bar and no back button, so the only way
   back to the conversation was closing the whole app. */
.lightbox {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 5, 16, 0.94);
  padding: calc(var(--safe-top) + 12px) 12px
           calc(var(--sab) + 12px);
  opacity: 0; transition: opacity 0.16s ease-out;
}
.lightbox.in { opacity: 1; }
.lightbox img, .lightbox video {
  max-width: 100%; max-height: 100%;
  object-fit: contain; border-radius: 10px;
}
/* The caption under a clip opened full screen. */
.lb-cap {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--sab) + 16px);
  padding: 0 20px; text-align: center;
  font-size: 14px; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.8);
}
.lb-close {
  position: absolute; top: calc(var(--safe-top) + 10px); right: 12px;
  width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff; font-size: 17px; line-height: 1; box-shadow: none;
}


/* A built-in chat a graduate has stepped out of: still listed, clearly not
   theirs any more, and one tap from walking back in. */
.thread-row.left-room { opacity: 0.55; }
.rejoin-btn {
  flex: none; min-height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 10px;
}


/* ----------------------------------------------------------- Steps 8 and 9 */
/* One list, two screens. Step 8 is the writing-down; Step 9 is the working
   through. Both are laid out as rows that are comfortable to hit with a thumb,
   because that is how this gets used. */

/* A second line under a tool's name, for the two that need one. */
.tool-row .tool-sub {
  display: block; font-weight: 500; font-size: 12px;
  color: var(--muted); margin-top: 2px;
}

/* ---- Step 8: the list ---- */
.amend-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* The whole row is the field. A bordered input sitting inside a bordered card
   was a box within a box, and a cramped one - so the row itself carries the
   border and the background, the name sits in it with nothing around it, and
   the row lights up as one thing when it is being typed in. */
.amend-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.amend-item:focus-within {
  border-color: var(--cyan);
  background: rgba(9, 18, 44, 0.5);
  box-shadow: 0 0 0 3.5px rgba(78, 201, 255, 0.18);
}
/* A name that has been ticked stays perfectly readable - it is a list of
   people, not a list of chores, and greying someone out reads wrong. The tick
   is the whole signal. */
.amend-item.done { background: rgba(108, 233, 166, 0.05); }

.amend-check {
  flex: none; width: 34px; height: 34px; min-height: 0; padding: 0;
  border-radius: 11px; font-size: 16px; line-height: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line); color: #6ce9a6; box-shadow: none;
}
.amend-item.done .amend-check {
  background: rgba(108, 233, 166, 0.18);
  border-color: rgba(108, 233, 166, 0.5);
}

/* Stripped right back, because the row around it is doing the work. */
.amend-name-input,
.amend-name-input:focus {
  flex: 1; min-width: 0;
  background: none; border: 0; box-shadow: none; outline: none;
  min-height: 34px; padding: 0; border-radius: 0;
  font-size: 16px; font-weight: 600; color: #fff;
}
.amend-name-input::placeholder { font-weight: 500; }

/* iOS paints a field it has offered to autofill with a background of its own,
   which came out as a black bar straight across the row and ignores any
   background set the normal way. The long transition is what holds it off -
   the colour is only applied after the delay, which never arrives - and
   text-fill-color keeps the name readable meanwhile. */
.amend-name-input:-webkit-autofill,
.amend-name-input:-webkit-autofill:hover,
.amend-name-input:-webkit-autofill:focus,
.amend-name-input:-webkit-autofill:active {
  -webkit-text-fill-color: #fff;
  caret-color: #fff;
  transition: background-color 100000s ease-in-out 0s;
}

.amend-del {
  flex: none; width: 32px; height: 32px; min-height: 0; padding: 0;
  border-radius: 10px; font-size: 16px; line-height: 1;
  background: none; border: 1px solid transparent;
  color: var(--muted); box-shadow: none;
}
.amend-del:active { background: rgba(255, 90, 110, 0.14); color: #ff9aa8; }

/* ---- the two choices, as one control ---- */
.amend-seg {
  display: flex; gap: 6px; margin-top: 8px;
}
.amend-seg button {
  flex: 1; min-height: 36px; padding: 0 10px;
  font-size: 12.5px; font-weight: 700; border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--muted); box-shadow: none;
}
.amend-seg button.on {
  background: var(--grad); border-color: transparent;
  color: #fff; box-shadow: var(--glow);
}
.amend-seg-wide { margin: 0 0 10px; }

/* ---- Step 9: a person, and how far it has got ---- */
.amend9-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

.amend9 {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px 12px;
}
.amend9-open {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; box-shadow: none; padding: 0;
  min-height: 0; text-align: left; color: inherit;
}
.amend9-open:active { transform: scale(.99); }
.amend9-main { flex: 1; min-width: 0; }
.amend9-name { display: block; font-weight: 800; font-size: 15px; color: #fff; }
.amend9-preview {
  display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- the journal ---- */
/* As close to a plain sheet of paper as a phone gets: the name, the two
   choices, and then nothing but what is being written. The box is the page -
   it fills what is left of the screen, measured the same way the chat screen
   is, so it is never short of the tab bar or hidden behind it. */
.amendpage {
  display: flex; flex-direction: column;
  min-height: calc(var(--vph) - var(--tabbar-real));
}
/* The same box the rest of the app edits in - the one built for writing in,
   with room to see what you have written - rather than a bare field. It keeps
   growing with the writing instead of stopping at a fixed height, because this
   is somewhere people write paragraphs, and it has no Save button because it
   does not need one. */
.amend-notes {
  flex: 1 0 auto; width: 100%; min-height: 260px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px; margin: 2px 0 0; resize: none;
  font-size: 16px; line-height: 1.65; color: var(--ink);
  font-family: inherit;
}
.amend-notes:focus {
  outline: none;
  border-color: rgba(88, 210, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(88, 210, 255, 0.12);
}
.amend-notes::placeholder { color: var(--muted); opacity: .75; }

/* Says what has happened to what you wrote, and otherwise stays out of it. */
.amend-status {
  min-height: 16px; margin-top: 8px;
  font-size: 12px; color: var(--muted); text-align: right;
}
.amend-status.ok { color: #6ce9a6; }
.amend-status.bad { color: #ff9aa8; }

/* ------------------------------------------------- online, and message actions */

/* Whether somebody is about. A dot and three words - it is a courtesy, not a
   readout, and it should never be the loudest thing on a profile. */
.seen-line { margin-top: 4px; }
.seen { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.seen .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.seen.on { color: #6ce9a6; font-weight: 700; }
.seen.on .dot { background: #6ce9a6; box-shadow: 0 0 0 3px rgba(108, 233, 166, 0.18); }

/* The hold-down menu. The emoji row is what it always was; the actions sit
   under it behind a divider so reacting stays the obvious thing to do. */
.react-row-pick { display: flex; gap: 2px; }
.msg-acts {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.msg-acts button {
  flex: 1; min-height: 34px; padding: 0 12px; white-space: nowrap;
  font-size: 13px; font-weight: 700; border-radius: 9px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line);
  color: var(--ink); box-shadow: none;
}
.msg-acts button.warn { color: #ff9aa8; }
.msg-acts button:active { background: rgba(255, 255, 255, 0.14); }

/* Invite sheet: a code big enough to scan across a table, on white because
   that is what a camera expects, and the steps under it in order. */
.head-actions { display: flex; gap: 8px; align-items: center; }
.invite-back { overflow-y: auto; align-items: flex-start; }
.invite-card {
  width: 100%; max-width: 420px; margin: auto;
  background: var(--card, rgba(12, 22, 54, 0.98));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 18px; position: relative;
}
.invite-title { font-size: 21px; margin: 0 34px 4px 0; }
.invite-sub { margin-top: 0; }
.invite-qr {
  background: #fff; border-radius: 14px; padding: 12px;
  margin: 14px auto 10px; width: fit-content; max-width: 100%;
  display: flex; align-items: center; justify-content: center;
}
.invite-qr svg { display: block; width: 210px; height: 210px; max-width: 100%; }
.invite-url {
  text-align: center; font-weight: 800; letter-spacing: .02em;
  font-size: 15px; color: #fff; margin-bottom: 16px;
}
.invite-stepstitle {
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.invite-steps { margin: 0 0 16px 18px; padding: 0; }
.invite-steps li { font-size: 14px; line-height: 1.55; margin-bottom: 7px; color: var(--ink); }

/* Six tabs rather than five, now that the Feed has a place of its own. The
   labels are the part that runs out of room first, so they lose a little size
   and are told not to wrap - a tab that breaks onto two lines makes the whole
   bar taller and shoves everything above it. */
.tabbar button {
  font-size: 9.5px;
  padding: 4px 1px;
  min-width: 0;
}
.tabbar button .ticon { font-size: 20px; }
.tabbar button > :not(.ticon):not(.tbadge):not(.tab-avatar) { white-space: nowrap; }

/* --------------------------------------------------------- phone on a profile */
/* An anchor rather than a button, because tel: is what makes iOS offer to
   place the call - styled to sit beside "Send a message" as an equal. */
.btn-call {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 8px 14px; border-radius: 13px;
  font-size: 14px; font-weight: 700; text-decoration: none;
  background: rgba(108, 233, 166, 0.14);
  border: 1px solid rgba(108, 233, 166, 0.45);
  color: #6ce9a6;
}
.btn-call:active { background: rgba(108, 233, 166, 0.24); }
.profile-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.phone-link { color: var(--cyan); text-decoration: none; }

/* The hold-down menu holds two rows now - the emoji, then the actions - so it
   stacks them. The wrap rule has to live on the emoji row itself: it was on the
   popup, and once the buttons were wrapped in a row of their own that row had
   nothing telling it to wrap, so eight emoji ran straight off both edges. */
.react-pop { flex-direction: column; align-items: stretch; }
.react-row-pick {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 2px; max-width: 100%;
}
.msg-acts { width: 100%; }

/* --------------------------------------------------- manage: today + graph */
/* Four across on a phone, because eight numbers in two tidy rows reads faster
   than eight in a column. Deliberately flatter than .stat - these are today's
   numbers, not the headline ones. */
.today-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.today-cell {
  background: var(--glass-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 4px; text-align: center;
}
.today-cell b {
  display: block; font-size: 19px; font-weight: 800; color: #fff;
  font-variant-numeric: tabular-nums;
}
.today-cell span {
  display: block; font-size: 10px; color: var(--muted); margin-top: 2px;
  line-height: 1.25; font-weight: 600;
}

.today-who {
  display: flex; gap: 8px; margin-top: 12px; padding-bottom: 4px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.today-person {
  flex: none; width: 78px; padding: 8px 4px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--glass-2); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.today-person .tp-name {
  font-size: 11px; font-weight: 700; color: #fff;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.today-person .tp-did { font-size: 9.5px; color: var(--muted); line-height: 1.2; }

/* The graph is fourteen stacked columns drawn out of divs. It has to survive a
   narrow phone, so the columns share the width rather than scrolling. */
.graph { position: relative; padding-top: 6px; }
.gpeak {
  position: absolute; top: 0; right: 0;
  font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.gcols { display: flex; align-items: flex-end; gap: 3px; height: 132px; }
.gcol { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.gbar-wrap { width: 100%; height: 96px; display: flex; align-items: flex-end; }
.gbar {
  width: 100%; border-radius: 4px 4px 2px 2px; overflow: hidden;
  display: flex; flex-direction: column-reverse;
  background: rgba(255, 255, 255, 0.06);
  transition: height .25s ease;
}
.gbar i { display: block; width: 100%; }
.gk-chat   { background: #6ea8ff; }
.gk-checks { background: #7ee2a8; }
.gk-rest   { background: #ffc840; }
.gday { font-size: 10px; color: var(--muted); margin-top: 5px; font-weight: 700; }
.gnum { font-size: 9px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 11px; }

.graph-key { display: flex; gap: 14px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.graph-key span { display: inline-flex; align-items: center; gap: 5px; }
.graph-key .gk { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* --------------------------------------------------- deleted posts archive */
.binned-line {
  margin-top: 10px; font-size: 12px; color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.07); padding-top: 8px;
}
.binned-card .post-body { opacity: .85; }


/* --------------------------------------------------- chat content (media grid)
   Square tiles, three across. A clip draws its own first frame as the
   thumbnail - the #t=0.1 on the source is what makes the browser seek far
   enough in to render a frame rather than showing black. */
.media-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 10px;
}
.media-cell {
  position: relative; padding: 0; border: 0; min-height: 0;
  aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--glass-2); box-shadow: none; cursor: pointer;
}
.media-cell img, .media-cell video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
/* Rearranging. The cell being carried is lifted off the page, so it is obvious
   which one is in your hand. The others simply take their new places as it
   passes - they are grid items being reordered, which is a layout change, and
   a transition cannot animate one. */
.media-grid.rearranging .media-cell { cursor: grab; }
.media-cell.lifted {
  /* No transition on this one - it is following a finger, and easing toward
     where the finger was a moment ago is exactly what lag feels like. */
  transition: none;
  z-index: 5; cursor: grabbing;
  box-shadow: 0 10px 26px rgba(4, 10, 30, 0.55);
  opacity: 0.92;
}
/* Nothing gets selected or long-press-magnified while a photo is being moved. */
body.no-select, body.no-select * {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* The mark that says "this one moves". */
.media-play {
  position: absolute; right: 6px; bottom: 5px;
  width: 21px; height: 21px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff; font-size: 9px; line-height: 21px; text-align: center;
  padding-left: 2px; pointer-events: none;
}


/* --------------------------------------------------- media held back
   A picture older than a month is not fetched until it is asked for. This is
   what sits in its place: cheap to draw, obvious what it is, and the same
   height whether it is standing in for a photo or a clip, so a conversation
   does not jump about as they load. */
.media-held {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 13px 14px; margin-bottom: 5px; min-height: 0;
  border: 1px dashed var(--line); border-radius: 13px;
  background: rgba(255, 255, 255, 0.05); box-shadow: none;
  color: var(--ink); font-size: 13.5px; font-weight: 600; text-align: left;
}
.media-held .held-icon { font-size: 21px; flex: none; }
.media-held .hint { font-weight: 500; font-size: 11.5px; }
.media-held:active { background: rgba(255, 255, 255, 0.1); }

/* The bulk button, beside "Load earlier messages" above the conversation. */
.load-old { margin-top: 0; }

/* The two buttons on your own memory, over the picture. */
.mem-actions {
  position: absolute; left: 0; right: 0;
  bottom: calc(var(--sab) + 52px);
  display: flex; gap: 10px; justify-content: center; padding: 0 20px;
}

/* A post's pictures open full size, so they say so on the way past. */
.post-imgs img { cursor: zoom-in; }

/* --------------------------------------------------- Desert Night Camo
   Matt Mayer wears this: his profile, his Sobriety page, and every post he
   writes in the Feed. Taken from the real pattern: a sand-coloured ground
   under a fine dark grid, with soft blotches showing through it.

   Deliberately a TEXTURE and not a repaint. The page keeps its own dark blue
   background and the cards keep their glass; the camo sits on top of them at
   low opacity, so it reads as fabric under the surface rather than a beige
   panel dropped onto a navy app. Everything is gradients - no image to load,
   and it stays sharp at any zoom.

   ::before carries the grid, ::after the blotches, so the two can be tuned
   without fighting each other, and neither can catch a tap.

   Two shapes wear it, and both are named on every rule: any card inside a
   container marked .dnc, and a post card marked .dnc itself. That is the whole
   interface - to put a new screen in camo, wrap it in a .dnc div and it
   inherits the pattern the other screens already have, with nothing here to
   edit. Keeping it to one pair of selectors is what stops the screens drifting
   into slightly different patterns. */
.dnc .card,
.post-card.dnc {
  position: relative;
  overflow: hidden;
  border-color: rgba(178, 164, 140, 0.42);
  background:
    linear-gradient(0deg, rgba(172, 158, 134, 0.10), rgba(172, 158, 134, 0.10)),
    var(--glass);
}

/* A pinned post keeps its gold edge. The camo rule sits later in this file
   than .post-card.pinned does and would otherwise take the gold away. */
.post-card.dnc.pinned { border-color: rgba(255, 200, 64, 0.40); }

.dnc .card::before,
.dnc .card::after,
.post-card.dnc::before,
.post-card.dnc::after,
.pcamo .card::before,
.pcamo .card::after,
.post-card.pcamo::before,
.post-card.pcamo::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* The grid. Two sets of lines at a 7px pitch, the dark grey-green of the real
   webbing. Strong enough to read as a pattern at arm's length, still open
   enough that text sits comfortably on top of it. */
.dnc .card::before,
.post-card.dnc::before {
  background-image:
    repeating-linear-gradient(0deg,
      rgba(34, 44, 39, 0.50) 0 1.5px, transparent 1.5px 7px),
    repeating-linear-gradient(90deg,
      rgba(34, 44, 39, 0.50) 0 1.5px, transparent 1.5px 7px);
}

/* The blotches under the grid - irregular and soft-edged, the sand showing
   through where the webbing thins out. */
.dnc .card::after,
.post-card.dnc::after {
  background-image:
    radial-gradient(38% 26% at 18% 22%, rgba(190, 174, 148, 0.20), transparent 70%),
    radial-gradient(30% 34% at 72% 14%, rgba(190, 174, 148, 0.16), transparent 72%),
    radial-gradient(44% 30% at 86% 62%, rgba(190, 174, 148, 0.18), transparent 70%),
    radial-gradient(34% 28% at 34% 78%, rgba(190, 174, 148, 0.19), transparent 72%),
    radial-gradient(26% 22% at 58% 46%, rgba(190, 174, 148, 0.14), transparent 74%);
}

/* Everything the card holds sits above the texture. Without this the pattern
   would be painted over the words rather than under them. */
/* Everything in a camo card sits above the pattern - EXCEPT the three-dots
   menu, which has its own place in the stack and must keep it.

   Without that exception this rule reached .post-more with `> *` and flattened
   it from `absolute; z-index: 3` to `relative; z-index: 1`, which broke two
   things on one account's posts and nobody else's:

   The dots left the top-right corner and dropped into the flow, landing on
   their own line above the post.
   
   And .post-actions - the Pin / Edit / Remove row - was lifted to z-index 1 by
   this same rule. Two siblings on the same z-index are decided by document
   order, and the actions row comes later, so it painted over the bottom of the
   open menu. The menu LOOKED fine; the taps went to the row underneath it, and
   Share Nationally could not be pressed at all. */
.dnc .card > *:not(.post-more),
.post-card.dnc > *:not(.post-more),
.pcamo .card > *:not(.post-more),
.post-card.pcamo > *:not(.post-more) { position: relative; z-index: 1; }

/* The stat tiles are cards in their own right and get the same treatment, one
   step quieter - three small boxes side by side show a pattern much more
   strongly than one big one does. */
.dnc .stat {
  position: relative;
  overflow: hidden;
  border-color: rgba(178, 164, 140, 0.36);
  background:
    linear-gradient(0deg, rgba(172, 158, 134, 0.07), rgba(172, 158, 134, 0.07)),
    var(--glass);
}
.dnc .stat::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg,
      rgba(34, 44, 39, 0.38) 0 1.5px, transparent 1.5px 7px),
    repeating-linear-gradient(90deg,
      rgba(34, 44, 39, 0.38) 0 1.5px, transparent 1.5px 7px);
}
.dnc .stat > * { position: relative; z-index: 1; }

/* The lines that divide a list - the details on a profile, the units on the
   Sobriety page - warmed to match. Both are borders on a plain --line grey,
   which reads cold against the sand. */
.dnc .kv-row { border-top-color: rgba(178, 164, 140, 0.22); }
.dnc .sober-row { border-bottom-color: rgba(178, 164, 140, 0.22); }

/* --------------------------------------------------- pink camo
   Roman Robinson wears this, in the same three places Matt Mayer wears his:
   his profile, his Sobriety page, and every post he writes in the Feed.

   Built the same way - the structure (what sits above the pattern, the
   three-dots exception) is shared with the desert camo above, so the two can
   never behave differently; only the pattern is its own.

   Unlike the desert camo this one IS a picture: the pattern he chose, a scan
   of the real fabric, shrunk to 720px and about 110KB. Hot pink, light pink,
   black and white is too particular a thing to imitate with gradients, and an
   imitation of somebody's chosen pattern is not their pattern.

   It is laid under a dark wash, the way the desert camo sits under the glass.
   Without one, white text on a white patch of camo is simply gone; with it,
   the pink still reads as pink and every word on the card stays legible. */
.pcamo .card,
.post-card.pcamo {
  position: relative;
  overflow: hidden;
  border-color: rgba(255, 110, 185, 0.55);
  background: #2a1030;
}
.post-card.pcamo.pinned { border-color: rgba(255, 200, 64, 0.40); }

/* The fabric. Covers the card rather than tiling - it is a scan, not a seamless
   tile, and the seams would show. Each card shows its own stretch of it. */
.pcamo .card::before,
.post-card.pcamo::before {
  background: url('/icons/camo-pink.jpg') center / cover no-repeat;
}

/* The wash that keeps the words readable. Light enough that the pink still
   reads as hot pink rather than maroon - measured against a first version at
   twice this, which turned the whole thing the colour of a bruise. */
.pcamo .card::after,
.post-card.pcamo::after {
  background: linear-gradient(180deg, rgba(20, 6, 30, 0.30), rgba(20, 6, 30, 0.42));
}

/* What keeps the words readable with the wash that light: a soft dark shadow
   behind every line of text, so a word crossing a white patch of the fabric
   still has an edge. And the quiet grey small print the rest of the app uses
   is brightened here, because grey on white-and-pink has nothing to stand on. */
.pcamo .card,
.post-card.pcamo,
.pcamo .stat { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 10px rgba(0, 0, 0, 0.45); }
.pcamo .hint,
.pcamo .who-sub,
.pcamo .profile-nick,
.pcamo .prof-line span,
.pcamo .stat span,
.post-card.pcamo .who-sub { color: #fbe6f3; }
/* Buttons keep their own colours and do not need the shadow. */
.pcamo .card button,
.pcamo .card .btn-sm,
.post-card.pcamo button { text-shadow: none; }

.pcamo .stat {
  position: relative;
  overflow: hidden;
  border-color: rgba(255, 110, 185, 0.45);
  background: #2a1030;
}
.pcamo .stat::before,
.pcamo .stat::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
}
.pcamo .stat::before { background: url('/icons/camo-pink.jpg') center / cover no-repeat; }
.pcamo .stat::after { background: rgba(20, 6, 30, 0.40); }
/* The big number on each tile is the app's blue gradient, painted INTO the
   letters - and a text shadow behind see-through letters shows through them,
   which turned the numbers into dark smudges. Solid white here, like the rest
   of the writing on this screen, so the shadow sits behind it as it should. */
.pcamo .stat b,
.pcamo .sober-row b {
  background: none; -webkit-background-clip: border-box; background-clip: border-box;
  -webkit-text-fill-color: #fff; color: #fff;
}
.pcamo .sober-row span { color: #fbe6f3; }
.pcamo .stat > * { position: relative; z-index: 1; }

.pcamo .kv-row { border-top-color: rgba(255, 150, 205, 0.24); }
.pcamo .sober-row { border-bottom-color: rgba(255, 150, 205, 0.24); }

/* --------------------------------------------------- push & pop
   Going into a conversation or a reading slides it in from the right over a
   still photograph of the list, and dragging from the left edge pulls it back
   off. Only transforms move, so the phone can do the whole thing on the
   compositor without laying anything out again. */
.behind {
  position: fixed; inset: 0; z-index: 1;
  overflow: hidden; pointer-events: none;
  background: #0a1330;
  transform: translateX(-22%);
  will-change: transform;
}
/* While something is pushed, the live screen is the one on top and needs a
   floor of its own - without it the photograph shows through the gaps. */
body.pushing #app {
  position: relative; z-index: 2;
  background: #0a1330;
  min-height: 100svh;
  will-change: transform;
}
/* The chat screen is already pinned, so it only needs the stacking. */
body.pushing.in-chat #app { position: fixed; min-height: 0; }
.glide-push { transition: transform 0.34s cubic-bezier(0.2, 0.9, 0.25, 1); }
@media (prefers-reduced-motion: reduce) {
  .glide-push { transition: none; }
}

/* --------------------------------------------------- the locked-out screen
   What somebody sees while a lock is on. Deliberately calm: this is a group
   for people in recovery, and a red wall shouting BANNED at somebody having a
   bad week is the wrong thing to put on a phone. It reads as a wait, which is
   what it is. */
body.locked-out #app { padding-bottom: 40px; }
/* Centred down the screen. This was a plain flex row when the card was the
   only thing in it; the sponsor line then became a second COLUMN beside it and
   squeezed the card into half the width. It is a column now, which is what it
   always meant. */
.lockwrap {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 70vh;
}
.lockcard { width: 100%; text-align: center; padding: 28px 20px; }
.lock-icon { font-size: 44px; line-height: 1; margin-bottom: 10px; }
.lock-title { font-size: 21px; margin: 0 0 8px; }
.lock-sub { color: var(--muted); font-size: 14px; margin: 0 auto; max-width: 34ch; line-height: 1.5; }
.lock-reason {
  margin: 14px auto 0; max-width: 34ch;
  background: var(--glass-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 14px; color: var(--ink);
}
/* The number they are actually here for. */
.lock-clock {
  margin-top: 20px; font-size: 38px; font-weight: 800;
  font-variant-numeric: tabular-nums;   /* so it does not twitch as it ticks */
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.lock-when { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 2px; }
/* The last word on the screen, under the card rather than inside it - it is
   not part of the explanation, it is the thing worth doing about it. */
.lock-sponsor {
  text-align: center; margin: 18px auto 0; max-width: 32ch;
  font-size: 14px; font-weight: 700; color: var(--ink); line-height: 1.5;
}

/* --------------------------------------------------- locking an account out
   A lock is a heavier thing than a pause and looks like it: the row is marked,
   and the reason and the time it lifts are spelled out rather than hidden
   behind the chip. */
.mgmt-row.locked { border-color: rgba(255, 107, 107, 0.38); }
.mgmt-ban {
  font-size: 11.5px; font-weight: 700; color: #ff9a9a;
  margin-top: 3px; line-height: 1.35;
}
.rolechip.banchip.on {
  background: rgba(255, 107, 107, 0.16);
  border-color: rgba(255, 107, 107, 0.5);
  color: #ff9a9a;
}
/* The lengths, two to a row on a phone: big enough to hit without looking. */
.ban-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.ban-opt { width: 100%; }

/* --------------------------------------------------- add-people sheet
   The roster, as a sheet you scroll. It replaced the browser's own prompt box,
   which asked for part of a name and then acted on the first match - no help
   at all when two people in the group share a first name. */
.sheet-lb { align-items: flex-end; padding: 0; }
.pick-sheet {
  width: 100%; max-width: 640px; margin: 0 auto;
  background: rgba(13, 24, 56, 0.99);
  border-top: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 8px 12px calc(var(--sab) + 14px);
  /* Tall enough to be worth scrolling, short enough to still show the chat
     underneath so it is obvious what is being added to. */
  max-height: calc(78vh - var(--safe-top));
  display: flex; flex-direction: column;
}
@supports (height: 100dvh) {
  .pick-sheet { max-height: calc(78dvh - var(--safe-top)); }
}
/* The scrolling part of a sheet whose content is not the roster. A sheet is
   capped at 78vh, so anything taller than that is simply cut off and the
   button at the bottom cannot be reached - which is what happened to the
   second half of the "can't get in?" sheet on a phone. min-height:0 is what
   lets a flex child be shorter than its contents and scroll instead. */
.pick-sheet .sheet-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}

.pick-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 2px 10px;
}
.pick-sheet-head b { font-size: 16px; color: #fff; }
/* The list itself is the only part that scrolls - the search box stays put. */
.pick-sheet .pick-list {
  overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0;
}
/* Already in the chat: still shown, in place, so it reads as "they are here"
   rather than "they are missing". */
.pick-row.already { opacity: .5; }
.pick-row.already .pick-tick {
  width: auto; border: 0; border-radius: 0; color: var(--muted);
  font-size: 11px; font-weight: 600;
}
.pick-row[data-add] .pick-tick { color: var(--cyan); font-size: 15px; }

/* --------------------------------------------------- mass broadcast
   The one alert that goes to everybody. It sits above everything - it can land
   mid-chat, mid-anything - and it is meant to look like nothing else in the
   app does. Red, because every other surface in here is blue.

   No backdrop-filter, for the same reason nothing else has one: a blurred
   layer is a real cost on every frame beneath it, and this one would be on top
   of whatever was already moving. A flat dark wash reads the same and is free. */
.bcast {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(4, 8, 22, 0.86);
  opacity: 0; transition: opacity .18s ease;
}
.bcast.in { opacity: 1; }
.bcast-card {
  width: 100%; max-width: 420px; text-align: center;
  padding: 26px 20px 20px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(60, 14, 22, 0.98), rgba(24, 10, 20, 0.98));
  border: 1px solid rgba(255, 107, 107, 0.5);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 107, 107, 0.12) inset;
  transform: scale(.94); transition: transform .2s cubic-bezier(.2, .9, .3, 1.2);
}
.bcast.in .bcast-card { transform: scale(1); }
.bcast-siren { font-size: 46px; line-height: 1; }
@media (prefers-reduced-motion: reduce) {
  .bcast-card { transition: none; transform: none; }
}
.bcast-kicker {
  margin-top: 10px; font-size: 12px; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase; color: #ff9a9a;
}
.bcast-body {
  margin-top: 12px; font-size: 19px; font-weight: 700; line-height: 1.45;
  color: #fff; overflow-wrap: anywhere;
}
.bcast-when { margin-top: 10px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.bcast-ok {
  margin-top: 20px;
  background: linear-gradient(180deg, #ff6b6b, #d93b4e);
  border: none; color: #fff; font-weight: 800;
}

/* The sending end, in Manage. The button is red and says what it does, and it
   arms before it fires - see the handler. */
.bcast-admin textarea { margin-top: 10px; }
.bcast-send.armed, #bcast-send.armed {
  animation: bcast-arm .9s ease-in-out infinite;
}
@keyframes bcast-arm {
  0%, 100% { opacity: 1; }
  50%      { opacity: .62; }
}
.bcast-log { margin-top: 16px; }
.bcast-log-row {
  display: flex; gap: 10px; align-items: baseline;
  padding: 7px 0; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink);
}
.bcast-log-row span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bcast-log-row i { font-style: normal; color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* --------------------------------------------------- find someone
   A search box at the top of the Feed. It is the shortest path to somebody's
   profile, which used to be three taps through the drawer.

   Deliberately quiet: it sits in the page rather than floating over it, and
   the results drop underneath instead of taking the screen, so somebody who
   is not looking for anybody barely notices it is there. */
.peoplefind {
  display: flex; align-items: center; gap: 9px;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 14px; margin-bottom: 12px;
}
.peoplefind:focus-within { border-color: rgba(78, 201, 255, 0.45); }
.pf-ico { font-size: 15px; line-height: 1; opacity: .8; flex: none; }
.peoplefind input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  color: var(--ink); font: inherit; font-size: 15px; padding: 12px 0;
}
.peoplefind input::placeholder { color: var(--muted); }
/* Safari draws its own clear button inside a search field, which would sit
   next to ours. */
.peoplefind input::-webkit-search-cancel-button { -webkit-appearance: none; }
.pf-clear {
  flex: none; background: none; border: 0; color: var(--muted);
  font-size: 13px; padding: 6px; min-height: 0; box-shadow: none;
}
.pf-out { margin: -4px 0 12px; }
.pf-row {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px; margin-bottom: 6px;
  color: var(--ink); font: inherit; box-shadow: none;
}
.pf-row:active { background: var(--glass-2); }
.pf-name { flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px;
  display: flex; align-items: center; gap: 6px; }
.pf-role { flex: none; font-size: 11px; font-weight: 800; color: var(--muted); }
.pf-none { color: var(--muted); font-size: 13.5px; padding: 8px 4px; }

/* --------------------------------------------------- GIFs
   A GIF is the one thing in a bubble that is not served from here: Giphy's
   terms require their CDN to serve the file, and a few hundred three-megabyte
   GIFs would fill the same store the group's own photos live in. */
/* A GIF keeps a box of its own before it has loaded.
   With `height: auto` the bubble was nothing but its padding until the GIF
   arrived and then jumped to full height - so a conversation full of GIFs grew
   under the reader as each one landed, and a GIF just sent pushed everything
   about twice: once for the placeholder, once when it decoded. This is the same
   fault .chat-photo was given a fixed box to cure; GIFs never got one.
   contain rather than cover because a GIF is somebody's joke and cropping it
   can cut the point out. The faint background is what shows in the margins. */
.chat-gif {
  display: block; max-width: 100%; width: 210px;
  aspect-ratio: 4 / 3; object-fit: contain;
  border-radius: 14px; margin-bottom: 4px; background: rgba(255, 255, 255, 0.05);
}
/* ---------- polls ---------- */
/* The same card on a feed post and inside a chat bubble. */
.pollcard {
  margin-top: 10px; padding: 12px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
  /* A bubble is white-space: pre-wrap, so every newline and every space of
     indentation in the card's markup was being drawn - which is why the first
     one came out with an empty inch above the question and another below the
     count. Normal whitespace here makes the card immune to how its own HTML
     happens to be laid out, which is better than keeping it all on one line
     and hoping nobody ever reformats it. */
  white-space: normal;
}
.poll-q { font-weight: 800; font-size: 14.5px; margin-bottom: 9px; line-height: 1.35; }
.poll-opts { display: flex; flex-direction: column; gap: 7px; }
/* Each choice is a button with a bar painted behind the words. The bar is a
   child rather than a background gradient so it can be animated from one width
   to another when the count changes, which a background cannot be. */
.poll-opt {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 8px;
  width: 100%; min-height: 40px; padding: 8px 11px;
  border-radius: 11px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05); color: var(--ink);
  font-size: 14px; font-weight: 600; text-align: left;
  box-shadow: none;
}
.poll-opt:active { transform: scale(.985); }
.poll-opt[disabled] { opacity: .85; }
.poll-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(90deg, rgba(78, 201, 255, .30), rgba(47, 143, 232, .22));
  transition: width .32s cubic-bezier(.22, .92, .3, 1);
  pointer-events: none;
}
.poll-opt.picked .poll-fill {
  background: linear-gradient(90deg, rgba(78, 201, 255, .52), rgba(47, 143, 232, .38));
}
.poll-opt.picked { border-color: rgba(78, 201, 255, .55); }
/* Holds its width whether or not there is a tick in it, so the words do not
   shift sideways when you change your answer. */
.poll-tick { position: relative; width: 13px; flex: none; color: var(--cyan); font-weight: 900; }
.poll-label { position: relative; flex: 1; min-width: 0; }
.poll-share { position: relative; flex: none; font-size: 12.5px; font-weight: 800; opacity: .85; }
.poll-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 9px; font-size: 12px; color: var(--muted);
}
/* A bubble with a poll in it needs more than a sentence does: a row of choices
   squeezed into 82% of a phone is unreadable - it came out 192px wide on a
   430px screen. The width has to be lifted on the WRAP as well: .bubble is
   sized against .bubble-wrap, and the wrap is the one carrying max-width: 82%,
   so widening only the bubble widened it to 100% of a narrow box. */
.bubble-wrap.has-poll { max-width: 100%; width: 100%; }
.bubble.has-poll { max-width: 100%; width: 100%; }
.bubble.mine.has-poll .pollcard { background: rgba(0, 0, 0, 0.16); border-color: rgba(255, 255, 255, 0.2); }
.bubble.mine.has-poll .poll-opt { background: rgba(0, 0, 0, 0.16); border-color: rgba(255, 255, 255, 0.22); }

/* The poll waiting to go out with a post. */
.post-poll { margin-top: 10px; }
.poll-chip {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 13px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
  font-size: 13.5px;
}
.poll-chip .hint { margin-top: 3px; }

/* The sheet you write one in. */
.poll-sheet {
  width: 100%; max-width: 520px; margin: auto auto 0;
  background: #142554; border: 1px solid var(--line);
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(var(--sab) + 18px);
  display: flex; flex-direction: column; gap: 10px;
  max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
}
.poll-sheet h3 { font-size: 16px; }
.poll-sheet input[type="text"] { width: 100%; }
#poll-rows { display: flex; flex-direction: column; gap: 8px; }
.poll-multi { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.poll-multi input { width: 18px; height: 18px; }
.poll-err:empty { display: none; }
.poll-err { color: var(--red); font-size: 13px; }
.poll-foot-row { margin-top: 2px; }
.poll-btn { flex: none; font-size: 15px; padding: 0 9px; min-height: 38px; border-radius: 12px; }

.gif-btn {
  flex: none; font-size: 11px; font-weight: 800; letter-spacing: .04em;
  padding: 0 9px; min-height: 38px; border-radius: 12px;
}
/* The picker. A sheet rather than a screen, because you are in the middle of
   saying something and the conversation should stay behind it. */
.gif-sheet {
  width: 100%; max-width: 640px; margin: 0 auto;
  background: rgba(13, 24, 56, 0.99);
  border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
  padding: 8px 14px calc(var(--sab) + 14px);
  max-height: 72vh; display: flex; flex-direction: column;
}
.gif-head { display: flex; gap: 9px; align-items: center; margin-bottom: 10px; }
.gif-head input {
  flex: 1; min-width: 0; background: var(--glass); border: 1px solid var(--line);
  border-radius: 999px; color: var(--ink); font: inherit; padding: 11px 15px; outline: none;
}
.gif-head input::-webkit-search-cancel-button { -webkit-appearance: none; }
.gif-grid {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-content: start;
  /* A DEFINITE row height, and that is the whole point of it.
     These rows used to be automatic, and an automatic row is sized from what
     its items contribute - which for a button whose height comes from
     aspect-ratio came out at 54px while the button itself drew at 198px. Every
     tile then spilled 144px into the row beneath it, which is why the picker
     looked like a stack of half-cropped pictures sliding over each other.
     Measured before: rows of 54px, 198px tiles, 84 overlapping pairs.
     Measured after: rows of 120px, 120px tiles, none. */
  grid-auto-rows: 120px;
}
.gif-pick {
  padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--glass);
  min-height: 0; box-shadow: none;
  /* The row decides the height now. Leaving aspect-ratio here would put the
     button back to a size its row knows nothing about. */
  height: 100%;
}
.gif-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-note { grid-column: 1 / -1; color: var(--muted); font-size: 13.5px; padding: 18px 4px; text-align: center; }
.gif-by { text-align: center; font-size: 10px; letter-spacing: .08em; color: var(--muted);
  text-transform: uppercase; padding-top: 9px; font-weight: 700; }

/* --------------------------------------------------- my net
   Who you would actually call. Two lists, and every row is one tap from a
   message or a phone call - which is the whole point of writing it down. */
.net-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.net-row:first-of-type { border-top: 0; }
.net-who {
  display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0;
  background: none; border: 0; padding: 0; color: var(--ink); font: inherit;
  text-align: left; box-shadow: none; min-height: 0;
}
.net-name {
  font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 6px;
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.net-acts { display: flex; align-items: center; gap: 7px; flex: none; }
.net-msg, .net-call {
  min-height: 34px; padding: 7px 12px; font-size: 13px; font-weight: 700;
  border-radius: 10px; white-space: nowrap;
}
/* Call is an <a href="tel:"> so the phone does the dialling. Styled to match
   the button beside it, because to the person tapping it they are the same
   kind of thing. */
.net-call {
  display: inline-flex; align-items: center; text-decoration: none;
  background: linear-gradient(180deg, #3ddc84, #22a45d); color: #06231a; border: 0;
}
/* Somebody who has not given a number gets no Call button at all, rather than
   one that does nothing when it is pressed. */
.net-nocall { font-size: 11.5px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.net-x {
  background: none; border: 0; color: var(--muted); font-size: 13px;
  padding: 8px; min-height: 0; box-shadow: none; flex: none;
}
.net-empty { color: var(--muted); font-size: 13.5px; padding: 10px 2px; }
.net-add { margin-top: 10px; }
.pick-has { flex: none; font-size: 13px; opacity: .8; }

/* On a narrow phone the buttons drop under the name rather than squeezing it
   down to two letters and an ellipsis. */
@media (max-width: 380px) {
  .net-acts { width: 100%; justify-content: flex-end; }
}

/* --------------------------------------------------- the V2 notes
   Shown once on the first open after V2, and reachable from a row at the top
   of the Feed until somebody dismisses it. */
/* The notes themselves, shared by the popup and the full page. */


/* ---------- the outline of a tab you have not opened yet ----------
   Carried in by a swipe so the gesture always has something to move. Shapes
   only, no words: it is on screen for about a fifth of a second and anything
   readable in that time would be read, found to be wrong, and replaced. The
   shimmer is a background position, which is composited, so a card sliding
   under a finger costs no layout. */
.skel-wrap { display: flex; flex-direction: column; gap: 12px; }
.skel-card {
  height: 92px; border-radius: var(--radius);
  background: linear-gradient(100deg,
    rgba(255, 255, 255, 0.05) 30%,
    rgba(255, 255, 255, 0.09) 50%,
    rgba(255, 255, 255, 0.05) 70%);
  background-size: 220% 100%;
  border: 1px solid var(--line);
  animation: skel-sheen 1.3s ease-in-out infinite;
}
.skel-card:nth-child(2) { height: 128px; }
.skel-card:nth-child(3) { height: 74px; }
@keyframes skel-sheen {
  from { background-position: 120% 0; }
  to   { background-position: -20% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skel-card { animation: none; }
}

/* ---------- the three dots on a feed post ----------
   Steering only, and only one thing in it so far. Sat in the top-right corner
   of the card, over the author row, because that corner is the one place on a
   post that never holds anything somebody wrote. */
.post-more { position: absolute; top: 10px; right: 10px; z-index: 3; }
.post-dots {
  width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line);
  color: var(--muted); font-size: 17px; line-height: 1; box-shadow: none;
}
.post-dots:active { background: rgba(255, 255, 255, 0.14); }
.post-menu {
  position: absolute; top: 40px; right: 0; min-width: 200px;
  background: #16254e; border: 1px solid var(--line); border-radius: 13px;
  padding: 5px; box-shadow: 0 14px 34px rgba(4, 10, 30, 0.6);
}
.post-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; box-shadow: none; color: var(--ink);
  font-size: 14px; font-weight: 600; text-align: left;
  padding: 10px 10px; min-height: 0; border-radius: 9px;
}
.post-menu button:active { background: rgba(255, 255, 255, 0.09); }
/* Holds its width whether or not there is a tick in it, so the words do not
   shift sideways as it is turned on and off. */
.menu-tick { width: 15px; flex: none; color: var(--cyan); font-weight: 900; }

/* ---------- Imminent Domain ----------
   One switch, on the Manage screen, for the one account it belongs to. */
.idcard { padding: 0; overflow: hidden; }
.idrow {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; background: none; box-shadow: none; color: var(--ink);
  text-align: left; padding: 15px 16px; min-height: 0; border-radius: 0;
}
.idrow .hint { display: block; margin-top: 3px; }
.idswitch {
  flex: none; width: 50px; height: 30px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.11); border: 1px solid var(--line);
  position: relative; transition: background .18s;
}
.idswitch i {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--muted); transition: transform .18s, background .18s;
}
.idswitch.on { background: rgba(78, 201, 255, 0.3); border-color: rgba(78, 201, 255, 0.5); }
.idswitch.on i { transform: translateX(20px); background: var(--cyan); }

/* ---------- finding somebody in Manage ----------
   A row is a name you tap open. Seventy rows of buttons was a wall you
   scrolled past to reach the one person you wanted. */
.mgmt-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.mgmt-count { margin: 0 0 8px; }
.mgmt-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; background: none; box-shadow: none; color: var(--ink);
  text-align: left; padding: 2px 0; min-height: 0; border-radius: 0;
}
.mgmt-headtext { min-width: 0; }
.mgmt-head .mgmt-name, .mgmt-head .mgmt-sub { display: block; }
.mgmt-chev { flex: none; color: var(--muted); font-size: 19px; transition: transform .16s; }
.mgmt-row.open .mgmt-chev { transform: rotate(90deg); }
/* Shut by default. The controls are still in the page, so everything already
   wired to them stays wired - this only decides whether they are on screen. */
.mgmt-body { display: none; margin-top: 10px; }
.mgmt-row.open .mgmt-body { display: block; }
.mgmt-pick {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); font-weight: 700;
}
.mgmt-pick select { min-width: 68px; }

/* --------------------------------------------------- sober birthdays
   The card at the top of a feed on the day somebody's count turns over a year.
   Gold, because the gold fist is what the day is about, but as a wash and an
   edge over the same glass every other card is made of - it should read as
   this app having something to celebrate, not as an advert dropped into it. */
.sbday {
  position: relative; overflow: hidden;
  border-color: rgba(255, 200, 64, 0.5);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 200, 64, 0.2), transparent 60%),
    var(--glass);
}
.sbday-kicker {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  color: #ffd772; margin-bottom: 10px;
}
/* Which year, as a figure. Solid gold where the rest of the card is a wash of
   it, so it is the first thing read. */
.sbday-year {
  flex: none; padding: 4px 11px; border-radius: 999px;
  background: linear-gradient(135deg, #ffcf55, #f0a020); color: #2a1a00;
  font-size: 12.5px; font-weight: 900; letter-spacing: .05em;
  box-shadow: 0 3px 10px rgba(240, 160, 32, 0.35);
}
.sbday-main { display: flex; align-items: center; gap: 12px; }
.sbday-face { background: none; border: 0; padding: 0; min-height: 0; flex: none; cursor: pointer; }
.sbday-av { width: 52px; height: 52px; font-size: 18px; box-shadow: 0 0 0 2px rgba(255, 200, 64, 0.75); }
.sbday-text { flex: 1; min-width: 0; font-size: 15px; line-height: 1.4; color: var(--ink); }
.sbday-text b { color: #fff; }
.sbday-knot { width: 46px; height: 46px; flex: none; }
.sbday-wish {
  width: 100%; margin-top: 14px;
  background: linear-gradient(135deg, #ffcf55, #f0a020); color: #2a1a00;
  font-weight: 800; box-shadow: 0 6px 18px rgba(240, 160, 32, 0.35);
}
/* Wished: it stays where it was and says so, rather than vanishing and leaving
   somebody wondering whether the tap took. */
.sbday-wish.done {
  background: rgba(255, 200, 64, 0.14); color: #ffd772; box-shadow: none;
  border: 1px solid rgba(255, 200, 64, 0.4); opacity: 1;
}
.sbday-count { margin-top: 9px; font-size: 12.5px; color: var(--muted); text-align: center; }
.sbday-count:empty { display: none; }
.sbday-mine .sbday-count { margin-top: 12px; font-size: 13.5px; color: var(--ink); }

/* Confetti is one canvas over everything that takes no taps: whatever is under
   it carries on working while the paper falls. Above a lightbox (90), because
   the year card it accompanies IS a lightbox. */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 96; pointer-events: none; }

/* --------------------------------------------------- the year, once */
.cheer-card {
  width: 100%; max-width: 380px; text-align: center;
  padding: 30px 22px 24px; border-radius: var(--radius);
  border: 1px solid rgba(255, 200, 64, 0.55);
  background:
    radial-gradient(130% 90% at 50% 0%, rgba(255, 200, 64, 0.24), transparent 65%),
    rgba(13, 24, 56, 0.98);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  transform: scale(.92); transition: transform .28s cubic-bezier(.2, .9, .3, 1.2);
}
.lightbox.in .cheer-card { transform: scale(1); }
.lightbox .cheer-knot {
  width: 104px; height: 104px; max-width: none; max-height: none;
  border-radius: 0; margin: 0 auto 12px; display: block;
}
.cheer-kicker {
  font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #ffd772;
}
.cheer-title { font-size: 31px; font-weight: 900; color: #fff; margin: 6px 0 10px; letter-spacing: -.01em; }
.cheer-words { font-size: 15px; line-height: 1.5; color: var(--ink); margin: 0 0 20px; }
.cheer-card button { width: 100%; }
@media (prefers-reduced-motion: reduce) {
  .cheer-card { transform: none; transition: none; }
}

/* --------------------------------------------------- birthdays */
.bday-pick { display: flex; gap: 8px; }
.bday-pick select { flex: 1; min-width: 0; }
.profile-bday {
  margin-top: 10px; display: inline-block; padding: 6px 13px; border-radius: 999px;
  background: rgba(255, 143, 177, 0.16); border: 1px solid rgba(255, 143, 177, 0.4);
  color: #ffd0de; font-size: 13.5px; font-weight: 700;
}

/* --------------------------------------------------- who reacted */
/* A chip is held to open the list, and a held finger on text is also how a
   phone starts selecting it. Not here. */
.react-chip { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.who-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 0 2px 10px; flex: none;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.who-tabs::-webkit-scrollbar { display: none; }
.who-tab {
  flex: none; min-height: 0; padding: 7px 13px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); color: var(--ink);
  font-size: 14px; font-weight: 700; box-shadow: none;
}
.who-tab.on { background: rgba(90, 160, 255, 0.22); border-color: var(--accent); color: #fff; }
.who-row {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  padding: 10px 4px; min-height: 0; text-align: left; color: var(--ink); box-shadow: none;
}
.who-row:last-child { border-bottom: 0; }
.who-row:active { background: var(--glass-2); }
.who-row .who-name {
  flex: 1; min-width: 0; font-size: 15px; font-weight: 700; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who-row .nick { font-weight: 500; color: var(--muted); }
.who-you {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--cyan); margin-left: 4px;
}
.who-emoji { flex: none; font-size: 22px; }

/* --------------------------------------------------- Matt Points
   The way to the leaderboard at the top of the Feed: one line, gold, the
   reader's own score in it so it is worth a glance even when they are not
   going to tap it. */
.points-link {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; color: var(--ink); min-height: 0;
  border-color: rgba(255, 200, 64, 0.45);
  background: linear-gradient(100deg, rgba(255, 200, 64, 0.16), var(--glass) 70%);
  box-shadow: none;
}
.points-link:active { transform: scale(.985); }
.pl-cup { font-size: 24px; line-height: 1; flex: none; }
.pl-text { flex: 1; min-width: 0; }
.pl-text b { display: block; color: #fff; font-size: 15px; }
.pl-text span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
/* On a profile, under the name. A button, because it goes to the board. */
.points-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; min-height: 0;
  padding: 6px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 800;
  background: rgba(255, 200, 64, 0.15); color: #ffd772; border: 1px solid rgba(255, 200, 64, 0.45);
  box-shadow: none;
}
.points-chip.neg { background: rgba(255, 107, 125, 0.14); color: #ff9aa8; border-color: rgba(255, 107, 125, 0.4); }
