/*
  The rules app's tokens and type levels. Every screen uses only these.

  Type levels, set once (lesson T2): each is at least a quarter larger than the one below.
    --type-1  where I am                 32px
    --type-2  my goal here               25px
    --type-3  the decision               20px
    --type-body  everything read to decide  16px
    --type-caption  labels and captions  12.8px
  Nothing but the page's "where", "says" and "ask" is set at levels 1 to 3.
*/
:root {
  --type-1: 2rem;
  --type-2: 1.5625rem;
  --type-3: 1.25rem;
  --type-body: 1rem;
  --type-caption: 0.8rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f5f3ee;
  --surface: #ffffff;
  --fg: #1c1b19;
  --fg-muted: #57534b;
  --line: #d8d3c7;
  --line-strong: #8f897c;
  --accent: #1d4e89;
  --accent-strong: #163d6c;
  --accent-fg: #ffffff;
  --accent-tint: #e4edf7;
  --good-fg: #1c5631;
  --good-bg: #e1f1e4;
  --caution-fg: #70440a;
  --caution-bg: #fbeccd;
  --bad-fg: #8a1c1c;
  --bad-bg: #fbe3e0;
  --neutral-fg: #45423c;
  --neutral-bg: #eae7df;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --radius: 6px;
  --rail-width: 380px;
  --chrome-height: 56px;
}

