/* The House — tenant portal.
 *
 * The idea is a ledger: numbers align in columns, entries hang off ruled
 * lines, settling something strikes it out rather than deleting it.
 *
 * Earlier this was pure hairlines on a flat background, which read as
 * unfinished — paper works that way because paper is itself a surface, and a
 * screen is not. Content now sits on real panels with a distinct page behind
 * them. The ledger discipline stays; the void is gone.
 */

:root {
  /* Page sits behind; surface is what content sits on. The small step between
     them is what makes the layout read as built rather than dumped. */
  --page:    #F1EEE7;
  --surface: #FDFCFA;
  --sunken:  #F6F3EC;

  --ink:     #191B1F;
  --muted:   #5E5A52;
  --dim:     #8A857A;

  --line:    #E4DFD4;   /* structural rules */
  --hairline:#EEEAE0;   /* row separators, lighter */

  --owed:    #A83E27;   /* only ever on money owed */
  --square:  #35624A;   /* only ever on settled/complete */
  --accent:  #2C5578;   /* focus, links, the one cool note */

  --shadow: 0 1px 2px rgba(25, 27, 31, 0.04),
            0 8px 24px -12px rgba(25, 27, 31, 0.14);
  --shadow-lift: 0 2px 4px rgba(25, 27, 31, 0.05),
                 0 18px 42px -22px rgba(25, 27, 31, 0.28);

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --gap: 1.5rem;
  --measure: 68rem;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page:    #101215;
    --surface: #191C21;
    --sunken:  #14171B;

    --ink:     #EDE9E1;
    --muted:   #A9A398;
    --dim:     #7E786D;

    --line:    #282C33;
    --hairline:#22262C;

    --owed:    #E4805F;
    --square:  #6FB48D;
    --accent:  #7FAFDC;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3),
              0 8px 24px -8px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="light"] {
  --page: #F1EEE7; --surface: #FDFCFA; --sunken: #F6F3EC;
  --ink: #191B1F; --muted: #5E5A52; --dim: #8A857A;
  --line: #E4DFD4; --hairline: #EEEAE0;
  --owed: #A83E27; --square: #35624A; --accent: #2C5578;
  --shadow: 0 1px 2px rgba(25,27,31,.04), 0 4px 12px -4px rgba(25,27,31,.06);
}
:root[data-theme="dark"] {
  --page: #101215; --surface: #191C21; --sunken: #14171B;
  --ink: #EDE9E1; --muted: #A9A398; --dim: #7E786D;
  --line: #282C33; --hairline: #22262C;
  --owed: #E4805F; --square: #6FB48D; --accent: #7FAFDC;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -8px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

/* Any class setting `display` outranks the browser's `[hidden] { display:none }`,
   which silently breaks every element the app hides. This puts `hidden` back in
   charge — without it the login and reset forms rendered on top of each other. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(65rem 32rem at 8% -8%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 62%),
    radial-gradient(46rem 28rem at 100% 18%, color-mix(in srgb, var(--square) 5%, transparent), transparent 70%),
    var(--page);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Every figure in the app aligns in its column. This is the whole point of
   the ledger idea, and it is why tabular figures are set this broadly. */
.num, .money, .amount, .standing__line, .codes, .key,
input[inputmode="decimal"], input[inputmode="numeric"], input[type="date"] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv05" 1;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --- sign in ---------------------------------------------------------- */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--gap);
  /* A faint warm wash off the top-left stops the page reading as a flat void
     behind the card. */
  background:
    radial-gradient(80rem 40rem at 15% -10%,
      color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
    var(--page);
}

.gate__form {
  width: min(24rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.25rem 2rem 2rem;
}

.gate__mark {
  margin: 0;
  font-size: clamp(2.25rem, 7vw, 2.75rem);
  font-weight: 680;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

/* The one flourish: a short rule under the wordmark, in the accent. */
.gate__mark::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  margin-top: 1rem;
  border-radius: 2px;
  background: var(--accent);
}

.gate__sub {
  margin: -0.25rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.gate__forgot {
  align-self: flex-start;
  margin-top: -0.25rem;
}

/* --- fields ------------------------------------------------------------ */

.field { display: block; }

.field__label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4375rem;
}

.field__hint {
  display: block;
  font-size: 0.75rem;
  color: var(--dim);
  margin-top: 0.375rem;
  line-height: 1.45;
}

/* Inputs are real boxes now. The hairline-only treatment looked unfinished
   and left people hunting for where to type. */
input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.5rem 0.6875rem;
  transition: border-color 120ms, box-shadow 120ms, background-color 120ms;
}

input::placeholder, textarea::placeholder { color: var(--dim); }

input:hover, select:hover, textarea:hover { border-color: var(--muted); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

input[readonly] { background: var(--sunken); color: var(--muted); }

textarea { resize: vertical; line-height: 1.6; min-height: 4.5rem; }

select {
  appearance: none;
  padding-right: 2rem;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 1rem center, right 0.7rem center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input[type="file"] {
  padding: 0.4375rem;
  font-size: 0.875rem;
  background: var(--sunken);
}

input[type="checkbox"] { width: auto; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  font-size: 0.875rem;
  line-height: 1.5;
  cursor: pointer;
  color: var(--muted);
}

.check input[type="checkbox"] {
  width: 1.0625rem;
  height: 1.0625rem;
  margin: 0.125rem 0 0;
  flex: none;
  accent-color: var(--accent);
}

/* --- buttons ----------------------------------------------------------- */

.btn {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0.5rem 1rem;
  white-space: nowrap;
  transition: background-color 120ms, color 120ms,
              border-color 120ms, transform 60ms;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--solid {
  background: var(--ink);
  color: var(--surface);
}
.btn--solid:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 86%, var(--accent));
}

.btn--quiet {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--line);
  padding: 0.4375rem 0.875rem;
}
.btn--quiet:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--muted);
  background: var(--sunken);
}

