/*
 * ASL (أصل) design system — "the reading room".
 *
 * ASL is not a chat app with a price tag; it is an instrument that reads your request
 * before anything is spent. The interface takes its vocabulary from the two places that
 * behaviour comes from: the Arabic manuscript page (a ruled writing area with the reading
 * set in the margin, generous leading, hairlines instead of boxes) and the ledger (figures
 * that align in a column, one metal colour reserved for money and measure).
 *
 * Colour. The palette is the logo's: an ink-blue ground taken darker than the mark's deepest
 * stroke, cool paper for type — dark-on-light inverted, not a terminal. The logo's azure is
 * the ONLY accent and it is spent only on the measure: the clarity reading, the price, the
 * ceiling, the primary action. If azure appears on something that is not a number or a
 * commitment, remove it. Coral stays the one signal colour, warm against an all-blue system.
 *
 * Type. One family, IBM Plex Sans Arabic — a genuine bilingual superfamily, so Arabic and
 * Latin share a skeleton instead of Arabic falling through to a system serif. The display
 * face stays a fall-through to Thuluth II for when the licensed file lands (ROADMAP #9).
 * Sizes follow a 1.25 modular scale; Arabic runs one step larger with more leading, because
 * the script needs it.
 *
 * Structure. Hairlines carry hierarchy; a border-radius means "this is an input you act on".
 * Logical properties throughout, so one stylesheet serves right-to-left Arabic and
 * left-to-right English.
 */
:root {
  color-scheme: dark;
  /* ground: sampled from the logo's own background ink */
  --background: #0E1623;
  --surface-raised: #16293F;
  --border: #2A4058;
  /* type: cool paper on ink */
  --fg-strong: #EAF2FB;       /* headings and emphasis — 15:1 */
  --text: #C9D8E8;            /* body — 11.8:1 */
  --fg: #C9D8E8;
  --text-muted: #8BA1BA;      /* secondary — 6.4:1 */
  /* the measure: the logo's azure, and nothing else */
  --accent: #63AEF0;          /* 7.2:1 on the ground; ink on azure is 7.2:1 back */
  --accent-strong: #8FC8F7;
  --focus-ring: #8FC8F7;
  --line-active: #3D6E9E;     /* a border that has woken up, not a second accent */
  --fill-deep: #1E4E7E;       /* decorative fills only — never type */
  --alert: #E0765A;           /* the one signal colour: needs review, failed, over budget */
  /* derived surfaces: mixes of the system's own values */
  --surface-sunken: color-mix(in srgb, var(--background) 82%, black);
  --surface-hover: color-mix(in srgb, var(--accent) 7%, var(--surface-raised));
  --accent-wash: color-mix(in srgb, var(--accent) 12%, var(--background));
  --font-en: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif;
  /* One family for both scripts. Thuluth II, when licensed, takes over the display face only. */
  --font-ar: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-display: "Thuluth II", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --space-1: 4px; --space-2: 8px; --space-4: 16px; --space-6: 24px; --space-8: 32px;
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 16px;
  --sidebar: 272px;
  --panel: 320px;
  --measure: 66ch;            /* reading column: below 80 characters, per the type scale */
  --scrollbar-thumb: var(--border);
  --scrollbar-track: transparent;
}

* { box-sizing: border-box; }
html { background: var(--background); color: var(--text); font-family: var(--font-en); font-size: 16px; line-height: 26px; -webkit-font-smoothing: antialiased; }
html:lang(ar) { font-family: var(--font-ar); font-size: 17px; line-height: 32px; }
body { margin: 0; min-block-size: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
::selection { background: var(--fill-deep); color: var(--fg-strong); }
* { scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); scrollbar-width: thin; }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--text-muted); }
.caption { font-size: 13px; line-height: 18px; color: var(--text-muted); }
:lang(ar) .caption { font-size: 15px; line-height: 22px; }
svg.i { inline-size: 18px; block-size: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] svg.i.flip { transform: scaleX(-1); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-block-size: 36px; padding-inline: var(--space-4);
  border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-raised); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-hover); border-color: var(--line-active); }
/* Ink on azure: 7.2:1 contrast (pale-blue type on a mid-blue button would be ~1.9:1). */
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--background); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--alert); border-color: var(--alert); }
.btn-danger:hover { background: var(--alert); color: var(--background); }
.btn-ghost:hover { background: var(--surface-raised); border-color: transparent; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon-btn { inline-size: 34px; min-block-size: 34px; padding: 0; background: transparent; border-color: transparent; color: var(--text-muted); }
.icon-btn:hover { color: var(--text); background: var(--surface-raised); border-color: transparent; }
.icon-btn[aria-pressed="true"] { color: var(--background); background: var(--accent); }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* shell */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-block-size: 100dvh; }
.app.with-panel { grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--panel); }
.side { position: sticky; inset-block-start: 0; block-size: 100dvh; display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-4); background: var(--surface-sunken); border-inline-end: 1px solid var(--border); overflow: hidden; }
.brand { display: flex; align-items: center; gap: var(--space-2); color: var(--fg-strong); text-decoration: none; font-family: var(--font-display); font-weight: 600; font-size: 22px; line-height: 30px; padding-inline: var(--space-2); }
:lang(ar) .brand { font-size: 25px; line-height: 36px; font-weight: 500; }
.brand svg { inline-size: 26px; block-size: 26px; color: var(--text-muted); }
.new-chat { inline-size: 100%; justify-content: flex-start; background: transparent; }
.search { position: relative; }
.search svg { position: absolute; inset-inline-start: 10px; inset-block-start: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search input { inline-size: 100%; min-block-size: 36px; padding-inline: 36px var(--space-2); background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); }
.search input::placeholder { color: var(--text-muted); }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: var(--space-2); padding: 6px var(--space-2); border-radius: var(--radius-sm); color: var(--text-muted); text-decoration: none; }
.nav a:hover { background: var(--surface-raised); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-raised); color: var(--text); }
.side-section { min-block-size: 0; display: flex; flex-direction: column; flex: 1; }
/* A section label is a ruled margin note, not a tracked-out all-caps eyebrow: the rule does
   the separating and the word just names what follows. */