* { box-sizing: border-box; }
html { font-size: 100%; }
body { margin: 0; font: var(--type-body)/1.5 var(--font); color: var(--fg); background: var(--bg); }
a { color: var(--accent); }
h1, h2, p, ul, ol, dl, dd, blockquote { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- the frame: the app's own chrome ---------- */

.chrome { position: sticky; top: 0; z-index: 2; height: var(--chrome-height); display: flex; align-items: center; gap: var(--space-5); padding: 0 var(--space-5); background: var(--surface); box-shadow: 0 1px 0 var(--line); }
.brand { font-weight: 600; color: var(--fg); text-decoration: none; padding: var(--space-2) 0; }
.nav { display: flex; gap: var(--space-1); }
.nav a { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 36px; padding: 0 var(--space-3); border-radius: var(--radius); color: var(--fg); text-decoration: none; }
.nav a:hover { background: var(--neutral-bg); }
.nav a[aria-current="page"] { background: var(--accent-tint); color: var(--accent); }
.nav-count { font-size: var(--type-caption); line-height: 1.5; padding: 0 var(--space-2); border-radius: 999px; background: var(--caution-bg); color: var(--caution-fg); }
.chrome-end { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.who { font-size: var(--type-caption); color: var(--fg-muted); }

.frame { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-width); align-items: start; }
main { padding: var(--space-6) var(--space-7) var(--space-7); max-width: 980px; min-width: 0; }

/* ---------- the glance order (L27) ---------- */

.back { margin-bottom: var(--space-2); }
.back a { display: inline-block; padding: var(--space-1) 0; }
.back a::before { content: "\2190\00a0"; }
.where { font-size: var(--type-1); line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
.says { font-size: var(--type-2); line-height: 1.3; font-weight: 400; margin-top: var(--space-3); max-width: 34em; }
.says.struck { color: var(--fg-muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.decision { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: var(--space-5) 0 var(--space-6); max-width: 46em; }
.ask { font-size: var(--type-3); line-height: 1.35; font-weight: 600; flex: 0 0 100%; }
.decision.stack { flex-direction: column; align-items: stretch; }
.choice .ask { flex-basis: 100%; }
.consequence { flex: 0 0 100%; }
.choice { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- controls ---------- */

.button { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--fg); font-weight: 600; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--neutral-bg); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.button.primary:hover { background: var(--accent-strong); }
.button.quiet { border-color: transparent; background: transparent; color: var(--accent); }
.button.quiet:hover { background: var(--accent-tint); }
.button.small { min-height: 32px; padding: 0 var(--space-3); }
form.inline { display: inline-flex; align-items: center; gap: var(--space-2); }

.chrome .chip { font-size: var(--type-caption); min-height: 28px; padding: 0 var(--space-3); }
.chip, .verdict { display: inline-flex; align-items: center; line-height: 1.4; padding: 0 var(--space-2); border-radius: 999px; background: var(--neutral-bg); color: var(--neutral-fg); white-space: nowrap; text-decoration: none; }
.chip.good, .verdict.good { background: var(--good-bg); color: var(--good-fg); }
.chip.caution, .verdict.caution { background: var(--caution-bg); color: var(--caution-fg); }
.chip.bad, .verdict.bad { background: var(--bad-bg); color: var(--bad-fg); }
.verdict a { color: inherit; }

/* ---------- lists: tight inside a group, wide between groups (L11) ---------- */

.jump { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); margin: calc(-1 * var(--space-3)) 0 var(--space-6); }
.jump a { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 32px; padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--fg); text-decoration: none; }
.jump a:hover { background: var(--accent-tint); }
.jump-count { color: var(--fg-muted); }
.group { scroll-margin-top: calc(var(--chrome-height) + var(--space-4)); }

.group { margin-bottom: var(--space-6); }
.group-name, .block-name { font-size: var(--type-caption); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); margin-bottom: var(--space-2); }
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.rows > li + li { border-top: 1px solid var(--line); }
.row, .lesson-row, .access-row { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: var(--space-2) var(--space-4); }
.row { color: var(--fg); text-decoration: none; }
.row:hover, .row-open:hover .row-main { background: var(--accent-tint); }
.rows > li:first-child .row { border-radius: var(--radius) var(--radius) 0 0; }
.rows > li:last-child .row { border-radius: 0 0 var(--radius) var(--radius); }
.row-id { flex: 0 0 2.75rem; font-family: var(--font-mono); color: var(--fg-muted); }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-open { display: flex; align-items: center; gap: var(--space-3); flex: 1 1 auto; min-width: 0; min-height: 28px; color: var(--fg); text-decoration: none; }
.lesson-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; padding: var(--space-1) 0; }
.row-rank { display: inline-flex; align-items: center; gap: var(--space-3); padding-left: calc(2.75rem + var(--space-3)); }
.row-open { align-items: baseline; }
.row-action { flex: 0 0 auto; display: flex; justify-content: flex-end; }
.lesson-row.one-line .meter { flex: 0 0 auto; }
.quiet-lessons { margin-top: var(--space-6); }
.after-list { margin-top: calc(-1 * var(--space-3)); }
.access-row.done .row-main { color: var(--fg-muted); }
.access-row .fact { flex: 0 0 auto; }

.meter { display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.pips { display: inline-flex; gap: 3px; }
.pip { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); }
.pip.on { background: var(--good-fg); border-color: var(--good-fg); }
.meter-words { color: var(--fg-muted); }

/* ---------- the information for the decision: the quietest level, at body size ---------- */

.fact, .caption, .field-help { color: var(--fg-muted); }
.caption, .field-help { font-size: var(--type-caption); }
.facts { display: grid; gap: var(--space-4); margin-bottom: var(--space-6); max-width: 46em; }
.fact-row { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: var(--space-4); }
.fact-row dt { color: var(--fg-muted); }
.fact-row dd .fact { display: block; }
.block { margin-bottom: var(--space-6); }
.block > .fact { margin-bottom: var(--space-3); }
.secondary-actions { display: flex; gap: var(--space-2); margin-bottom: var(--space-6); }