.link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}
.link:hover { color: var(--accent); text-decoration-color: currentColor; }

/* --- header ------------------------------------------------------------ */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.75rem;
  padding: 0 var(--gap);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 3%, transparent);
}

@supports (backdrop-filter: blur(1rem)) {
  .top {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(18px) saturate(1.25);
  }
}

/* Inner wrapper keeps the bar full-bleed while its contents stay on the
   same measure as the views below. */
.top > * { position: relative; }
.top {
  padding-left: max(var(--gap), calc((100vw - var(--measure)) / 2));
  padding-right: max(var(--gap), calc((100vw - var(--measure)) / 2));
  padding-top: 0.75rem;
  padding-bottom: 0;
}

.top__mark {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 680;
  letter-spacing: -0.025em;
  font-size: 1rem;
  padding-bottom: 0.75rem;
}
.top__mark strong { color: var(--accent); font-weight: inherit; }

/* A tiny front door gives the product a recognizable silhouette without an
   icon font or image request. */
.top__home {
  width: 1.65rem;
  height: 1.65rem;
  flex: none;
  position: relative;
  border-radius: 7px;
  background: var(--ink);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,.14);
}
.top__home::before {
  content: "";
  position: absolute;
  width: .48rem;
  height: .68rem;
  left: .585rem;
  bottom: .3rem;
  border-radius: 4px 4px 2px 2px;
  background: var(--surface);
}
.top__home::after {
  content: "";
  position: absolute;
  width: .16rem;
  height: .16rem;
  right: .45rem;
  bottom: .57rem;
  border-radius: 50%;
  background: var(--accent);
}

.top__nav {
  display: flex;
  gap: 0.25rem;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-self: flex-end;
}

/* Tabs sit on the header's bottom edge, so the active one reads as connected
   to the panel below it. */
.tab {
  background: none;
  border: 0;
  padding: 0.5rem 0.75rem;
  margin-bottom: -1px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 7px 7px 0 0;
  transition: color 120ms, background-color 120ms, border-color 120ms;
}
.tab:hover { color: var(--ink); background: var(--sunken); }
.tab.is-active {
  color: var(--ink);
  font-weight: 620;
  border-bottom-color: var(--accent);
}