.side-label { font-size: 13px; line-height: 18px; color: var(--text-muted); padding: var(--space-2) var(--space-2) var(--space-1);
  border-block-start: 1px solid var(--border); margin-block-start: var(--space-2); }
:lang(ar) .side-label { font-size: 15px; }
.recents { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.recents a { display: block; padding: 6px var(--space-2); border-radius: var(--radius-sm); color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 20px; }
:lang(ar) .recents a { font-size: 16px; line-height: 26px; }
.recents a:hover { background: var(--surface-raised); }
.recents a[aria-current="page"] { background: var(--accent-wash); box-shadow: inset 2px 0 0 var(--accent); }
[dir="rtl"] .recents a[aria-current="page"] { box-shadow: inset -2px 0 0 var(--accent); }
.side-foot { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); padding-block-start: var(--space-2); border-block-start: 1px solid var(--border); }
.meter { display: flex; justify-content: space-between; gap: var(--space-2); padding: var(--space-2); border-radius: var(--radius-md); background: var(--surface-raised); text-decoration: none; color: var(--text); font-size: 14px; line-height: 20px; }
.meter strong { color: var(--fg-strong); }
.profile { display: flex; align-items: center; gap: var(--space-2); inline-size: 100%; padding: var(--space-2); border-radius: var(--radius-md); background: transparent; border: 0; cursor: pointer; text-align: start; }
.profile:hover { background: var(--surface-raised); }
.avatar { inline-size: 30px; block-size: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--fill-deep); color: var(--fg-strong); font-weight: 700; font-size: 13px; flex: none; }
.profile .who { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 20px; }

/* popover menus */
.menu { margin: 0; padding: var(--space-1); min-inline-size: 220px; background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgb(0 0 0 / .45); inset: auto; position: fixed; }
.menu button, .menu a { display: flex; align-items: center; gap: var(--space-2); inline-size: 100%; padding: var(--space-2); border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); text-decoration: none; cursor: pointer; text-align: start; }
.menu button:hover, .menu a:hover { background: var(--surface-hover); }
.menu hr { border: 0; border-block-start: 1px solid var(--border); margin-block: var(--space-1); }

/* stage */
.stage { min-inline-size: 0; display: flex; flex-direction: column; min-block-size: 100dvh; }
.topbar { position: sticky; inset-block-start: 0; z-index: 3; display: flex; align-items: center; gap: var(--space-2); min-block-size: 56px; padding-inline: var(--space-6);
  background: color-mix(in srgb, var(--background) 88%, transparent); backdrop-filter: blur(8px); border-block-end: 1px solid var(--border); }
.topbar .title { flex: 1; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--fg-strong); }
.badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2); border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted); font-size: 12px; line-height: 18px; white-space: nowrap; text-decoration: none; }
:lang(ar) .badge { font-size: 14px; line-height: 22px; }
.menu-toggle { display: none; }
.view { flex: 1; inline-size: 100%; max-inline-size: 52rem; margin-inline: auto; padding: var(--space-6) var(--space-6) 0; display: flex; flex-direction: column; }
.view.wide { max-inline-size: 1080px; }
.view .grow { flex: 1; }

/* Empty state. Set on the writing area's own baseline rather than centred over a decorative
   glyph, so the first thing the page does is point at the box you are about to type in. */
.hero { position: relative; display: grid; justify-items: start; text-align: start; gap: var(--space-2); padding-block: 12vh var(--space-6); }
.display { font-family: var(--font-display); font-size: 39px; line-height: 46px; font-weight: 600; margin: 0; letter-spacing: -.015em; color: var(--fg-strong); text-wrap: balance; }
:lang(ar) .display { font-size: 38px; line-height: 62px; font-weight: 500; letter-spacing: 0; }
.hero .lede { margin: 0; color: var(--text-muted); max-inline-size: 44ch; }
/* The starters are a ruled index of what this thing does, not a row of pills. */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0 var(--space-6); margin-block-start: var(--space-6);
  inline-size: 100%; border-block-start: 1px solid var(--border); }
.quick button { display: flex; align-items: center; gap: var(--space-2); padding: 10px 0; border: 0; border-block-end: 1px solid var(--border);
  background: transparent; color: var(--text); cursor: pointer; text-align: start; }
.quick button svg { color: var(--text-muted); transition: color .12s; }
.quick button:hover { color: var(--fg-strong); }
.quick button:hover svg { color: var(--accent); }
.quick button[aria-pressed="true"] { color: var(--fg-strong); box-shadow: inset 0 -1px 0 var(--accent); }
.quick button[aria-pressed="true"] svg { color: var(--accent); }

