/*
VOICE: calm, plain, trustworthy; the owner decides and the app gets out of the way.
IDEA: an office in a pocket: chat at the front door, approvals as the one place where things leave the office.
PICTURE: the leaf mark on the welcome and empty states; the approval preview is the main object.
COLOUR and TYPE: palette B in roles the founder approved (#332, #178): a linen ground, ink text, moss for Approve and the main action, wine for the leaf, badges and urgent times, peach for one soft focus field, a separate danger red for irreversible actions only; one large field per screen (the moss band on Approvals, the peach head of an approval), the leaf as a quiet watermark, a dark floating tab bar. Light and dark from the same roles. The approved fonts, self-hosted (#331): Sahel for all text in Persian and for body text in English (its Latin glyphs come from Open Sans, a plain UI sans), Fraunces for English headings. No font host: the pilot's policy is `font-src 'self'` (#188).
LAYOUT: phone bottom bar; sidebar from 900px; the approval opens full screen on a phone and as a side panel on wide screens.
Rule: logical properties only (no physical left or right); checks/test_logical_css.py enforces it.
*/
/* Files and licences: public/fonts (OFL 1.1). The URLs are relative to the page or app.css, both next to fonts/. */
@font-face {
  font-family: "Sahel";
  src: url("fonts/Sahel-VF.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("fonts/Fraunces-opsz-wght.woff") format("woff");
  font-weight: 500 600;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  /* Colour roles (#178), approved on #332: the same names and values as functions/marketing/brand/design-tokens.json,
     color.app; checks/test_contrast.py computes their contrast and holds this block to that file. */
  --bg: light-dark(#F3EEE3, #161B14);
  --surface: light-dark(#FBF8F2, #1F251C);
  --sunk: light-dark(#E8E1D2, #283024);
  --ink: light-dark(#22291F, #EEE8DB);
  --muted: light-dark(#5B6255, #AEB4A6);
  --line: light-dark(#DDD4C3, #343C30);
  --primary: light-dark(#4D6048, #A8BD9E);
  --on-primary: light-dark(#F7F3EA, #172014);
  --brand: light-dark(#963F56, #D99AA8);
  --on-brand: light-dark(#F7F3EA, #2A1219);
  --soft: light-dark(#EBCDBE, #3A2B2D);
  --on-soft: light-dark(#22291F, #F1DCD2);
  --band: light-dark(#4D6048, #2C3829);
  --on-band: light-dark(#F3EEE3, #EEE8DB);
  --band-muted: light-dark(#D5DCCD, #B9C4B1);
  --band-leaf: light-dark(#E4BAA5, #D99AA8);
  --bar: light-dark(#22291F, #262D22);
  --on-bar: light-dark(#E9E3D6, #D9D3C6);
  --bar-active: light-dark(#E4BAA5, #E4BAA5);
  --on-bar-active: light-dark(#22291F, #22291F);
  --danger: light-dark(#A3243D, #F08A9C);
  --on-danger: light-dark(#F7F3EA, #2A1219);
  --leaf: light-dark(#963F56, #D99AA8);
  --leaf-vein: var(--bg);
  --radius: 14px;
  --radius-card: 22px;
  --radius-field: 28px;
  /* Type scale (#332): title 34, subtitle 20, body 16, small 13 at the default text size. */
  --size-title: 2.125rem;
  --size-subtitle: 1.25rem;
  --size-small: 0.8125rem;
  --font-ui: "Sahel", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-latin: var(--font-ui);
  --font-display: "Fraunces", Georgia, serif;
  --font-fa: "Sahel", Tahoma, sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
}
:root:lang(fa) {
  --font-latin: var(--font-fa);
  --font-display: var(--font-fa);
}

* {
  box-sizing: border-box;
  min-width: 0;
}
html,
body {
  margin: 0;
  block-size: 100%;
}
body {
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.55 var(--font-latin);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
:lang(fa) {
  line-height: 1.8;
}
[lang="en"] {
  font-family: var(--font-ui);
}
#root {
  block-size: 100dvh;
}
h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
}
h1 {
  font-family: var(--font-display);
  font-size: 1.375rem;
  text-wrap: balance;
}
/* Read by screen readers, not shown: the detail's title when the screen's own head says it. */
.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
/* No resize grip on a phone (#388): it is a desktop handle. A mouse may still drag a field's text area taller (below). */
textarea {
  resize: none;
}
button {
  cursor: pointer;
}
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.8125rem;
}
.nowrap {
  white-space: nowrap;
}
.eyebrow {
  font-family: var(--font-latin);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}
.icon {
  inline-size: 22px;
  block-size: 22px;
  flex: none;
}
[dir="rtl"] .icon.flip {
  transform: scaleX(-1);
}
.leaf {
  display: inline-block;
  color: var(--leaf);
  flex: none;
}
.leaf svg {
  inline-size: 100%;
  block-size: 100%;
}

/* Buttons */
.primary,
.secondary,
.ghost,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-block-size: 44px;
  padding-block: 10px;
  padding-inline: 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
}
.primary {
  background: var(--primary);
  color: var(--on-primary);
}
.secondary {
  background: var(--surface);
  border-color: var(--line);
}
a.secondary,
a.primary {
  text-decoration: none;
}
a.secondary {
  color: var(--ink);
}
.secondary:where(.answer *, .reject-form *) {
  background: transparent;
  border: 1.5px solid var(--line);
}
.ghost {
  background: transparent;
  color: var(--ink);
  padding-inline: 12px;
}
.danger {
  background: var(--danger);
  color: var(--on-danger);
}
.wide {
  inline-size: 100%;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  flex: none;
}
.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.send {
  background: var(--primary);
  color: var(--on-primary);
}

/* Welcome. Its own scroll container (#385): the body never scrolls, so with the keyboard open (the viewport shrinks,
   `interactive-widget=resizes-content`) the sign-in fields must scroll here or they sit behind the keyboard. */
.welcome {
  max-block-size: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  max-inline-size: 440px;
  margin-inline: auto;
  padding-block: 12vh 24px;
  padding-inline: 24px;
  display: grid;
  gap: 18px;
  text-align: center;
}
.welcome h1 {
  font-size: 1.875rem;
}
.welcome-mark {
  justify-self: center;
}
/* Sign-in (#311): the name under the leaf, a language choice at the top, fields aligned like the rest of the app. */
.sign-in .welcome-mark {
  display: grid;
  justify-items: center;
  gap: 4px;
}
.sign-in .welcome-mark p {
  margin: 0;
}
.brand-word {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.sign-in .form {
  text-align: start;
}
.lang-switch {
  justify-self: end;
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--sunk);
}
.lang-switch .seg {
  min-block-size: 36px;
  padding-inline: 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
}
/* The chosen language as every other segmented choice (#388): surface on sunk was 1.2:1 and read as nothing chosen. */
.lang-switch .seg.active {
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
}
.code-input {
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  text-align: center;
}
.sign-in-more {
  justify-content: center;
}
/* Step-up opens inside the app: the same parts, with room around them. */
.page.sign-in {
  display: grid;
  gap: 14px;
  padding-block: 24px;
  padding-inline: 16px;
  max-inline-size: 520px;
}
.page.sign-in > * {
  margin: 0;
}
.lang-choice {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.lang-choice legend {
  font-weight: 600;
  margin-block-end: 10px;
}
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-block-size: 52px;
  padding-inline: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1.125rem;
  cursor: pointer;
}
.choice.on {
  border-color: var(--primary);
}
.choice input {
  accent-color: var(--primary);
  inline-size: 20px;
  block-size: 20px;
}

/* Shell */
.app {
  block-size: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
}
.sidebar {
  display: none;
}
.main {
  display: flex;
  flex-direction: column;
  min-block-size: 0;
  overflow: hidden;
  /* Room under the content for the floating tab bar (#332); none from 900px, where the sidebar takes its place. */
  padding-block-end: calc(var(--bar-room) + env(safe-area-inset-bottom));
}
:root {
  --bar-room: 92px;
  /* Content keeps a reading width on wide screens (#337): the side gutter grows so a line stays near 40rem. Percentages
     here resolve against each element's containing block, where the property is used. */
  --measure: 40rem;
  --gutter: max(16px, (100% - var(--measure)) / 2);
}
.banner {
  font-size: 0.75rem;
  text-align: center;
  padding-block: 4px;
  padding-inline: 12px;
  background: var(--sunk);
  color: var(--muted);
  padding-block-start: max(4px, env(safe-area-inset-top));
}
/* A dark bar that floats above the content, the open destination in a peach pill (#332). */
.tabbar {
  position: fixed;
  z-index: 5;
  inset-inline: max(16px, (100% - 32rem) / 2);
  inset-block-end: calc(18px + env(safe-area-inset-bottom));
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 32px;
  background: var(--bar);
}
.nav-item {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-block-size: 52px;
  padding-block: 4px;
  border: 0;
  border-radius: 26px;
  background: transparent;
  color: var(--on-bar);
  font-size: 0.6875rem;
  line-height: 1.2;
}
.nav-item.on,
.nav-item.active {
  background: var(--bar-active);
  color: var(--on-bar-active);
  font-weight: 700;
}
.nav-icon {
  position: relative;
  display: inline-grid;
}
.badge {
  position: absolute;
  inset-block-start: -6px;
  inset-inline-end: -12px;
  min-inline-size: 1.65em;
  block-size: 1.65em;
  padding-inline: 0.45em;
  border-radius: 999px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.65em;
  text-align: center;
}
.panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--bg);
  overflow-y: auto;
  padding-block-start: env(safe-area-inset-top);
  padding-block-end: env(safe-area-inset-bottom);
}

@media (min-width: 900px) {
  .app {
    grid-template-columns: 260px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .app.has-panel {
    grid-template-columns: 260px minmax(0, 1fr) minmax(360px, 440px);
  }
  .tabbar {
    display: none;
  }
  .main {
    padding-block-end: 0;
  }
  .nav .nav-item {
    color: var(--muted);
  }
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px 12px;
    border-inline-end: 1px solid var(--line);
    background: var(--surface);
    overflow-y: auto;
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-inline: 8px;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
  }
  .nav {
    display: grid;
    gap: 2px;
  }
  .nav .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-block: 10px;
    padding-inline: 10px;
    border-radius: 10px;
    font-size: 0.9375rem;
    text-align: start;
  }
  .nav .nav-item.on,
  .nav .nav-item.active {
    background: var(--sunk);
    color: var(--ink);
  }
  .panel {
    position: static;
    border-inline-start: 1px solid var(--line);
  }
  .banner {
    padding-block-start: 4px;
  }
}

.history {
  display: grid;
  gap: 2px;
}
.history .eyebrow {
  padding-inline: 10px;
  margin-block-end: 4px;
}
.history-item {
  border: 0;
  background: transparent;
  text-align: start;
  padding-block: 8px;
  padding-inline: 10px;
  border-radius: 8px;
  font-size: 0.875rem;
}
.history-item.on {
  background: var(--sunk);
}

/* Views */
.view-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-block: 12px;
  padding-inline: var(--gutter);
  min-block-size: 60px;
}
.view-head h1 {
  flex: 1;
}
/* A screen opened from another has its Back in reach however far the page is scrolled (#387, hypothesis). */
.view-head.sticky-head {
  position: sticky;
  inset-block-start: 0;
  z-index: 4;
  background: var(--bg);
}
.chat .view-head h1 {
  font-size: 1.125rem;
}
/* The title and, under it, who reads a note (#303). */
.chat-head {
  flex-wrap: wrap;
  row-gap: 0;
}
.chat-head p {
  flex-basis: 100%;
  margin: 0;
}
.page {
  overflow-y: auto;
  padding-block-end: 24px;
}
.page > *:not(.view-head) {
  margin-inline: var(--gutter);
}
.empty-line {
  padding-block: 24px;
  text-align: center;
}
.section-gap {
  margin-block-start: 20px;
  margin-block-end: 8px;
}

/* Chat */
.chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-block-size: 0;
}
.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-block: 8px 16px;
  padding-inline: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.empty {
  margin-block: auto;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  max-inline-size: 480px;
  margin-inline: auto;
}
.empty h2 {
  font-family: var(--font-display);
  font-size: 1.375rem;
}
.suggestion {
  border: 1.5px dashed var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding-block: 12px;
  padding-inline: 16px;
  text-align: start;
  line-height: 1.5;
}
.msg {
  display: grid;
  gap: 6px;
  max-inline-size: min(560px, 88%);
}
.msg.owner {
  align-self: flex-end;
  justify-items: end;
}
.msg.agent {
  align-self: flex-start;
}
.bubble {
  margin: 0;
  padding-block: 12px;
  padding-inline: 16px;
  border-radius: 20px;
  border-start-start-radius: 6px;
  background: var(--surface);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* The person's own words in moss, the corner toward them squared (#332). */
.msg.owner .bubble {
  background: var(--primary);
  color: var(--on-primary);
  border-start-start-radius: 20px;
  border-start-end-radius: 6px;
}
.msg.owner .bubble .muted {
  color: inherit;
}
.meta {
  font-size: 0.75rem;
  color: var(--muted);
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin-block: 4px 12px;
  margin-inline: var(--gutter);
  padding: 6px;
  padding-inline-start: 8px;
  border-radius: var(--radius-field);
  border: 1px solid var(--line);
  background: var(--surface);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-block-size: 8.75rem;
  min-block-size: 44px;
  padding-block: 10px;
  padding-inline: 10px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 0.9375rem;
}
.composer:focus-within {
  border-color: var(--primary);
}

/* Approval card in the thread */
.approval-card {
  display: grid;
  gap: 8px;
  padding-block: 10px 12px;
  padding-inline: 14px;
  border-radius: 16px;
  background: var(--sunk);
}
.card-action {
  margin: 0;
  font-weight: 600;
}
.card-figures {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.approval-card .secondary {
  justify-self: start;
}
.pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding-block: 2px;
  padding-inline: 10px;
  border-radius: 999px;
  background: var(--sunk);
  color: var(--muted);
  white-space: nowrap;
}
.pill.pending {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary);
}
.pill.approved {
  color: var(--primary);
}
.pill.rejected,
.pill.expired {
  color: var(--brand);
}

/* Approvals list */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block: 18px 10px;
}
.seg {
  min-block-size: 40px;
  padding-inline: 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 0.875rem;
}
.seg.on,
.seg.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  font-weight: 600;
}
.list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 10px;
}
.row {
  inline-size: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-card);
  border: 0;
  background: var(--surface);
  text-align: start;
  min-block-size: 56px;
}
.row-main {
  flex: 1;
  display: grid;
  gap: 2px;
}
.row-title {
  font-weight: 700;
  line-height: 1.5;
}
.row-sub {
  font-size: 0.875rem;
  color: var(--muted);
}
.row-end {
  display: grid;
  justify-items: end;
  gap: 4px;
  font-size: 0.875rem;
}

/* Approval detail */
.detail {
  padding-block-end: 24px;
}
.detail > *:not(.view-head) {
  margin-inline: var(--gutter);
}
.facts {
  margin-block: 0 16px;
  display: grid;
  gap: 10px;
}
/* Label and value side by side; at large text sizes the value wraps under its label instead of running off the screen. */
.facts > div {
  display: flex;
  flex-wrap: wrap;
  column-gap: 12px;
  row-gap: 2px;
}
.facts > div > dt {
  flex: 0 0 7.5em;
}
.facts > div > dd {
  flex: 1 1 10em;
}
.facts dt {
  color: var(--muted);
  font-size: 0.875rem;
}
.facts dd {
  margin: 0;
}
.facts.compact {
  gap: 6px;
  font-size: 0.875rem;
}
.amount {
  font-size: 1.25rem;
  font-weight: 700;
}
.outgoing {
  padding-block: 14px 16px;
  padding-inline: 18px;
  border-radius: var(--radius-card);
  background: var(--sunk);
  margin-block-end: 14px;
}
.outgoing-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-block-end: 8px;
}
.lang-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding-block: 2px;
  padding-inline: 8px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--on-soft);
}
.draft {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.draft[lang="en"] {
  font-family: var(--font-ui);
}
.agent-desc {
  padding-block: 10px;
  padding-inline: 14px;
  border-inline-start: 3px solid var(--line);
  margin-block-end: 16px;
}
.agent-desc p {
  margin: 4px 0 0;
  color: var(--muted);
}
/* The head of an approval (#282): the action, whom and how much, then the state, smaller. */
.approval-head {
  margin-block-end: 16px;
}
.approval-action {
  margin: 0;
  font-size: 1.375rem;
  line-height: 1.3;
}
.approval-what {
  margin: 4px 0;
  font-size: 1.125rem;
  font-weight: 600;
}
.approval-head .small {
  margin: 0;
}
/* The agent's description reads as a side note, after the facts. */
.agent-desc.aside {
  font-size: 0.875rem;
}
.agent-desc.aside p {
  margin-block-start: 2px;
}
.promise {
  margin-block: 0 4px;
}
/* What an approval changes, in plain words (#273): a block per record, a row per field. */
.changes {
  margin-block-end: 16px;
}
.change {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1.5px solid var(--line);
  margin-block-start: 8px;
}
.change-title {
  margin: 0 0 10px;
  font-size: 1rem;
}
.change .facts {
  margin-block-end: 0;
}
/* A long value (a rule's text, a list) runs under its label at full width. */
.change .facts > div.long {
  flex-direction: column;
}
.change .facts > div.long > dt,
.change .facts > div.long > dd {
  flex: none;
}
.change-text {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
}
.change-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
.change-before {
  display: block;
  margin-block-start: 8px;
  padding-inline-start: 10px;
  border-inline-start: 3px solid var(--line);
  color: var(--muted);
}
/* The Office view and the approval of a change to how the office works (#427). Colour only through the roles; the
   removed and added lines say so in words, never by colour alone. */
.office-section {
  display: grid;
  gap: 10px;
  margin-block-end: 18px;
}
.office-section > .eyebrow,
.office-section > p,
.office-section > .list,
.office-section > ol {
  margin: 0;
}
.asleep-room {
  background: var(--sunk);
  color: var(--muted);
  min-block-size: 0;
  padding-block: 12px;
}
.waiting-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border-inline-start: 4px solid var(--brand);
}
.changes-list {
  margin: 0;
}
.change-entry {
  margin-block-start: 0;
  display: grid;
  gap: 6px;
}
.change-entry > p {
  margin: 0;
}
.change-entry .change-title {
  margin: 0;
}
.meta-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}
.more-decisions summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.875rem;
}
.plain-text {
  display: grid;
  gap: 8px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.plain-text p,
.plain-text h3 {
  margin: 0;
}
.plain-h {
  font-size: 1rem;
  font-weight: 700;
  margin-block-start: 6px;
}
.plain-list-marks {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
}
.plain-list-marks li {
  display: flex;
  gap: 8px;
}
.plain-list-marks .mark {
  flex: none;
  color: var(--muted);
}
.mech {
  display: grid;
  gap: 12px;
  margin-block-end: 16px;
}
.mech .change {
  margin-block-start: 0;
}
.diff {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
.diff-row {
  display: grid;
  gap: 2px;
  padding-block: 4px;
  padding-inline: 10px;
  border-inline-start: 3px solid var(--line);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.diff-row.added {
  border-inline-start-color: var(--primary);
  background: var(--sunk);
}
.diff-row.removed {
  border-inline-start-color: var(--brand);
  background: var(--sunk);
}
.diff-row.removed .diff-text {
  text-decoration: line-through;
  color: var(--muted);
}
.diff-row.same {
  color: var(--muted);
}
.diff-tag {
  font-size: var(--size-small);
  font-weight: 700;
}
.diff-row.added .diff-tag {
  color: var(--primary);
}
.diff-row.removed .diff-tag {
  color: var(--ink);
}
.diff-text.strong {
  font-weight: 700;
}
.diff-gap {
  padding-inline: 13px;
  margin: 0;
}
.evidence-list {
  margin: 0;
}
.evidence {
  display: grid;
  gap: 4px;
  padding-block-end: 10px;
  border-block-end: 1px solid var(--line);
}
.evidence:last-child {
  border-block-end: 0;
  padding-block-end: 0;
}
.edit textarea,
.lost-draft textarea {
  inline-size: 100%;
  line-height: 1.6;
}
.lost-draft summary {
  cursor: pointer;
  color: var(--muted);
}
.voice-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cannot-show {
  margin: 0;
  padding-block: 10px;
  padding-inline: 14px;
  border-radius: var(--radius);
  background: var(--sunk);
  border-inline-start: 3px solid var(--brand);
}
.answer {
  position: sticky;
  inset-block-end: 0;
  display: grid;
  gap: 10px;
  padding-block: 14px;
  background: var(--bg);
}
.done {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 600;
}
.done.ok {
  color: var(--primary);
}
.reject-form {
  display: grid;
  gap: 8px;
}
.reject-form textarea {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 10px;
  background: var(--surface);
  font-size: 1rem;
}
.row-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Office */
.report {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--sunk);
}
.report p {
  margin: 4px 0 0;
}
.roles {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.role {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  gap: 10px;
}
.role .facts {
  margin: 0;
}
.authority {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 0.875rem;
}
.authority li {
  display: grid;
  gap: 2px;
}
.auth {
  font-size: 0.75rem;
  font-weight: 700;
}
.auth.does {
  color: var(--primary);
}
.auth.asks {
  color: var(--ink);
}
.auth.never {
  color: var(--brand);
}

/* Settings */
.profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-block-end: 12px;
}
.avatar {
  display: grid;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  border-radius: 999px;
  background: var(--sunk);
}
.form {
  display: grid;
  gap: 14px;
  max-inline-size: 520px;
}
.field {
  display: grid;
  gap: 4px;
}
.field-label {
  font-size: 0.875rem;
  font-weight: 600;
}
/* One style for every field: select, text input and text area (#299). */
.field select,
.field input:not([type="radio"]):not([type="checkbox"]):not([type="range"]),
.field textarea {
  min-block-size: 44px;
  padding-inline: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 1rem;
}
.field textarea {
  padding-block: 10px;
  line-height: 1.5;
}
@media (pointer: fine) {
  .field textarea {
    resize: vertical;
  }
}
.field [aria-invalid="true"] {
  border-color: var(--brand);
}
.field-error {
  color: var(--brand);
  font-size: 0.875rem;
}
/* Privacy and data in the pilot (#306) and the About line under the Settings list. */
.plain-list {
  margin: 0;
  padding-inline-start: 1.2em;
  display: grid;
  gap: 8px;
  line-height: 1.6;
}
.privacy h2 {
  margin: 0;
}
.about {
  margin-block: 16px 0;
  text-align: center;
}
/* A ready-to-send card (#299): the customer first, then the text, then one clear next step. */
.outbox-who {
  display: grid;
  gap: 2px;
  margin-block-end: 8px;
}
.outbox-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-block-start: 12px;
}
.outbox .outgoing > .small {
  margin-block: 8px 0;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
.preview {
  display: grid;
  gap: 2px;
  padding: 12px;
  border-radius: 10px;
  background: var(--sunk);
}
.office-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.office-block legend {
  font-weight: 600;
  padding-inline: 4px;
}
.footer-note {
  margin-block-start: 20px;
}
.toast {
  position: fixed;
  inset-inline: 16px;
  /* At the top, clear of the sticky Approve and Reject bar and the tab bar (#282). */
  inset-block-start: calc(12px + env(safe-area-inset-top));
  z-index: 20;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  text-align: center;
}
@media (prefers-reduced-motion: no-preference) {
  .approval-card,
  .msg {
    animation: rise 0.18s ease-out;
  }
  @keyframes rise {
    from {
      opacity: 0;
      translate: 0 6px;
    }
  }
}

:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after {
  animation: none !important;
  transition: none !important;
}

/* Settings in the pilot (#181), text size (#179), install and notices (#180) */
.section-note {
  margin: 0;
  max-inline-size: 520px;
}
.field input[type="time"] {
  min-block-size: 44px;
  padding-inline: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.quiet {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-block-size: 52px;
  padding-block: 8px;
  padding-inline: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.switch-row input {
  accent-color: var(--primary);
  inline-size: 1.4em;
  block-size: 1.4em;
  flex: none;
}
.switch-row .always {
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}
.steps-group {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5em, 1fr));
  gap: 8px;
}
.steps-group legend {
  font-size: 0.875rem;
  font-weight: 600;
  margin-block-end: 6px;
}
.step-choice {
  display: grid;
  place-items: center;
  gap: 2px;
  min-block-size: 64px;
  padding: 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
}
.step-choice.on {
  border-color: var(--primary);
}
.step-choice input {
  position: absolute;
  opacity: 0;
}
.step-choice:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.step-choice .aa {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1;
}
.text-sample {
  padding: 12px;
  border-radius: 10px;
  background: var(--sunk);
}
.text-sample p {
  margin: 0;
}
.notice-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  max-inline-size: 520px;
}
.notice-card p {
  margin: 0;
}
.install-steps {
  margin: 0;
  padding-inline-start: 1.4em;
  display: grid;
  gap: 8px;
  text-align: start;
}
.install-guide {
  max-inline-size: 440px;
  margin-inline: auto;
  padding-block: 8vh 24px;
  padding-inline: 24px;
  display: grid;
  gap: 18px;
}
.install-notes {
  margin: 0;
  padding-inline-start: 1.2em;
  display: grid;
  gap: 8px;
  text-align: start;
  font-size: 0.9375rem;
}
.install-guide .share-glyph {
  display: inline-block;
  inline-size: 1.2em;
  block-size: 1.2em;
  vertical-align: -0.2em;
}
.row[disabled] {
  cursor: default;
  opacity: 0.7;
}

:lang(fa) .install-steps {
  list-style-type: persian;
}
/* A deletion in progress, on every destination until it ends (#307): above everything, plain and hard to miss. */
.deletion-banner {
  padding-block: 10px;
  padding-inline: 16px;
  background: var(--sunk);
  border-block-end: 3px solid var(--danger);
  font-size: 0.875rem;
}
.deletion-banner p {
  margin: 0;
}
/* Who asked and who approves (#274), quieter than the facts above them. */
.facts.who {
  font-size: 0.875rem;
}
/* An agent's notice in Chat (#304): what, then why, smaller. */
.notice-what,
.notice-why {
  margin: 0;
}
.notice-why {
  margin-block-start: 4px;
}
/* The notice a note answers, above the composer, with a way back out. */
.replying {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-block: 6px;
  padding-inline: 12px;
  border-block-start: 1px solid var(--line);
  border-inline-start: 3px solid var(--primary);
  background: var(--surface);
}
.replying-text {
  display: grid;
  min-inline-size: 0;
}
.replying-what {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.answer.lapsed {
  display: grid;
  gap: 10px;
}
/* Reply under an agent's notice sits at its start, as a person's buttons sit at their end; never stretched across. */
.msg.agent {
  justify-items: start;
}

/* The approved composition (#178, design on #332): one large field per screen, the leaf as a quiet watermark,
   cards without borders on the ground, a large type scale (34 / 20 / 16 / 13). */
/* The watermark's box stays inside its field and clips the leaf itself, so the field never overflows: at large text
   sizes nothing scrolls sideways (#179). */
.leaf.watermark {
  position: absolute;
  overflow: hidden;
  pointer-events: none;
}
.leaf.watermark svg {
  position: absolute;
}
/* Approvals: the moss band at the top, with the office, today, the title and how many wait. */
.page > .band {
  margin-inline: 0;
}
.band {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding-block: 36px 30px;
  padding-inline: calc(var(--gutter) + 8px);
  background: var(--band);
  color: var(--on-band);
  border-end-start-radius: 32px;
  border-end-end-radius: 32px;
}
.band .leaf.watermark {
  z-index: -1;
  inset-block: 0;
  inset-inline-start: 0;
  inline-size: 194px;
  color: var(--band-leaf);
  opacity: 0.22;
}
.band .leaf.watermark svg {
  inline-size: 250px;
  block-size: 217px;
  inset-inline-start: -56px;
  inset-block-start: 26px;
  rotate: -8deg;
}
.band-eyebrow {
  margin: 0;
  font-size: var(--size-small);
  color: var(--band-muted);
}
.band h1 {
  margin-block-start: 6px;
  font-size: var(--size-title);
  font-weight: 800;
  line-height: 1.3;
}
.band-line {
  margin: 6px 0 0;
}
:lang(en) .band h1 {
  font-weight: 600;
}
/* A request's kind, on the soft colour. */
.glyph {
  display: grid;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--on-soft);
  flex: none;
}
.glyph .icon {
  inline-size: 20px;
  block-size: 20px;
}
/* Time left to answer: quiet, and in the brand colour under a day. */
.time {
  font-size: 0.75rem;
  font-weight: 600;
  padding-block: 1px;
  padding-inline: 9px;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.time.urgent {
  border-color: var(--brand);
  color: var(--brand);
}
/* An approval: a round Back and the state on the ground, then the peach head with the action, the amount, whom. */
/* The detail scrolls on its own; no padding under the sticky answer, so nothing shows through below it. */
.main > .detail {
  flex: 1;
  overflow-y: auto;
  padding-block-end: 0;
}
.detail-top {
  justify-content: space-between;
}
.detail-top .back {
  background: var(--surface);
}
.detail-state {
  margin: 0;
  font-weight: 600;
}
.approval-head {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  margin-block: 4px 14px;
  padding-block: 22px 20px;
  padding-inline: 22px;
  border-radius: 28px;
  background: var(--soft);
  color: var(--on-soft);
}
.approval-head .leaf.watermark {
  z-index: -1;
  inset-inline-start: 0;
  inset-block-end: 0;
  inline-size: 140px;
  block-size: 113px;
  color: var(--leaf);
  opacity: 0.16;
}
.approval-head .leaf.watermark svg {
  inline-size: 170px;
  block-size: 147px;
  inset-inline-start: -30px;
  inset-block-end: -34px;
  rotate: 10deg;
}
.approval-head .approval-action {
  margin: 0;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.5;
}
/* Large, but never wider than the phone: at the largest text sizes it stops near 12 percent of the screen width. */
.approval-amount {
  margin-block: 8px 0;
  font-size: min(2.75rem, 12vw);
  font-weight: 800;
  line-height: 1.1;
}
.approval-amount .currency {
  font-size: 1rem;
  font-weight: 600;
}
.approval-what {
  margin-block: 10px 0;
  font-size: 0.9375rem;
  font-weight: 400;
}
/* The facts as one card, a hairline between rows. */
.detail .facts {
  gap: 0;
  padding-block: 4px;
  padding-inline: 18px;
  border-radius: var(--radius-card);
  background: var(--surface);
  margin-block-end: 14px;
}
.detail .facts > div {
  padding-block: 9px;
  border-block-end: 1px solid var(--line);
}
.detail .facts > div:last-child {
  border-block-end: 0;
}
.detail .facts dd {
  font-weight: 600;
}
.detail .change .facts {
  padding-inline: 0;
}
/* Approve and Reject at the foot, full width: Approve larger and first; Reject outlined. Label and place differ, not colour alone. */
.detail > .answer {
  margin-inline: 0;
  padding-inline: var(--gutter);
  border-block-start: 1px solid var(--line);
}
.answer .row-buttons {
  flex-wrap: nowrap;
  gap: 10px;
}
.answer .row-buttons > button {
  flex: 1 1 0;
  min-block-size: 54px;
  font-size: 1rem;
}
.answer .row-buttons > .primary {
  flex-grow: 2;
  font-size: 1.0625rem;
  font-weight: 700;
}
.answer .promise,
.detail .promise {
  text-align: center;
}
/* Chat: a large title with a line under the head; Reply in moss, outlined. */
.chat > .view-head {
  padding-block: 20px 14px;
  padding-inline: calc(var(--gutter) + 4px);
  border-block-end: 1px solid var(--line);
}
.chat > .view-head h1 {
  font-size: 1.875rem;
  font-weight: 800;
  line-height: 1.3;
}
:lang(en) .chat > .view-head h1 {
  font-weight: 600;
}
.messages {
  gap: 16px;
  padding-block: 18px;
}
/* Who wrote it: the agent's name beside a small leaf. */
.meta.from {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 700;
}
.msg.agent > .ghost .icon {
  inline-size: 18px;
  block-size: 18px;
}
.msg.agent > .ghost,
.msg.owner > .ghost {
  min-block-size: 36px;
  padding-block: 3px;
  padding-inline: 14px;
  border: 1.5px solid var(--primary);
  border-radius: 18px;
  color: var(--primary);
  font-size: 0.875rem;
}

/* A short screen, such as a phone on its side (#337): the band and the bar give their height back to the content.
   The band drops the date line and the leaf, the bar puts each label beside its icon, the approval's head and its
   answer get tighter. Touch targets stay at least 44px. */
@media (max-height: 500px) {
  :root {
    --bar-room: 64px;
  }
  .tabbar {
    inset-block-end: calc(8px + env(safe-area-inset-bottom));
    padding: 4px;
  }
  .nav-item {
    grid-auto-flow: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    min-block-size: 44px;
    font-size: 0.75rem;
  }
  /* With the label beside the icon, the badge moves to the icon's far side so it never covers the label. */
  .tabbar .badge {
    inset-inline-end: auto;
    inset-inline-start: -14px;
  }
  .band {
    padding-block: 12px 14px;
  }
  .band-eyebrow,
  .band .leaf.watermark,
  .approval-head .leaf.watermark {
    display: none;
  }
  .band h1 {
    margin-block-start: 0;
    font-size: 1.5rem;
  }
  .band-line {
    margin-block-start: 2px;
  }
  .segmented {
    margin-block: 10px 8px;
  }
  .approval-head {
    padding-block: 14px;
  }
  .approval-amount {
    font-size: min(2rem, 12vw);
  }
  .answer {
    padding-block: 8px;
  }
  .answer .row-buttons > button {
    min-block-size: 44px;
  }
  .chat > .view-head {
    padding-block: 10px 8px;
  }
  .chat > .view-head h1 {
    font-size: 1.375rem;
  }
}

/* No connection (#341): a plain line at the top of every destination while the service cannot be reached. */
.offline-bar {
  margin: 0;
  padding-block: 10px;
  padding-inline: 16px;
  background: var(--sunk);
  color: var(--ink);
  border-block-end: 3px solid var(--line);
  font-size: 0.875rem;
}
.main > .offline-bar:first-child {
  padding-block-start: max(10px, env(safe-area-inset-top));
}
.welcome .offline-bar {
  border-radius: var(--radius);
  border-block-end: 0;
}
/* The owner has not filled the quote sender (#233): a plain line over Approvals with a way to the form, as the offline bar. */
.gap-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-block: 10px;
  padding-inline: 16px;
  background: var(--sunk);
  color: var(--ink);
  border-block-end: 3px solid var(--brand);
  font-size: 0.875rem;
}
.gap-bar p {
  margin: 0;
  flex: 1 1 14rem;
}
.main > .gap-bar:first-child {
  padding-block-start: max(10px, env(safe-area-inset-top));
}
/* A new version is ready (#341): it stays until the person taps Update or Later; never a reload by itself. */
.update-bar {
  position: fixed;
  z-index: 30;
  inset-inline: 16px;
  inset-block-start: calc(12px + env(safe-area-inset-top));
  max-inline-size: 32rem;
  margin-inline: auto;
  display: grid;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}
/* The app switcher cover (#340): the leaf mark on the plain ground over every screen while the page is hidden. On at
   once; off with a short fade, none when motion is reduced (the rule above and the system's setting). */
.switcher-cover {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
:root[data-cover="on"] .switcher-cover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: none;
}
@media (prefers-reduced-motion: no-preference) {
  .switcher-cover {
    transition: opacity 0.15s ease-out, visibility 0s linear 0.15s;
  }
}