.top__right {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-left: auto;
  padding-bottom: 0.75rem;
}

.top__who { font-size: 0.8125rem; color: var(--muted); white-space: nowrap; }

.pip {
  display: inline-block;
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: var(--owed);
  margin-left: 0.375rem;
  vertical-align: 0.3em;
}

/* --- views ------------------------------------------------------------- */

.view {
  display: none;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.75rem var(--gap) 5rem;
}
.view.is-active { display: block; }
.view.is-active { animation: view-in 260ms cubic-bezier(.2,.75,.25,1) both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

/* The headline figure. Stated as a sentence, not a labelled stat tile. */
.standing {
  padding: 1.75rem 1.75rem 1.625rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  /* A colour bar on the leading edge: the one place the page states a
     financial position, so it gets the one strong accent. */
  border-left: 3px solid var(--accent);
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(110deg, var(--surface) 0 72%, color-mix(in srgb, var(--accent) 7%, var(--surface)) 100%);
}
.standing::after {
  content: "";
  position: absolute;
  width: 9rem;
  height: 9rem;
  right: -3.5rem;
  top: -5.5rem;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 0 1.4rem color-mix(in srgb, var(--accent) 3%, transparent),
              0 0 0 2.8rem color-mix(in srgb, var(--accent) 2%, transparent);
  pointer-events: none;
}

.standing__line {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.125rem);
  font-weight: 620;
  letter-spacing: -0.03em;
  line-height: 1.2;
  text-wrap: balance;
}

.standing__line .amount--owed   { color: var(--owed); }
.standing__line .amount--square { color: var(--square); }

.standing__note {
  margin: 0.625rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

/* --- bin day ------------------------------------------------------------ */
/* The one thing on this page with an actual deadline, so it gets to look
   like a notice rather than another row in a list. */

.bins {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1.125rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--dim);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.bins--recycling { border-left-color: var(--square); }
.bins--now       { border-left-color: var(--owed); }

/* A simple bin glyph, drawn in CSS so there is no icon font or external
   asset to load under the strict CSP. */
.bins__icon {
  flex: none;
  width: 1.375rem;
  height: 1.5rem;
  position: relative;
  border: 2px solid currentColor;
  border-radius: 2px 2px 4px 4px;
  color: var(--dim);
}
.bins__icon::before {
  content: "";
  position: absolute;
  left: -3px; right: -3px; top: -6px;
  height: 3px;
  background: currentColor;
  border-radius: 1px;
}
.bins__icon::after {
  content: "";
  position: absolute;
  left: 50%; top: -10px;
  width: 0.5rem; height: 4px;
  transform: translateX(-50%);
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
}
.bins--recycling .bins__icon { color: var(--square); }
.bins--now .bins__icon { color: var(--owed); }

.bins__text {
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
  min-width: 0;
}
.bins__text strong { font-size: 0.9375rem; font-weight: 620; }
.bins__note { font-size: 0.8125rem; color: var(--muted); }

/* --- panels ------------------------------------------------------------ */

.block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
@media (hover: hover) {
  .block:hover {
    border-color: color-mix(in srgb, var(--line) 70%, var(--accent));
    box-shadow: var(--shadow-lift);
    transform: translateY(-1px);
  }
}

.block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: var(--sunken);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.block__head h2 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.hint {
  margin: 0;
  padding: 0.875rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.55;
  background: var(--sunken);
  border-bottom: 1px solid var(--hairline);
}
.hint:last-child { border-bottom: 0; }

/* --- entry forms ------------------------------------------------------- */

.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--sunken);
}

.entry--stack {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}
.entry--stack button { justify-self: start; }

/* A row of controls inside a stacked form — lets the lease form keep its
   short fields side by side while the wide ones get a line each. */
.entry__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 0.75rem;
  align-items: center;
}
@media (max-width: 46rem) {
  .entry__row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 30rem) {
  .entry__row { grid-template-columns: 1fr; }
}

/* Numeric inputs are right-aligned but keep their grid width — capping them
   with max-width left a stunted box floating in an empty column. */