/* messages */
.thread { display: grid; gap: var(--space-8); padding-block: var(--space-4) var(--space-8); }
.msg-user { justify-self: end; max-inline-size: min(85%, 640px); display: grid; gap: var(--space-1); justify-items: end; }
.bubble { padding: var(--space-2) var(--space-4); border-radius: var(--radius-lg); border-end-end-radius: var(--radius-sm); background: var(--surface-raised); color: var(--fg-strong); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-tools { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.msg-user:hover .msg-tools, .msg-ai:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
.msg-ai { display: grid; gap: var(--space-2); }
.msg-head { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; color: var(--text-muted); font-size: 14px; line-height: 20px; }
:lang(ar) .msg-head { font-size: 16px; line-height: 26px; }
.mark { inline-size: 24px; block-size: 24px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); }
.mark svg { inline-size: 16px; block-size: 16px; }
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-block-start: 0; }
.md > :last-child { margin-block-end: 0; }
.md h1, .md h2, .md h3 { color: var(--fg-strong); font-weight: 600; margin-block: var(--space-6) var(--space-2); }
.md h1 { font-size: 28px; line-height: 36px; } .md h2 { font-size: 20px; line-height: 28px; } .md h3 { font-size: 17px; line-height: 26px; }
:lang(ar) .md h1 { font-size: 26px; line-height: 40px; font-weight: 400; } :lang(ar) .md h2, :lang(ar) .md h3 { font-weight: 400; font-size: 22px; line-height: 34px; }
.md p, .md ul, .md ol { margin-block: 0 var(--space-4); }
.md ul, .md ol { padding-inline-start: var(--space-6); }
.md strong { color: var(--fg-strong); }
.md blockquote { margin: 0 0 var(--space-4); padding-inline-start: var(--space-4); border-inline-start: 2px solid var(--fill-deep); color: var(--text-muted); }
.md pre { background: var(--surface-sunken); border: 1px solid var(--border); padding: var(--space-4); border-radius: var(--radius-md); overflow-x: auto; direction: ltr; text-align: start; font-size: 14px; line-height: 21px; }
.md code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; background: var(--surface-raised); padding: 1px 5px; border-radius: var(--radius-sm); direction: ltr; unicode-bidi: isolate; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; margin-block-end: var(--space-4); }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: start; }
.md th { color: var(--fg-strong); background: var(--surface-raised); }
mark.flag { background: none; color: inherit; text-decoration: underline wavy var(--alert); text-underline-offset: 4px; cursor: help; }
.caret { display: inline-block; inline-size: 8px; block-size: 1.1em; background: var(--accent); vertical-align: text-bottom; border-radius: 1px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.thinking { display: inline-flex; gap: 4px; align-items: center; } .thinking i { inline-size: 6px; block-size: 6px; border-radius: 50%; background: var(--accent); animation: dot 1.2s infinite ease-in-out; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.sources { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.sources a { display: inline-flex; align-items: center; gap: 6px; max-inline-size: 280px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 13px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sources a:hover { border-color: var(--accent); }
.images { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-2); }
.images img { inline-size: 100%; block-size: auto; border-radius: var(--radius-md); border: 1px solid var(--border); display: block; }
.msg-foot { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: 13px; line-height: 18px; color: var(--text-muted); }
:lang(ar) .msg-foot { font-size: 15px; line-height: 22px; }
.receipt strong, .saved { color: var(--fg-strong); font-weight: 600; }
.card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); }
.card-title { font-weight: 600; color: var(--fg-strong); margin: 0 0 var(--space-2); }
.notice { display: flex; align-items: center; gap: var(--space-2) var(--space-4); flex-wrap: wrap; justify-content: space-between; padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md); background: var(--accent-wash); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: 14px; line-height: 20px; }
:lang(ar) .notice { font-size: 16px; line-height: 26px; }
/* Status is carried by an icon and a stronger outline: the system has a single hue family. */
.notice.error { border-color: var(--alert); background: var(--surface-raised); justify-content: flex-start; }
.notice.error::before { content: "!"; display: grid; place-items: center; inline-size: 22px; block-size: 22px; border-radius: 50%; background: var(--alert); color: var(--background); font-weight: 700; flex: none; }
.notice .grow { flex: 1; min-inline-size: 12rem; }
.probe { border-style: dashed; }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-4); }
.compare .card { display: grid; gap: var(--space-2); align-content: start; }
.compare .card.chosen { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.verify { border-inline-start: 2px solid var(--alert); padding-inline-start: var(--space-4); font-size: 14px; line-height: 21px; }
:lang(ar) .verify { font-size: 16px; line-height: 26px; }
.verify ul { margin: var(--space-1) 0 0; padding-inline-start: var(--space-4); }

/* composer */
.dock { position: sticky; inset-block-end: 0; z-index: 2; padding: var(--space-6) 0 var(--space-4); background: linear-gradient(to bottom, transparent, var(--background) 40px); }
/* The writing area. One surface, one rule, no drop shadow — the page is a sheet, not a stack
   of floating cards, and the only thing that lifts off it is a popover. */
.composer { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); transition: border-color .15s; }
.composer:focus-within { border-color: var(--line-active); }
.composer.drag { border-color: var(--accent); border-style: dashed; }
.composer textarea { display: block; inline-size: 100%; field-sizing: content; min-block-size: 3lh; max-block-size: 12lh; resize: none; padding: var(--space-4) var(--space-4) var(--space-2);
  border: 0; outline: none; background: transparent; color: var(--fg-strong); }
