/* Mobile first, single column, 44px tap targets (§10). No framework: the whole
   sheet is smaller than one, and CSP forbids fetching one anyway. */

:root {
  --ink: #1c1b1a;
  --muted: #63605c;
  --line: #dedbd6;
  --paper: #ffffff;
  --wash: #f6f4f1;
  --accent: #ff6d00;      /* the letterhead's orange */
  --slate: #444142;       /* the letterhead's charcoal */
  --bad: #a3211a;
  --tap: 44px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font: 16px/1.6 "Cairo", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--paper);
  border-block-end: 3px solid var(--accent);
}
.brand { font-weight: 700; text-decoration: none; color: var(--slate); }
.bar nav { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: center; }

/* Everything in the bar is a tap target, so all of it clears 44px — this is
   the row a phone user touches most. */
.bar a, .linklike {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.4rem;
  color: var(--muted);
  text-decoration: none;
}
.bar .brand { padding-inline-start: 0; }
.bar nav a:hover, .bar nav a:focus, .linklike:hover, .linklike:focus {
  color: var(--ink);
  text-decoration: underline;
}
.signout { margin: 0; display: flex; }
.lang {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 0.75rem;
  font-size: 0.9rem;
}
.linklike { font: inherit; background: none; border: 0; cursor: pointer; }

main { max-width: 40rem; margin: 0 auto; padding: 1rem 1rem 4rem; }

/* A link on its own line is a tap target too, not a word in a sentence. */
main > p > a:only-child {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}
h1 { font-size: 1.4rem; margin: 1rem 0; }
h2 { font-size: 1.1rem; margin: 2rem 0 0.5rem; }
.hint, .empty { color: var(--muted); }

/* ---- form ---- */
.field { margin-block-end: 1.25rem; }
label { display: block; margin-block-end: 0.35rem; font-weight: 600; }
input {
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
}
select {
  width: 100%;
  min-height: var(--tap);
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

/* Present to a screen reader, absent to the eye — the per-user password box
   already says what it is through its placeholder. */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.field--bad input { border-color: var(--bad); }
.field-error { margin: 0.35rem 0 0; color: var(--bad); font-size: 0.9rem; }
.errors { color: var(--bad); font-weight: 600; }

/* Latin-only values read left-to-right even inside an RTL page. */
input[inputmode="numeric"], input[inputmode="decimal"] { direction: ltr; text-align: start; }

/* ---- buttons ---- */
button, .primary, .secondary {
  display: inline-block;
  min-height: var(--tap);
  padding: 0.6rem 1.25rem;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.primary { background: var(--accent); color: #fff; }
.secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0; }
.actions form { margin: 0; }

/* ---- values, list, history ---- */
.values { display: grid; grid-template-columns: 1fr; gap: 0 1rem; margin: 1rem 0; }
.values dt { color: var(--muted); font-size: 0.9rem; }
.values dd { margin: 0 0 0.9rem; font-weight: 600; overflow-wrap: anywhere; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.cards a {
  display: grid;
  gap: 0.25rem;
  padding: 1rem;
  min-height: var(--tap);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
.card-id { font-weight: 700; direction: ltr; }
.card-meta { color: var(--muted); font-size: 0.9rem; display: flex; gap: 0.5rem; align-items: center; }

.pill {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  background: var(--wash);
  border: 1px solid var(--line);
}
.pill--generated { background: #eef3fb; }
.pill--sent      { background: #fff3e3; }
.pill--signed    { background: #e9f6ec; }
.pill--cancelled { background: #f7eceb; color: var(--bad); }

/* ---- search ---- */
.search { margin: 1rem 0 1.5rem; display: grid; gap: 0.75rem; }
.search input[type="search"] { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { margin: 0; font-weight: 400; }
/* The radio itself is off-screen rather than display:none, so it stays
   focusable and reachable by keyboard and screen reader. */
.chip input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
}
.chip span {
  display: inline-block;
  min-height: 2.25rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  cursor: pointer;
}
.chip input:checked + span { background: var(--slate); color: #fff; border-color: var(--slate); }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }

.count { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.75rem; }
.pager { display: flex; gap: 0.75rem; align-items: center; margin: 1.5rem 0; }

/* ---- users ---- */
.cards li.user {
  padding: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0.25rem;
}
.user-head { display: grid; gap: 0.25rem; }
.user .actions { margin: 0.75rem 0 0; }
.inline { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.inline input { width: auto; flex: 1 1 10rem; }

/* ---- status ---- */
.status-form { margin: 1rem 0 2rem; }
.status-form .actions { margin-block-start: 0.75rem; }
.history-note {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.9rem;
  padding-inline-start: 0.25rem;
}
.history-who { font-weight: 600; }

.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.history li { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.history time { color: var(--muted); font-size: 0.9rem; direction: ltr; }

/* ---- the generate indicator ---- */
.generating { display: none; color: var(--muted); }
.htmx-request .generating, .htmx-request.generating { display: block; }

@media (min-width: 34rem) {
  .values { grid-template-columns: 12rem 1fr; }
  .values dd { margin-block-end: 0.5rem; }
}