.entry .num { text-align: right; }
.entry select { min-width: 9rem; }
.entry input[type="date"] { width: 11rem; }
/* The amount field is the primary input in these forms, so it takes the
   flexible column and everything else sizes to content. */
.entry input[name="amount"], .entry input[name="rent"] { min-width: 7rem; }

@media (max-width: 46rem) {
  .entry { grid-template-columns: 1fr 1fr; }
  .entry .num, .entry input[type="date"] { max-width: none; }
  .entry button[type="submit"] { grid-column: 1 / -1; }
}
@media (max-width: 30rem) {
  .entry { grid-template-columns: 1fr; }
}

/* --- ruled rows -------------------------------------------------------- */
/* The signature: entries hang off a hairline that runs the full panel width,
   and money aligns in a fixed column regardless of what else is in the row. */

.rows { list-style: none; margin: 0; padding: 0; }

.row {
  display: grid;
  /* content | figure | actions.
     The figure and action columns are fixed widths, not `auto`, so a money
     value lands in the same place whether or not its row has buttons —
     otherwise amounts jump left and right between panels and the whole
     point of tabular figures is lost. */
  grid-template-columns: minmax(0, 1fr) 7.5rem 6rem;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.8125rem 1.25rem;
  border-bottom: 1px solid var(--hairline);
  transition: background-color 140ms, padding-left 140ms;
}

@media (max-width: 34rem) {
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row__actions { grid-column: 1 / -1; justify-content: flex-start; }
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--sunken); padding-left: 1.4rem; }

.row__main { min-width: 0; }

.row__title {
  display: block;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.row__meta {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 0.0625rem;
}

.row__detail {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 0.25rem;
  max-width: 62ch;
  line-height: 1.5;
}

.money {
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.money--owed   { color: var(--owed); }
.money--square { color: var(--square); }

.row__actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-end;
}

/* Settling strikes the row through in place: the ledger keeps its history
   rather than losing it. */
.row.is-done .row__title,
.row.is-done .money {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
  color: var(--dim);
}
.row.is-done { opacity: 0.7; }

/* Specificity has to beat the base `input` rule above, which otherwise gives
   these a padded box and makes them render as empty text fields. */
input.row__check {
  appearance: none;
  -webkit-appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  padding: 0;
  min-width: 0;
  border: 1.5px solid var(--dim);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  flex: none;
  background: var(--surface);
  transition: background-color 120ms, border-color 120ms;
}
input.row__check:hover { border-color: var(--square); }
input.row__check:checked {
  background: var(--square);
  border-color: var(--square);
}
input.row__check:checked { animation: check-pop 220ms cubic-bezier(.2,.9,.3,1.35); }
@keyframes check-pop {
  50% { transform: scale(1.16); }
}
input.row__check:checked::after {
  content: "";
  position: absolute;
  left: 0.3125rem; top: 0.09375rem;
  width: 0.3125rem; height: 0.625rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}

/* Someone else's task: visible for context, but clearly not your problem. */
.row--theirs .row__title { color: var(--muted); }
.row--theirs .row__detail { display: none; }

.empty {
  padding: 1.5rem 1.25rem;
  color: var(--dim);
  font-size: 0.9375rem;
}

/* --- pills ------------------------------------------------------------- */

.pill {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1875rem 0.625rem;
  white-space: nowrap;
}
.pill--open {
  color: var(--owed);
  border-color: color-mix(in srgb, var(--owed) 40%, transparent);
  background: color-mix(in srgb, var(--owed) 8%, var(--surface));
}
.pill--executed {
  color: var(--square);
  border-color: color-mix(in srgb, var(--square) 40%, transparent);
  background: color-mix(in srgb, var(--square) 8%, var(--surface));
}

/* --- profile grid ------------------------------------------------------ */

.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.125rem 1.5rem;
  padding: 1.25rem;
}
.grid2 .field--wide { grid-column: 1 / -1; }

@media (max-width: 40rem) {
  .grid2 { grid-template-columns: 1fr; }
}

/* --- welcome packet ---------------------------------------------------- */

