/* Render Relay phone app (relay.expel.gg). The Expel "family" look: tokens and components copied from
   Render Relay's app/css/family.css (dash.expel.gg tokens), cut down for one phone page.
   Light/dark follows the phone (prefers-color-scheme). No inline styles anywhere (CSP style-src 'self'). */

/* Barlow and Barlow Condensed, stored locally (latin subset, SIL OFL 1.1: fonts/OFL.txt). */
@font-face{font-family:"Barlow";font-style:normal;font-weight:400;font-display:swap;src:url(fonts/barlow-400.woff2) format("woff2")}
@font-face{font-family:"Barlow";font-style:normal;font-weight:500;font-display:swap;src:url(fonts/barlow-500.woff2) format("woff2")}
@font-face{font-family:"Barlow";font-style:normal;font-weight:600;font-display:swap;src:url(fonts/barlow-600.woff2) format("woff2")}
@font-face{font-family:"Barlow";font-style:normal;font-weight:700;font-display:swap;src:url(fonts/barlow-700.woff2) format("woff2")}
@font-face{font-family:"Barlow Condensed";font-style:normal;font-weight:600;font-display:swap;src:url(fonts/barlow-condensed-600.woff2) format("woff2")}
@font-face{font-family:"Barlow Condensed";font-style:normal;font-weight:700;font-display:swap;src:url(fonts/barlow-condensed-700.woff2) format("woff2")}

:root {
  --plane: #f3f4f1; --surface: #fcfcfb; --ink: #101512; --ink-2: #4d5550; --muted: #6b736d;
  --grid: #e3e5e0; --axis: #c4c8c1; --hair: rgba(16, 21, 18, .10); --wash: rgba(16, 21, 18, .045);
  --s1: #2a78d6; --s2: #eb6834; --s4: #eda100; --good: #006300; --bad: #c23434;
  --chip: #101512; --chip-ink: #fcfcfb; --note: #fff7e6; --note-edge: #e9c46a; --brand: #ff3535;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --sans: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pad: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --plane: #0d0f0e; --surface: #171a18; --ink: #f2f4f1; --ink-2: #bec4be; --muted: #8a918b;
    --grid: #282c29; --axis: #3a3f3b; --hair: rgba(255, 255, 255, .10); --wash: rgba(255, 255, 255, .06);
    --s1: #3987e5; --s2: #d95926; --s4: #c98500; --good: #2fb52f; --bad: #ec7070;
    --chip: #f2f4f1; --chip-ink: #101512; --note: #241f12; --note-edge: #7a6428;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--plane); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
body { min-height: 100vh; min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: .01em; text-transform: uppercase; }
h1 { font-size: 30px; font-weight: 700; line-height: 1; }
h2 { font-size: 21px; font-weight: 700; letter-spacing: .03em; line-height: 1.1; }
h3 { font-size: 17px; font-weight: 600; letter-spacing: .05em; color: var(--ink-2); line-height: 1.2; }
p, ol { margin: 0; }
button, input { font-family: inherit; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }

/* Shell: one column, safe-area aware (viewport-fit=cover) */
.app {
  max-width: 560px; margin: 0 auto; display: grid; gap: 22px; align-content: start;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) calc(env(safe-area-inset-right, 0px) + var(--pad))
           calc(env(safe-area-inset-bottom, 0px) + 28px) calc(env(safe-area-inset-left, 0px) + var(--pad));
}
.screen { display: grid; gap: 22px; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--grid); min-width: 0; }
.mark { width: 40px; height: 40px; flex: none; display: block; }
.top-text { display: grid; gap: 4px; min-width: 0; }
.fresh { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink-2); min-width: 0; }
.fresh span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fresh i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.fresh.off i { background: var(--axis); }
.fresh.bad i { background: var(--bad); }
.meta { color: var(--ink-2); font-size: 14px; margin-top: -8px; }
/* Role line under the connection line, viewers only (CONTRACT P3): a quiet badge, not a warning. */
.role { justify-self: start; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); background: var(--wash); border: 1px solid var(--hair); border-radius: 999px; padding: 0 9px; line-height: 20px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small { font-size: 13px; color: var(--muted); }
.sub { color: var(--ink-2); font-size: 15px; }