.composer textarea::placeholder { color: var(--text-muted); }
@supports not (field-sizing: content) { .composer textarea { block-size: 6lh; } }
.tray { display: flex; flex-wrap: wrap; gap: var(--space-2); padding-inline: var(--space-4); }
.att { display: inline-flex; align-items: center; gap: 6px; max-inline-size: 260px; padding-block: 2px; padding-inline: 10px 4px; border-radius: var(--radius-sm); background: var(--background); border: 1px solid var(--border); font-size: 13px; line-height: 22px; }
.att .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.att[data-state="error"] { border-color: var(--alert); }
.att button { border: 0; background: none; color: var(--text-muted); cursor: pointer; padding: 0 4px; }
.toolbar { display: flex; align-items: flex-end; gap: var(--space-2); padding: var(--space-2); }
.toolbar .opts { flex: 1; min-inline-size: 0; display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.model-pick { display: inline-flex; align-items: center; gap: 6px; min-block-size: 34px; padding-inline: 10px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--background); color: var(--text); cursor: pointer; max-inline-size: 240px; }
.model-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle { display: inline-flex; align-items: center; gap: 6px; min-block-size: 34px; padding-inline: 10px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 14px; line-height: 20px; }
:lang(ar) .toggle { font-size: 16px; }
.toggle:hover { color: var(--text); background: var(--background); }
.toggle[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: var(--accent-wash); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--background); }
.seg button { border: 0; background: transparent; color: var(--text-muted); padding: 2px 10px; border-radius: 999px; cursor: pointer; font-size: 13px; line-height: 24px; }
:lang(ar) .seg button { font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--surface-raised); color: var(--text); }
.send { min-block-size: 38px; border-radius: var(--radius-md); padding-inline: var(--space-6); }
/* Folded options: the button carries the count, so nothing is hidden, only put away. */
.options-btn[aria-pressed="true"] { color: var(--fg-strong); border-color: var(--line-active); background: transparent; }
.options-menu { inline-size: min(340px, 92vw); }
.options-menu .opt-row { display: grid; grid-template-columns: 18px 1fr; gap: var(--space-2); align-items: start; padding: var(--space-2); }
.options-menu .opt-row > span:last-child { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2); align-items: center; }
.options-menu .opt-row small { grid-column: 2; display: block; color: var(--text-muted); font-size: 13px; line-height: 18px; }
:lang(ar) .options-menu .opt-row small { font-size: 14px; line-height: 21px; }
.options-menu .tick { color: var(--accent); }
.menu-label { margin: var(--space-1) var(--space-2); color: var(--text-muted); font-size: 13px; }
.menu-seg { padding: 0 var(--space-2) var(--space-2); }

/* ------------------------------------------------------------------ the reading
 * A manuscript page: the platform's reading is set in the margin, hairline-ruled off the
 * body, and what the user can act on sits in the writing area. The gloss narrows and moves
 * above the body on a phone, where there is no margin to speak of.
 */
.coach { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 0 var(--space-6);
  padding: var(--space-4); border-block-end: 1px solid var(--border); max-block-size: 55vh; overflow-y: auto; }
.coach-body { display: grid; gap: var(--space-4); align-content: start; min-inline-size: 0; }
.gloss { display: grid; gap: var(--space-2); align-content: start; padding-inline-end: var(--space-6);
  border-inline-end: 1px solid var(--border); }
[dir="rtl"] .gloss { padding-inline-end: var(--space-6); }
.gloss .verdict { color: var(--fg-strong); font-weight: 600; font-size: 16px; line-height: 22px; }
:lang(ar) .gloss .verdict { font-size: 18px; line-height: 28px; font-weight: 500; }
.gloss-hint { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 19px; }
:lang(ar) .gloss-hint { font-size: 15px; line-height: 24px; }
.d-review .gloss .verdict { color: var(--alert); }
.reasons { list-style: none; margin: var(--space-1) 0 0; padding: 0; display: grid; gap: 2px; font-size: 13px; line-height: 19px; color: var(--text-muted); }
:lang(ar) .reasons { font-size: 14px; line-height: 22px; }
.reasons li { display: grid; grid-template-columns: 2.6em 1fr; gap: var(--space-1); }
.reasons .num { text-align: end; color: var(--text-muted); }
.reasons .up .num { color: var(--accent); }
.ring { --v: 0; position: relative; inline-size: 52px; block-size: 52px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--accent) calc(var(--v) * 1%), var(--border) 0); display: grid; place-items: center; }
.ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface-raised); }
.ring b { position: relative; font-size: 17px; line-height: 1; font-weight: 600; color: var(--fg-strong); font-variant-numeric: tabular-nums; }
.d-review .ring { background: conic-gradient(var(--alert) calc(var(--v) * 1%), var(--border) 0); }
/* The one orchestrated moment: the reading arrives by filling, once, and never again. */
@media (prefers-reduced-motion: no-preference) {
  .ring { animation: fill .5s cubic-bezier(.2, .7, .3, 1) both; }
  @keyframes fill { from { background: conic-gradient(var(--accent) 0, var(--border) 0); } }
}
.coach-row { display: flex; align-items: center; gap: var(--space-2) var(--space-4); flex-wrap: wrap; }
.coach-label { color: var(--text-muted); font-size: 13px; line-height: 18px; }
:lang(ar) .coach-label { font-size: 15px; line-height: 22px; }
.coach-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); }
.coach .note { margin: 0; padding-inline-start: var(--space-4); border-inline-start: 2px solid var(--alert); color: var(--text); font-size: 14px; line-height: 21px; }
:lang(ar) .coach .note { font-size: 16px; line-height: 26px; }