#packet { padding: 0; }

.packet__section { border-bottom: 1px solid var(--line); }
.packet__section:last-child { border-bottom: 0; }

.packet__label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.875rem 1.25rem 0.5rem;
  background: var(--sunken);
  border-bottom: 1px solid var(--hairline);
}

.doc {
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--hairline);
}
.doc:last-child { border-bottom: 0; }

.doc__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.doc h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.doc__body {
  margin: 0.375rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 68ch;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--muted);
}

.doc__meta { font-size: 0.75rem; color: var(--dim); }

/* Unfilled placeholders should read as gaps, not as content. */
.packet__todo {
  color: var(--owed);
  font-style: italic;
  background: color-mix(in srgb, var(--owed) 9%, transparent);
  padding: 0 0.25rem;
  border-radius: 3px;
}

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

.thread__subject {
  margin: 0;
  padding: 1.125rem 1.25rem 0;
  font-size: 1.25rem;
  font-weight: 640;
  letter-spacing: -0.02em;
}

.thread { padding: 0.75rem 1.25rem 1.25rem; }

.bubble {
  padding: 0.9375rem 0;
  border-bottom: 1px solid var(--hairline);
}
.bubble:last-child { border-bottom: 0; }

.bubble__head {
  display: flex;
  gap: 0.625rem;
  align-items: baseline;
  font-size: 0.75rem;
  color: var(--dim);
  margin-bottom: 0.3125rem;
}

.bubble__who { font-weight: 620; color: var(--ink); font-size: 0.8125rem; }

.bubble__body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 66ch;
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* Your own messages are inset behind a rule, so a thread reads as a
   conversation without resorting to chat bubbles. */
.bubble--mine {
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
  margin-left: -1rem;
  padding-left: 1rem;
}

/* --- agreements -------------------------------------------------------- */

.agreement {
  max-height: 26rem;
  overflow-y: auto;
  padding: 1.25rem;
  margin: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--sunken);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
  line-height: 1.7;
}

.signbox {
  margin: 1.25rem;
  padding: 1.5rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}

.signbox__head {
  margin: 0;
  font-size: 1rem;
  font-weight: 640;
  letter-spacing: -0.015em;
}

.sigpad {
  width: 100%;
  height: 180px;
  border: 1.5px dashed var(--dim);
  border-radius: 4px;
  background: var(--sunken);
  touch-action: none;   /* draw instead of scrolling the page */
  cursor: crosshair;
  display: block;
}

.sigpad__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.signed {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  gap: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.signed__img {
  height: 3.5rem;
  max-width: 14rem;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.25rem;
}

.signed__meta { font-size: 0.8125rem; color: var(--muted); line-height: 1.5; }

/* --- two-factor -------------------------------------------------------- */

#tfa-off, #tfa-setup, #tfa-codes, #tfa-on { padding: 1.25rem; }
#tfa-off > .hint, #tfa-setup > .hint, #tfa-codes > .hint {
  padding: 0; background: none; border: 0; margin-bottom: 1rem;
}

.qr {
  display: inline-block;
  padding: 0.75rem;
  background: #fff;          /* scanners want real white, in either theme */
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 0.875rem;
  line-height: 0;
}
.qr svg { display: block; width: 200px; height: 200px; }

.key {
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  background: var(--sunken);
  border: 1px solid var(--line);
  padding: 0.1875rem 0.4375rem;
  border-radius: 3px;
  overflow-wrap: anywhere;
}

/* Recovery codes get written down or copied — legibility beats density. */
.codes {
  list-style: none;
  margin: 0 0 1.125rem;
  padding: 1.125rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--sunken);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.5rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.9375rem;
  letter-spacing: 0.06em;
}

/* --- sessions and activity --------------------------------------------- */

.row--current .row__title::after {
  content: "this device";
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--square);
  border: 1px solid color-mix(in srgb, var(--square) 40%, transparent);
  background: color-mix(in srgb, var(--square) 9%, transparent);
  border-radius: 999px;
  padding: 0.125rem 0.5rem;
  margin-left: 0.625rem;
  vertical-align: 0.12em;
}