/* Buttons */
.ctl { font: 600 15px/1 var(--sans); color: var(--ink); background: var(--wash); border: 0; border-radius: 10px; min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; cursor: pointer; text-decoration: none; touch-action: manipulation; }
.ctl:active { background: var(--hair); }
.ctl.primary { background: var(--chip); color: var(--chip-ink); }
.ctl.primary:active { opacity: .85; background: var(--chip); }
.ctl.big { width: 100%; min-height: 54px; font-size: 17px; border-radius: 12px; }
.ctl:disabled { opacity: .5; cursor: default; }
.ctl[aria-busy="true"] { opacity: .75; cursor: progress; }
.link { font: 600 14px/1.3 var(--sans); color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--axis); text-underline-offset: 4px; text-decoration-thickness: 1px; border: 0; background: none; padding: 0 4px; cursor: pointer; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; touch-action: manipulation; }
.link.danger { color: var(--bad); text-decoration-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.link:disabled { opacity: .5; cursor: default; }

/* Cards and sections */
.card { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: 18px; display: grid; gap: 12px; min-width: 0; }
.section { display: grid; gap: 12px; min-width: 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }

/* Pairing screen */
.steps ol { padding-left: 22px; display: grid; gap: 8px; color: var(--ink-2); }
.steps strong, .pair strong { color: var(--ink); }
.field { display: grid; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.input { font: 500 16px/1.3 var(--sans); color: var(--ink); background: var(--wash); border: 1px solid var(--hair); border-radius: 10px; min-height: 44px; padding: 9px 12px; width: 100%; }
.input::placeholder { color: var(--muted); font-weight: 400; }
.input.code { font: 600 30px/1 var(--display); letter-spacing: .28em; text-align: center; text-transform: uppercase; min-height: 64px; padding: 10px 6px 10px calc(6px + .28em); font-variant-numeric: tabular-nums; }
.input.code::placeholder { letter-spacing: .28em; opacity: .45; }
.field-error { font-size: 14px; font-weight: 500; color: var(--bad); }
.pair form { display: grid; gap: 12px; }

/* Banner (relay unreachable) */
.banner { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--note-edge); background: var(--note); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.banner .dot { margin-top: 6px; --tone: var(--s4); }
.banner.error { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.banner.error .dot { --tone: var(--bad); }

/* Shutdown card */
.shut { background: var(--note); border-color: var(--note-edge); gap: 10px; }
.shut.is-urgent { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.shut-head { display: flex; align-items: center; gap: 10px; }
.shut-head .dot { --tone: var(--s4); }
.shut.is-urgent .shut-head .dot { --tone: var(--bad); }
.shut.is-done { border-color: color-mix(in srgb, var(--good) 45%, transparent); background: color-mix(in srgb, var(--good) 8%, var(--surface)); }
.shut.is-done .shut-head .dot { --tone: var(--good); }
.shut.is-done .result .dot { display: none; }
.clock { font: 700 60px/1 var(--display); letter-spacing: .02em; font-variant-numeric: tabular-nums; color: var(--ink); }
.clock-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.clock-label { font-size: 14px; color: var(--ink-2); }
.shut .ctl.big { margin-top: 4px; }
.result { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; font-weight: 600; }
.result .dot { margin-top: 7px; }
.result-text { flex: 1 1 auto; min-width: 0; }
/* OK keeps the 44 px tap target; the negative margins keep the row as tall as one line of text. */
.result .link { min-height: 44px; min-width: 44px; padding: 0 10px; justify-content: center; margin: -11px -10px -11px 0; }

/* KPI chips, one per channel */
.kpis { display: grid; gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: 12px 14px; display: grid; gap: 8px; }
.kpi .lbl { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink); }
.kpi .cells { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.kpi .cell { display: grid; gap: 1px; min-width: 0; }
.kpi .val { font-size: 22px; font-weight: 600; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi .val.bad { color: var(--bad); }
.kpi .cap { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Queue and activity lists */
.list { padding: 4px 16px; gap: 0; }
.qrow { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--grid); min-width: 0; }
.qrow:last-child, .logrow:last-child { border-bottom: 0; }
.fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.qline > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qline .chan { font-weight: 600; color: var(--ink); flex: none; max-width: 55%; }
.qerr { font-size: 13px; color: var(--bad); overflow-wrap: anywhere; }
.qrow .pill { justify-self: start; }
.empty { padding: 20px 0; text-align: center; color: var(--muted); font-size: 14px; }
/* Fixed time column: the clock, with "Yesterday" / "Sep 29" under it, so every row's text starts at the same x. */
.logrow { display: grid; grid-template-columns: 64px 8px minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.logrow .when { white-space: nowrap; font-variant-numeric: tabular-nums; line-height: 1.3; }
.logrow .when .day { display: block; font-size: 12px; }
.logrow .dot { transform: translateY(-1px); }
.logrow .what { overflow-wrap: anywhere; }
.alrow .what { display: grid; gap: 2px; min-width: 0; }
.alrow .al-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.alrow .al-title { font-weight: 600; }
.alrow .al-tag { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); background: var(--wash); border: 1px solid var(--hair); border-radius: 999px; padding: 0 7px; line-height: 18px; }
.alrow .al-body { color: var(--ink-2); font-size: 13px; }
.alrow .al-note { color: var(--muted); font-size: 12px; }
/* Switched off on this phone (P3): muted text, not opacity, so it still reads (4.5:1 on both themes). */
.alrow.is-off .al-title { font-weight: 500; color: var(--muted); }
.alrow.is-off .al-body { color: var(--muted); }
.alrow.is-off .al-note { font-weight: 600; }

/* Pill, tones, dots, keys (family.css) */
.pill { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 12px; border-radius: 999px; font: 600 13px/1 var(--sans); white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; max-width: 100%; --tone: var(--muted); background: color-mix(in srgb, var(--tone) 14%, transparent); color: var(--ink); }
.pill i { position: relative; width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--tone); }
.pill .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: color-mix(in srgb, var(--tone) 32%, transparent); }
.pill span { position: relative; }
.pill > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.t-work { --tone: var(--s4); }
.t-good { --tone: var(--good); }
.t-bad { --tone: var(--bad); }
.t-wait { --tone: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--muted)); flex: none; display: inline-block; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.k1 { background: var(--s1); }
.k2 { background: var(--s2); }
.k0 { background: var(--muted); }


/* Jump links and "Show all N" under long lists */
.jump { display: flex; flex-wrap: wrap; gap: 0 14px; margin: -14px 0 -10px -4px; }
.more { justify-self: start; margin: -8px 0 -6px -4px; }
#ra-sec, #a-sec, #alerts, #prefs-sec { scroll-margin-top: 12px; }

/* Alerts row */
.alerts { gap: 10px; }
.alerts-text { color: var(--ink-2); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }

/* Alerts on this phone: one full-width switch row per alert (the whole row is the tap target, >= 48 px). */
.prefs-card { gap: 6px; }
.prefs-card .alerts-text { margin-bottom: 4px; }
.pref-list { display: grid; }
.pref { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; min-height: 50px; padding: 8px 0; margin: 0; border: 0; border-bottom: 1px solid var(--grid); background: none; color: var(--ink); font: 500 15px/1.3 var(--sans); text-align: left; cursor: pointer; touch-action: manipulation; }
.pref:last-child { border-bottom: 0; }
.pref-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.switch { position: relative; flex: none; width: 48px; height: 30px; border-radius: 999px; background: var(--axis); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.pref[aria-checked="true"] .switch { background: var(--good); }
.pref[aria-checked="true"] .switch::after { transform: translateX(18px); }
.pref[aria-disabled="true"] { cursor: progress; }
.pref[aria-disabled="true"] .switch { opacity: .55; }
.pref:active .switch { filter: brightness(.92); }
.prefs-card .field-error { margin-top: 4px; }

/* Footer */
.foot { display: flex; justify-content: center; padding-top: 6px; }

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; justify-items: center; width: min(520px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--hair); border-left: 4px solid var(--tone, var(--muted)); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .28); padding: 11px 14px; font-size: 14px; max-width: 100%; overflow-wrap: anywhere; }
.toast .dot { margin-top: 6px; }

@media (max-width: 359px) {
  :root { --pad: 12px; }
  .card { padding: 14px; }
  .list { padding: 2px 12px; }
  .kpi .cells { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 8px; }
  .clock { font-size: 52px; }
  .input.code { font-size: 26px; letter-spacing: .2em; padding-left: calc(6px + .2em); }
}
@media (prefers-reduced-motion: no-preference) {
  .pill .bar { transition: width .4s ease; }
  .switch { transition: background-color .18s ease; }
  .switch::after { transition: transform .18s ease; }
}