/* Questions: required ones carry the word, not a colour alone. */
.qs { display: grid; gap: var(--space-2) var(--space-4); grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.field.q > span { display: flex; align-items: baseline; gap: var(--space-2); color: var(--text); }
.field.q .req { font-style: normal; color: var(--alert); font-size: 12px; }
:lang(ar) .field.q .req { font-size: 14px; }

/* Improvements: a ruled list of named, reversible edits, each with its reason. */
.improvements { list-style: none; margin: 0; padding: 0; display: grid; }
.improvement { border-block-start: 1px solid var(--border); }
.improvement:last-child { border-block-end: 1px solid var(--border); }
.improvement label { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-2); align-items: start; padding-block: 8px; cursor: pointer; }
.improvement input { margin: 4px 0 0; accent-color: var(--accent); inline-size: 16px; block-size: 16px; }
.imp-text { display: grid; gap: 1px; min-inline-size: 0; }
.imp-label { color: var(--text-muted); font-size: 14px; line-height: 20px; }
:lang(ar) .imp-label { font-size: 16px; line-height: 25px; }
.improvement.on .imp-label { color: var(--text); }
.imp-label b { color: var(--fg-strong); font-weight: 600; }
.imp-text small { color: var(--text-muted); font-size: 12px; line-height: 17px; opacity: .8; }
:lang(ar) .imp-text small { font-size: 14px; line-height: 21px; }
/* Three ways out of the panel, set as quiet text: underlining all of them would compete with
   the one thing on this screen that should look like a commitment (the run button). */
.panel-actions { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); font-size: 14px; padding-block-start: var(--space-1); }
:lang(ar) .panel-actions { font-size: 16px; }
.panel-actions .linklike { color: var(--text-muted); text-decoration: none; }
.panel-actions .linklike:hover { color: var(--fg-strong); text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px; border: 1px dashed var(--line-active); background: transparent; color: var(--text); cursor: pointer; font-size: 13px; line-height: 22px; }
:lang(ar) .chip { font-size: 15px; line-height: 24px; }
.chip.filled { border-style: solid; border-color: var(--accent); background: var(--accent-wash); }
.chip select { background: transparent; border: 0; color: var(--fg-strong); padding: 0; max-inline-size: 22ch; field-sizing: content; }
.chip select option { background: var(--surface-raised); }
.brief { display: grid; gap: var(--space-2) var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: grid; gap: var(--space-1); font-size: 13px; line-height: 18px; color: var(--text-muted); }
:lang(ar) .field { font-size: 15px; line-height: 22px; }
.field input, .field textarea, .field select, .input { inline-size: 100%; padding: 6px 10px; background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--fg-strong); }
.field textarea { field-sizing: content; min-block-size: 2lh; max-block-size: 8lh; resize: vertical; }
.field.span { grid-column: 1 / -1; }
.decision { display: flex; align-items: center; gap: var(--space-2) var(--space-4); flex-wrap: wrap; font-size: 14px; line-height: 21px; }
:lang(ar) .decision { font-size: 16px; line-height: 26px; }
.decision .model { color: var(--fg-strong); font-weight: 600; }
.decision .reason { color: var(--text-muted); }
.forecast { display: inline-flex; align-items: center; gap: 4px; color: var(--fg-strong); }
.price strong { color: var(--fg-strong); }
.band { font-size: 11px; line-height: 16px; letter-spacing: .06em; text-transform: uppercase; padding: 1px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--text-muted); font-family: var(--font-en); }
:lang(ar) .band { letter-spacing: 0; text-transform: none; font-size: 13px; font-family: var(--font-ar); }
.band.max { border-color: var(--accent); color: var(--accent); }
.band.free { border-color: var(--line-active); }
.passport-offer { margin-block-end: var(--space-2); }

/* model menu */
.model-menu { inline-size: min(440px, 92vw); max-block-size: 62vh; overflow-y: auto; }
.model-menu .group { font-size: 12px; line-height: 16px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); padding: var(--space-2) var(--space-2) var(--space-1); }
:lang(ar) .model-menu .group { letter-spacing: 0; text-transform: none; font-size: 14px; }
.model-menu .opt { display: grid; grid-template-columns: 18px 1fr auto; gap: var(--space-2); align-items: center; }
.model-menu .opt small { display: block; color: var(--text-muted); font-size: 12px; line-height: 16px; }
:lang(ar) .model-menu .opt small { font-size: 14px; line-height: 20px; }
.model-menu .opt[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.model-menu .tick { color: var(--accent); }

/* Passport panel */
.panel { position: sticky; inset-block-start: 0; block-size: 100dvh; overflow-y: auto; padding: var(--space-4); border-inline-start: 1px solid var(--border); background: var(--surface-sunken); display: grid; align-content: start; gap: var(--space-4); }
.panel h2 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 600; color: var(--fg-strong); }
:lang(ar) .panel h2 { font-weight: 400; font-size: 22px; line-height: 34px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }

/* pages */
.page-head { display: flex; align-items: end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-block-end: var(--space-6); }
.heading { font-size: 28px; line-height: 36px; font-weight: 600; margin: 0; color: var(--fg-strong); }
:lang(ar) .heading { font-size: 26px; line-height: 40px; font-weight: 400; }
.sub { font-size: 20px; line-height: 28px; font-weight: 600; margin: var(--space-8) 0 var(--space-4); color: var(--text); }
:lang(ar) .sub { font-weight: 400; font-size: 22px; line-height: 34px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-4); }
.tile { display: grid; gap: var(--space-2); align-content: start; padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-raised); color: var(--text); text-align: start; cursor: pointer; text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.tile strong { color: var(--fg-strong); }
.tile .ico { inline-size: 36px; block-size: 36px; border-radius: var(--radius-md); display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); }
.tile p { margin: 0; color: var(--text-muted); font-size: 14px; line-height: 21px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
:lang(ar) .tile p { font-size: 16px; line-height: 26px; }
.tile-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.stat { display: flex; gap: var(--space-8); flex-wrap: wrap; align-items: baseline; }
.stat .big { font-size: 40px; line-height: 48px; font-weight: 700; color: var(--fg-strong); font-family: var(--font-en); }
.table { inline-size: 100%; border-collapse: collapse; font-size: 14px; line-height: 21px; }
:lang(ar) .table { font-size: 16px; line-height: 26px; }
.table th, .table td { text-align: start; padding: var(--space-2); border-block-end: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--text-muted); font-weight: 500; }
.form { display: grid; gap: var(--space-4); max-inline-size: 26rem; }
.form label { display: grid; gap: var(--space-1); color: var(--text-muted); font-size: 14px; }
:lang(ar) .form label { font-size: 16px; }
.form input, .form select { min-block-size: 40px; padding-inline: var(--space-4); background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--fg-strong); }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: var(--space-8); }
.empty { color: var(--text-muted); padding-block: var(--space-6); }
.toast { position: fixed; inset-block-end: var(--space-6); inset-inline-start: 50%; translate: -50% 0; z-index: 50; padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); background: var(--fg-strong); color: var(--background); font-weight: 600; box-shadow: 0 10px 30px rgb(0 0 0 / .4); }
[dir="rtl"] .toast { translate: 50% 0; }
.scrim { display: none; }