/* Failures should be findable by eye when scanning the log. */
.event--bad .row__title { color: var(--owed); }
.event--good .row__title { color: var(--square); }

/* --- modal ------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, #000 55%, transparent);
  display: grid;
  place-items: center;
  padding: var(--gap);
  z-index: 50;
  backdrop-filter: blur(2px);
}

.modal__panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: min(46rem, 100%);
  max-height: min(85vh, 52rem);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.4);
}

.modal__head,
.modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  flex: none;
  flex-wrap: wrap;
}
.modal__head { border-bottom: 1px solid var(--line); background: var(--sunken); }
.modal__foot { border-top: 1px solid var(--line); background: var(--sunken); }

.modal__head h2 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 640;
  letter-spacing: -0.02em;
}

.modal__body {
  overflow-y: auto;
  padding: 1.5rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--muted);
}

/* Section headings inside long-form text — used by both the policy modal and
   the welcome packet, which share the same ALL-CAPS-line convention. */
.policy-head {
  display: block;
  font-weight: 650;
  letter-spacing: 0.07em;
  font-size: 0.75rem;
  text-transform: uppercase;
  margin: 1.5rem 0 0.5rem;
  color: var(--accent);
}
.policy-head:first-child { margin-top: 0; }
.doc__body .policy-head { margin-top: 1.25rem; }

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

.msg {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
}
.msg--bad  { color: var(--owed); }
.msg--good { color: var(--square); }

/* Inside panels, status lines need the panel's padding. */
.block > .msg { padding: 0 1.25rem 1.25rem; margin-top: 0.5rem; }

.tagline {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 0.125rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* On phones, primary destinations become a stable thumb dock. The secondary
   account actions remain in the compact header above the page. */
@media (max-width: 42rem) {
  body { font-size: 14px; background-attachment: scroll; }
  #app { padding-bottom: 5.25rem; }

  .top {
    min-height: 3.75rem;
    padding: .7rem 1rem;
    gap: .75rem;
  }
  .top__mark { padding: 0; margin-right: auto; }
  .top__who { display: none; }
  .top__right { margin: 0; padding: 0; }
  .top__right .btn { padding: .4rem .65rem; font-size: .75rem; }

  .top__nav {
    position: fixed;
    left: max(.6rem, env(safe-area-inset-left));
    right: max(.6rem, env(safe-area-inset-right));
    bottom: max(.6rem, env(safe-area-inset-bottom));
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .15rem;
    padding: .42rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: 0 14px 45px rgba(12,17,22,.22);
    overflow: hidden;
  }
  @supports (backdrop-filter: blur(1rem)) {
    .top__nav { backdrop-filter: blur(20px) saturate(1.35); }
  }
  .tab {
    min-width: 0;
    margin: 0;
    padding: .62rem .12rem .48rem;
    border: 0;
    border-radius: 10px;
    font-size: clamp(.54rem, 2.2vw, .68rem);
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tab::before {
    content: "";
    display: block;
    width: .36rem;
    height: .36rem;
    margin: 0 auto .42rem;
    border: 2px solid currentColor;
    border-radius: 50%;
    opacity: .6;
  }
  .tab.is-active { background: var(--sunken); color: var(--accent); }
  .tab.is-active::before { background: currentColor; opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent); }
  .pip { position: absolute; top: .42rem; right: 26%; }

  .view { padding: 1rem 1rem 2rem; }
  .standing { padding: 1.35rem 1.25rem; margin-bottom: 1rem; }
  .standing__line { font-size: 1.45rem; }
  .block, .bins { margin-bottom: 1rem; }
  .block__head, .row { padding-left: 1rem; padding-right: 1rem; }
  .row:hover { padding-left: 1.1rem; }
}

/* Keep the atmosphere while dropping the two costliest compositing effects on
   devices that explicitly ask pages to conserve data or rendering work. */
@media (prefers-reduced-data: reduce) {
  body { background-image: none; }
  .top, .top__nav { backdrop-filter: none; }
}