.verdicts { border-collapse: collapse; width: 100%; max-width: 46em; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.verdicts th, .verdicts td { text-align: left; vertical-align: top; padding: var(--space-2) var(--space-4); font-weight: 400; }
.verdicts tr + tr th, .verdicts tr + tr td { border-top: 1px solid var(--line); }
.verdicts th { width: 15rem; }
.verdicts td:nth-child(2) { width: 7rem; }
.verdict-detail { color: var(--fg-muted); }

.applications { display: grid; gap: var(--space-2); max-width: 46em; }
.applications li { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: var(--space-3); align-items: start; }
.applications .verdict { justify-self: start; }

.changes { display: grid; gap: var(--space-3); max-width: 46em; }
.change-what { font-weight: 600; }
.change-note { color: var(--fg-muted); }
.change-diff summary { cursor: pointer; color: var(--accent); min-height: 24px; }
.diff { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: var(--space-1) var(--space-3); margin: var(--space-2) 0; padding: var(--space-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.diff dt { font-size: var(--type-caption); color: var(--fg-muted); padding-top: 3px; }

/* ---------- the inbox ---------- */

.findings { display: grid; gap: var(--space-3); margin-bottom: var(--space-6); }
.finding { display: flex; gap: var(--space-5); align-items: flex-start; padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.finding-main { flex: 1 1 auto; min-width: 0; display: grid; gap: var(--space-2); }
.finding-where { color: var(--fg-muted); }
.finding-actions { flex: 0 0 auto; display: flex; flex-direction: column; align-items: stretch; gap: var(--space-2); }
.findings.decided .finding { background: transparent; }
.findings.decided .finding-actions { align-items: flex-end; }
.finding-evidence summary { cursor: pointer; color: var(--accent); min-height: 24px; }
.quoted { margin: var(--space-5) 0; padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-width: 46em; display: grid; gap: var(--space-2); }

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

.form { display: grid; gap: var(--space-4); max-width: 46em; margin-top: var(--space-5); }
.field { display: grid; gap: var(--space-1); }
.field-name { color: var(--fg-muted); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
input, select, textarea { width: 100%; min-height: 40px; padding: var(--space-2) var(--space-3); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); }
textarea { resize: vertical; line-height: 1.5; }
.form-end { display: flex; gap: var(--space-3); position: sticky; bottom: 0; padding: var(--space-3) 0; background: var(--bg); }
.add-row { display: grid; grid-template-columns: minmax(0, 1fr) 12rem auto; gap: var(--space-3); align-items: end; margin-top: var(--space-3); max-width: 46em; }
.access-row select { width: auto; min-height: 32px; padding: 0 var(--space-2); }

.problem { margin: var(--space-4) 0; padding: var(--space-3) var(--space-4); background: var(--bad-bg); color: var(--bad-fg); border: 1px solid var(--bad-fg); border-radius: var(--radius); max-width: 46em; }
.once { margin: var(--space-5) 0; padding: var(--space-4); background: var(--accent-tint); border: 1px solid var(--accent); border-radius: var(--radius); display: grid; gap: var(--space-3); max-width: 46em; }
.key { font-family: var(--font-mono); padding: var(--space-2) var(--space-3); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); overflow-wrap: anywhere; }

/* ---------- usage: figures that add up, and the trend ---------- */

.figures { border-collapse: collapse; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.figures th, .figures td { text-align: left; vertical-align: top; padding: var(--space-2) var(--space-4); font-weight: 400; }
.figures thead th { color: var(--fg-muted); }
.figures tbody tr + tr th, .figures tbody tr + tr td, .figures tbody tr:first-child th, .figures tbody tr:first-child td, .figures tfoot th, .figures tfoot td { border-top: 1px solid var(--line); }
.figures tfoot th, .figures tfoot td { background: var(--neutral-bg); }
.figures .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.figures td a { display: inline-block; min-height: 24px; line-height: 24px; }
.figure summary { cursor: pointer; min-height: 24px; }
.figure .working, .working { color: var(--fg-muted); text-align: left; white-space: normal; max-width: 34em; margin: var(--space-1) 0 var(--space-2) auto; }
.figure { position: relative; }
.figure[open] .working { position: absolute; right: 0; top: 100%; z-index: 1; width: 26em; max-width: 60vw; margin: var(--space-1) 0 0; padding: var(--space-3); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.cap-cell { display: flex; align-items: center; gap: var(--space-3); }
.cap-cell .figure[open] .working { left: 0; right: auto; }
.cap-bar { flex: 0 0 auto; vertical-align: middle; }
.cap-track { fill: var(--neutral-bg); }
.cap-used { fill: var(--accent); }
.cap-used.near { fill: var(--caution-fg); }
.figures.days { margin-top: var(--space-3); max-width: 30em; }
.trend-wrap { overflow-x: auto; padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.trend { display: block; }
.trend .bar { fill: var(--accent); }
.trend .bar.today { fill: var(--accent-strong); }
.trend-label { font: var(--type-caption) var(--font); fill: var(--fg-muted); }
.trend-line, .trend-base { stroke: var(--line); stroke-width: 1; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-mono); }
.plain { list-style: disc; padding-left: 1.2em; display: grid; gap: var(--space-1); }

/* ---------- access: keys ---------- */

/* A key's row: name, kind, dates and Revoke on one line, with Revoke always at the right. When they do not fit, the dates wrap inside their own column. */
.key-row { display: grid; grid-template-columns: minmax(max-content, 1fr) auto minmax(12em, auto) auto; align-items: center; }
.key-row .fact { text-align: right; }
/* The full-width lines take the row's width and add nothing to the columns' own widths. */
.key-row .key-spend, .key-row .key-controls { grid-column: 1 / -1; width: 0; min-width: 100%; }
.key-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
input.cap { width: 6rem; min-height: 32px; padding: 0 var(--space-2); }
.key-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 11rem; gap: var(--space-3) var(--space-3); align-items: start; margin-top: var(--space-4); max-width: 52em; }
.key-form .check, .key-form .button { grid-column: 1 / -1; justify-self: start; }
.check { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 32px; }
input[type="checkbox"] { width: 24px; height: 24px; min-height: 24px; padding: 0; accent-color: var(--accent); }

/* ---------- DESIGNNERD's rail ---------- */

#designnerd { position: sticky; top: var(--chrome-height); height: calc(100vh - var(--chrome-height)); display: flex; flex-direction: column; background: var(--surface); box-shadow: -1px 0 0 var(--line); }
.rail-head { padding: var(--space-4) var(--space-4) var(--space-3); }
.rail-name { font-size: var(--type-body); font-weight: 700; letter-spacing: 0.04em; }
.rail-role, .rail-note { color: var(--fg-muted); }
.rail-note { padding: 0 var(--space-4); }
.rail-log { flex: 1 1 auto; overflow-y: auto; padding: var(--space-2) var(--space-4) var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.rail-form { padding: var(--space-3) var(--space-4) var(--space-4); display: grid; gap: var(--space-2); box-shadow: 0 -1px 0 var(--line); }
.rail-form-end { display: flex; justify-content: space-between; align-items: center; }
.say { white-space: pre-wrap; overflow-wrap: anywhere; }
.say.you { align-self: flex-end; max-width: 90%; padding: var(--space-2) var(--space-3); background: var(--accent-tint); border-radius: var(--radius); }
.say.working { color: var(--fg-muted); font-size: var(--type-caption); }
.say.trouble { padding: var(--space-2) var(--space-3); background: var(--bad-bg); color: var(--bad-fg); border: 1px solid var(--bad-fg); border-radius: var(--radius); }
.card { padding: var(--space-3); border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface); display: grid; gap: var(--space-2); }
.card.done { border-color: var(--good-fg); background: var(--good-bg); }
.card.declined { border-color: var(--line); color: var(--fg-muted); }
.card-title { font-weight: 600; }
.card-change { display: grid; gap: 2px; }
.card-label { color: var(--fg-muted); }
.card-before { color: var(--fg-muted); text-decoration: line-through; text-decoration-thickness: 1px; overflow-wrap: anywhere; }
.card-after { overflow-wrap: anywhere; }
.card-actions { display: flex; gap: var(--space-2); }

/* ---------- sign-in and other pages outside the frame ---------- */

.bare-main { max-width: 34rem; margin: 0 auto; padding: 18vh var(--space-5) var(--space-7); }
.bare-main .decision { margin-bottom: var(--space-4); }

@media (max-width: 1100px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  #designnerd { position: static; height: auto; min-height: 20rem; box-shadow: 0 -1px 0 var(--line); }
  main { padding: var(--space-5); }
  .chrome { flex-wrap: wrap; height: auto; padding: var(--space-2) var(--space-4); gap: var(--space-2); }
}

/* ---------- the satisfaction check ---------- */

/* The pages an outside person opens from a face on the card. */
.answer-says { margin-top: 0; }
.answer-faces { list-style: none; display: flex; align-items: flex-end; gap: var(--space-4); margin: var(--space-4) 0; }
.answer-face { display: grid; justify-items: center; gap: var(--space-1); line-height: 0; }
.answer-face a { display: inline-block; min-width: 44px; min-height: 44px; border-radius: var(--radius); }
/* The chosen face is larger, boxed and named: told by shape and words, not by color alone. */
.answer-face.chosen { padding: var(--space-2) var(--space-3); background: var(--surface); border: 2px solid var(--fg); border-radius: var(--radius); }
.answer-mark { line-height: 1.4; }
.say-more { display: grid; gap: var(--space-3); justify-items: start; margin: var(--space-5) 0; }
.say-more .field { width: 100%; }
.bare-main > p { margin-top: var(--space-3); max-width: 34em; }

/* What people answered, on Usage. */
.mood-says .figure { display: inline-block; }
.mood-says .figure[open] .working { left: 0; right: auto; font-size: var(--type-1, 1rem); }
.mood-line { margin: var(--space-3) 0 var(--space-5); max-width: 46em; }
.decision + .fact { margin-bottom: var(--space-5); }
.asked-bar { display: block; max-width: 100%; margin: var(--space-3) 0; }
.asked-whole { fill: var(--surface); stroke: var(--line-strong); }
.asked-part { stroke: var(--surface); stroke-width: 1; }
.asked-part.score-1 { fill: var(--accent-strong); }
.asked-part.score-2 { fill: var(--accent); }
.asked-part.score-3 { fill: var(--accent); fill-opacity: 0.72; }
.asked-part.score-4 { fill: var(--accent); fill-opacity: 0.48; }
.asked-part.score-5 { fill: var(--accent); fill-opacity: 0.26; }
.asked-part.none { fill: none; stroke: var(--fg-muted); }
.mood-none { display: block; width: 44px; height: 44px; border: 2px dashed var(--fg-muted); border-radius: 50%; }
.finding-score { display: flex; align-items: center; gap: var(--space-3); }
.said-from .figure { display: inline-block; }
.said-from .figure[open] .working { left: 0; right: auto; }
.figures.mood-keys { max-width: 46em; margin-bottom: var(--space-4); }
.mood-keys .figure[open] .working { left: 0; right: auto; }
.mood-faces { list-style: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-3); max-width: 46em; margin: var(--space-4) 0; padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.mood-face { display: grid; justify-items: center; gap: var(--space-1); text-align: center; }
.mood-name { font-size: var(--type-caption); color: var(--fg-muted); }
.mood-count { font-size: var(--type-3); font-variant-numeric: tabular-nums; }
.mood-trend { display: block; }
.mood-day { fill: var(--accent); stroke: var(--accent-strong); stroke-width: 1; }
.said { list-style: none; display: grid; gap: var(--space-3); max-width: 52em; }
.said-item { display: flex; gap: var(--space-4); align-items: flex-start; padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.said-face { flex: 0 0 auto; line-height: 0; }
.said-main { display: grid; gap: var(--space-2); min-width: 0; }
.said-words { overflow-wrap: anywhere; white-space: pre-wrap; }

/* How often people are asked, on Access. */
.asking-form { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); margin-top: var(--space-4); max-width: 34em; }
.asking-form .field { flex: 1 1 16rem; }
.asking-form + .button { margin-top: var(--space-2); }