/* legacy classes used by the sandbox checkout page */
.sheet { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.pad { padding: var(--space-6); }
.lede { color: var(--text-muted); }
body > main { max-inline-size: 760px; margin-inline: auto; padding: var(--space-8) var(--space-6); }
body > main > h1 { font-size: 28px; line-height: 36px; color: var(--fg-strong); }

/* responsive */
@media (max-width: 1180px) {
  .app.with-panel { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .app.with-panel .panel { position: fixed; inset-block: 0; inset-inline-end: 0; inline-size: min(var(--panel), 92vw); z-index: 30; box-shadow: 0 0 40px rgb(0 0 0 / .5); }
}
@media (max-width: 860px) {
  .app, .app.with-panel { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; inline-size: min(var(--sidebar), 86vw); z-index: 40; translate: -105% 0; transition: translate .2s ease; }
  [dir="rtl"] .side { translate: 105% 0; }
  .app.nav-open .side { translate: 0 0; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(0 0 0 / .5); }
  .menu-toggle { display: inline-flex; }
  .view { padding-inline: var(--space-4); }
  .topbar { padding-inline: var(--space-2); }
  .display { font-size: 30px; line-height: 40px; }
  :lang(ar) .display { font-size: 28px; line-height: 48px; }
  .toolbar .label-sm { display: none; }
  .toolbar { flex-wrap: nowrap; }
  .toolbar .opts { flex-wrap: nowrap; }
  .model-pick { max-inline-size: 38vw; }
  .send { padding-inline: var(--space-4); }
  /* No margin to gloss into on a phone: the reading goes above the body, under its own rule. */
  .coach { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
  .gloss { border-inline-end: 0; border-block-end: 1px solid var(--border); padding-inline-end: 0; padding-block-end: var(--space-4);
    grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .gloss .ring { grid-row: span 2; }
  .gloss .reasons, .gloss .caption { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* admin console (same tokens) */
.admin-shell { display: grid; grid-template-columns: 15rem 1fr; min-block-size: 100vh; }
.admin-nav { background: var(--surface-sunken); border-inline-end: 1px solid var(--border); padding: var(--space-4); display: flex; flex-direction: column; gap: 2px; }
.admin-nav .brand { margin-block-end: var(--space-4); }
.admin-nav a { color: var(--text-muted); text-decoration: none; padding: 6px var(--space-2); border-radius: var(--radius-sm); font-size: 14px; }
.admin-nav a:hover { background: var(--surface-raised); color: var(--text); }
.admin-nav a[aria-current="page"] { background: var(--surface-raised); color: var(--fg-strong); }
.admin-main { padding: var(--space-6) var(--space-8) var(--space-8); overflow-x: auto; }
.admin-main h1 { font-size: 28px; line-height: 36px; color: var(--fg-strong); margin: 0 0 var(--space-4); }
.admin-main h2 { font-size: 20px; line-height: 28px; margin: var(--space-8) 0 var(--space-2); color: var(--fg-strong); }
.admin-main h3 { font-size: 16px; line-height: 24px; font-weight: 600; margin: var(--space-6) 0 var(--space-1); color: var(--text); }
.admin-main .lede { max-inline-size: 60rem; }
.admin-main h3 + .mini { max-inline-size: 60rem; margin-block: 0 var(--space-2); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--space-2); margin-block: var(--space-4); }
.kpi { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; }
.kpi .v { font-size: 22px; line-height: 30px; font-weight: 700; color: var(--fg-strong); }
.kpi .l, .kpi .d { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.alert { padding: var(--space-2) 12px; border-radius: var(--radius-sm); margin-block: var(--space-1); font-size: 14px; border-inline-start: 3px solid var(--line-active); background: var(--surface-raised); }
.alert.critical { border-color: var(--fg-strong); } .alert.info { border-color: var(--fill-deep); }
.bars { display: flex; align-items: flex-end; gap: 4px; block-size: 6rem; border-block-end: 1px solid var(--border); }
.bars div { flex: 1; max-inline-size: 2.5rem; background: var(--fill-deep); min-block-size: 1px; border-radius: 2px 2px 0 0; }
.admin-main .toolbar input, .admin-main .toolbar select { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 8px; background: var(--background); color: var(--fg-strong); }
.mini { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.pill-ok { color: var(--fg-strong); font-weight: 600; } .pill-bad { color: var(--alert); font-weight: 700; text-decoration: underline wavy; }
pre.json { background: var(--surface-sunken); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 12px; max-block-size: 24rem; color: var(--text); }
.edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: var(--space-2); }
.edit-grid label { display: grid; gap: 2px; font-size: 12px; color: var(--text-muted); }
.edit-grid input, .edit-grid select, .edit-grid textarea { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 8px; font-size: 14px; background: var(--background); color: var(--fg-strong); }
details.card summary { cursor: pointer; font-weight: 600; }
details.card { margin-block: var(--space-2); }
.tile .linklike { justify-self: start; }
/*
 * Organisation accounts (orgnizationAccount.md §23.4). Brass stays reserved for the measure, so
 * the budget ring is the only new place it appears: it is a number and a commitment. Status is
 * always carried by text as well as colour (WCAG 2.1 AA), and every rule uses logical properties
 * so one stylesheet serves both directions.
 */
.org-switch { display: flex; align-items: center; gap: var(--space-2); inline-size: 100%; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-md); background: transparent; color: var(--text); cursor: pointer; text-align: start; font-size: 14px; line-height: 20px; }
.org-switch:hover { background: var(--surface-hover); }
.org-switch .who { flex: 1; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { flex: none; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted); font-size: 11px; line-height: 16px; }

/* The budget meter: a conic ring, a percentage in the middle, and the renewal date beside it. */
.budget-meter { display: flex; align-items: center; gap: var(--space-2); inline-size: 100%; padding: var(--space-2); border: 0; border-radius: var(--radius-md); background: var(--surface-raised); color: var(--text); cursor: pointer; text-align: start; }
.budget-meter:hover { background: var(--surface-hover); }
.budget-meter .grow { flex: 1; min-inline-size: 0; display: grid; font-size: 13px; line-height: 18px; }
.budget-meter .grow small { color: var(--text-muted); font-size: 12px; line-height: 16px; }
.budget-meter .ring { position: relative; flex: none; display: grid; place-items: center; inline-size: 34px; block-size: 34px; border-radius: 50%;
  background: conic-gradient(var(--ring-colour, var(--accent)) calc(var(--pct) * 1%), var(--border) 0); }
.budget-meter .ring::before { content: ""; position: absolute; inline-size: 26px; block-size: 26px; border-radius: 50%; background: var(--surface-raised); }
.budget-meter .ring .num { position: relative; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--fg-strong); }
.budget-meter.warn { --ring-colour: var(--accent); }
.budget-meter.high, .budget-meter.over { --ring-colour: var(--alert); }
.budget-meter.over .grow small { color: var(--alert); }

.bell { position: relative; display: flex; align-items: center; justify-content: center; inline-size: 100%; padding: var(--space-2); border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-muted); cursor: pointer; }
.bell:hover { background: var(--surface-hover); color: var(--text); }
.bell .badge { position: absolute; inset-block-start: 2px; inset-inline-end: 8px; min-inline-size: 16px; padding: 0 4px; border-radius: 999px; background: var(--alert); color: var(--fg-strong); font-size: 11px; line-height: 16px; font-weight: 700; }
.bell-menu { inline-size: min(360px, 92vw); max-block-size: 70vh; overflow-y: auto; }
.bell-menu .opt.unread > span:first-child { font-weight: 600; color: var(--fg-strong); }

/* A read-only menu row: the same grid as `.opt` without the affordances of a button. */
.menu .opt.static { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2); align-items: center; padding: var(--space-2); }
.menu .opt.static > span:first-child { display: grid; }
.menu .opt.static small { color: var(--text-muted); font-size: 12px; line-height: 16px; }

.charge-to { max-inline-size: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* What this run leaves of the budget, next to the price. */
.budget-hint { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.budget-hint.near_limit { color: var(--accent); }
.budget-hint.will_exceed, .budget-hint.needs_approval { color: var(--alert); }

/*
 * The blocked panel replaces the Run button in place. It is never a modal: a member who cannot run
 * something needs the reason and the next step in front of them, not a dialog to dismiss.
 */
.notice.blocked { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); border-color: var(--alert); background: var(--surface-raised); justify-content: flex-start; }
.notice.blocked strong { color: var(--fg-strong); }
.notice.blocked .caption { flex-basis: 100%; }

dialog.sheet { margin: auto; inline-size: min(28rem, 92vw); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-raised); color: var(--text); }
dialog.sheet::backdrop { background: rgb(0 0 0 / .55); }
dialog.sheet form { display: grid; gap: var(--space-4); padding: var(--space-6); }
dialog.sheet h3 { margin: 0; color: var(--fg-strong); }
dialog.sheet .sheet-foot { display: flex; gap: var(--space-2); justify-content: flex-end; }

.invite { max-inline-size: 32rem; margin-inline: auto; display: grid; gap: var(--space-4); }
.invite .invite-org { margin: 0; font-family: var(--font-display); font-size: 24px; line-height: 32px; color: var(--fg-strong); }
.invite .row { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/*
 * The organisation console at /org. It reuses the admin shell's grid, but it is a customer-facing
 * screen: Arabic-first, right-to-left by default, and typed at the reading sizes of the work screen
 * rather than the denser internal console.
 */
.org-console .admin-nav a { display: flex; align-items: center; gap: var(--space-2); }
.org-console .admin-nav .brand { display: block; font-family: var(--font-display); font-size: 20px; line-height: 28px; color: var(--fg-strong); text-decoration: none; }
.org-console .admin-nav .role-badge { align-self: flex-start; margin-block-end: var(--space-4); }
.org-console .admin-nav .grow { flex: 1; }
.org-console .admin-nav .linklike { text-align: start; padding: 6px var(--space-2); font-size: 14px; }
:lang(ar) .org-console .admin-main { font-size: 16px; line-height: 26px; }
.org-console .toolbar { align-items: center; padding-inline: 0; }
.org-console .toolbar h2 { margin-block: 0; }
.org-console .row-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.org-console .card.pad { padding: var(--space-4); }
.org-console .empty { color: var(--text-muted); padding: var(--space-4) 0; }

/* A budget bar states its percentage in text as well as filling, so colour is never the only cue. */
.progress { position: relative; display: block; min-inline-size: 6rem; block-size: 18px; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; }
.progress .fill { position: absolute; inset-block: 0; inset-inline-start: 0; inline-size: calc(var(--pct) * 1%); background: var(--fill-deep); }
.progress .label { position: relative; display: block; text-align: center; font-size: 11px; line-height: 18px; font-weight: 600; color: var(--fg-strong); }
.progress.warn .fill { background: var(--line-active); }
.progress.high .fill, .progress.over .fill { background: var(--alert); }

.wizard .steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.wizard .steps li { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-md); }
.wizard .steps li.done { color: var(--text-muted); border-style: dashed; }
.wizard .steps li .grow { flex: 1; }
.wizard .steps .dot { inline-size: 18px; block-size: 18px; border: 2px solid var(--line-active); border-radius: 50%; flex: none; }

label.check { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-2); align-items: center; padding-block: var(--space-1); font-size: 14px; }
label.check small { grid-column: 2; color: var(--text-muted); font-size: 12px; line-height: 16px; }
.org-console .field small { color: var(--text-muted); font-size: 12px; line-height: 16px; }
.org-console h4 { margin: var(--space-4) 0 var(--space-1); font-size: 14px; color: var(--text-muted); text-transform: none; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.preview-out { margin-block-start: var(--space-2); }
.toast.bad { background: var(--surface-raised); color: var(--fg-strong); outline: 2px solid var(--alert); }

@media (max-width: 860px) {
  .org-console.admin-shell { grid-template-columns: minmax(0, 1fr); }
  .org-console .admin-nav { flex-direction: row; flex-wrap: wrap; border-inline-end: 0; border-block-end: 1px solid var(--border); }
  .org-console .admin-nav .brand, .org-console .admin-nav .role-badge { margin-block-end: 0; }
  .org-console .admin-main { padding: var(--space-4); }
}

/* ---------------------------------------------------------------- sign in, registration and the closed door
   The gate is the whole screen when the service is private: one centred column, the brand above
   it, and no navigation, because none of it would answer. The account-type tiles are the first
   thing anyone sees, so they carry the weight — everything after them is an ordinary form. */
.app-gate { display: block; }
.app-gate .stage { align-items: center; justify-content: center; padding: var(--space-6) var(--space-4); }
.gate { inline-size: 100%; max-inline-size: 30rem; display: grid; gap: var(--space-6); }
.gate-head { display: grid; justify-items: center; gap: var(--space-2); text-align: center; }
.gate-head .display { font-size: 31px; line-height: 38px; }
.gate-head .lede { max-inline-size: 38ch; margin: 0; }
/* The lockup is silver on the page's own ink, so there is no plate edge to draw: a rule here would
   frame empty ground. The mark sits in the page rather than on it. */
.gate-logo { inline-size: 100%; max-inline-size: 15rem; block-size: auto; }
.gate-foot { display: flex; justify-content: center; }
.gate .auth-panel { padding: var(--space-6); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-raised); }
.gate .auth-form, .gate .auth-panel .form { max-inline-size: none; }

.auth-panel { display: grid; gap: var(--space-4); }
.auth-step { display: grid; gap: var(--space-4); }
.auth-h { margin: 0; }
.auth-stepmark { margin: 0; font-size: 13px; line-height: 18px; color: var(--text-muted); }
:lang(ar) .auth-stepmark { font-size: 15px; }
.auth-form label small { font-size: 12px; line-height: 16px; }

.auth-types { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.auth-type { gap: var(--space-1); border-color: var(--border); }
.auth-type:hover { border-color: var(--accent); background: var(--surface-hover); }
.auth-type-mark { color: var(--text-muted); }
.auth-type:hover .auth-type-mark { color: var(--accent); }
.auth-type-mark svg { inline-size: 24px; block-size: 24px; }

/* "or" as a ruled line rather than a floating word, so the two routes read as equals. */
.auth-alt { display: grid; gap: var(--space-4); }
.auth-or { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-4); color: var(--text-muted); font-size: 13px; }
.auth-or::before, .auth-or::after { content: ""; border-block-start: 1px solid var(--border); }
.btn-google { inline-size: 100%; gap: var(--space-2); }
.btn-google svg { inline-size: 18px; block-size: 18px; flex: none; }
