/* =====================================================================
   AgentOS Web: the base sheet. The reset, buttons, fields, the card, and
   the sign-in components (password, code box, setup square, recovery
   codes, the locked wall). Loaded by every page after tokens.css; the
   app adds style.css on top. Every value is a token from tokens.css.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs-md); line-height: var(--lh);
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-md); }
h3 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
p { margin: 0 0 var(--s-3); }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted { color: var(--ink-3); }
.small { font-size: var(--fs-xs); }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }
.status-line { font-size: var(--fs-sm); color: var(--ink-2); min-height: 1.2em; }

/* focus: always visible, same everywhere */
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 700; letter-spacing: -0.01em; }
.brand-lg { font-size: var(--fs-lg); margin-bottom: var(--s-4); }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), var(--accent-hover)); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 5px; border-radius: 2px; background: var(--accent-ink); opacity: .9; }

/* ---------- buttons, fields ---------- */
.btn {
  font: inherit; font-size: var(--fs-sm); font-weight: 550; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3); cursor: pointer; min-height: 36px; line-height: 1.2;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-1); text-decoration: none;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-link { border: 0; background: none; color: var(--ink-3); text-decoration: underline; font-weight: 400; }
.btn-danger-ghost { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { min-height: 30px; padding: var(--s-1) var(--s-2); font-size: var(--fs-xs); }
.btn-block { width: 100%; }
.btn-icon { padding: var(--s-1); width: 36px; }
.btn-icon.btn-sm { width: 30px; }

.field { display: flex; flex-direction: column; gap: var(--s-1); font-size: var(--fs-sm); color: var(--ink-2); }
.field > span { font-weight: 550; }
input, select, textarea {
  font: inherit; font-size: var(--fs-md); color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); min-height: 38px; width: 100%;
}
select { padding-right: var(--s-4); }
textarea { resize: vertical; }
.form-error { color: var(--danger); font-size: var(--fs-sm); min-height: 1.2em; margin-top: var(--s-2); }
/* Plain-language notice on the login card (e.g. "You were signed out") - information, not an error. */
.login-note { background: var(--warn-soft); color: var(--ink); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); margin-bottom: var(--s-3); }

/* ---------- screens (sign in, set up, connect) ---------- */
.screen-center { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-4); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-6); box-shadow: var(--shadow); width: 100%; }
.card-login { max-width: 380px; display: flex; flex-direction: column; gap: var(--s-3); }
.card-login h1 { margin-bottom: 0; }
.steps { margin: 0 0 var(--s-3); padding-left: 1.3em; }
.steps li { margin-bottom: var(--s-1); }
.details summary { cursor: pointer; font-size: var(--fs-sm); color: var(--ink-2); }

/* ---------- signing in, step two: codes, the setup square, recovery codes ---------- */
.card-enroll { max-width: 620px; display: flex; flex-direction: column; gap: var(--s-3); }
.row-split { justify-content: space-between; gap: var(--s-2); }
/* the card's own gap only reaches its direct children, and the whole code form is one of them */
#mfa-live { display: flex; flex-direction: column; gap: var(--s-3); }

/* One box for both kinds of code. Six digits sit far apart so they are easy to check against the phone;
   a recovery code is words and dashes, so that spacing comes off (.code-input-wide). */
.code-input { font-family: var(--font-mono); font-size: var(--fs-xl); letter-spacing: 0.35em; text-align: center; padding: var(--s-3); font-variant-numeric: tabular-nums; }
.code-input-wide { font-size: var(--fs-lg); letter-spacing: 0.06em; }

.qr-row { display: flex; gap: var(--s-4); align-items: flex-start; flex-wrap: wrap; }
/* The square is always black on white, in both themes: that is what a scanner expects, and an inverted or
   tinted code is the classic reason a phone will not read one. The white plate is the quiet zone. */
.qr { background: #fff; padding: var(--s-2); border-radius: var(--r-md); border: 1px solid var(--border); flex: 0 0 auto; line-height: 0; }
.qr svg { width: 200px; height: 200px; display: block; }
.qr-side { flex: 1 1 240px; min-width: 220px; display: flex; flex-direction: column; gap: var(--s-2); }
.qr-side .steps { margin: 0; }
.secret { font-family: var(--font-mono); font-size: var(--fs-lg); line-height: 1.6; word-spacing: 0.2em; word-break: break-word; background: var(--surface-2); border-radius: var(--r-sm); padding: var(--s-2) var(--s-3); user-select: all; margin: var(--s-2) 0 0; }

.recovery { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); background: var(--surface-2); display: flex; flex-direction: column; gap: var(--s-2); }
.recovery h2 { font-size: var(--fs-lg); margin: 0; }
.recovery p { margin: 0; font-size: var(--fs-sm); }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-1) var(--s-3); margin: var(--s-2) 0; padding-left: 1.6em; }
.code-item { font-family: var(--font-mono); font-size: var(--fs-md); user-select: all; }
.check { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; min-height: 44px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Locked out: this is a wall, not an error line, so it replaces the form instead of sitting under it. */
.locked { background: var(--danger-soft); border: 1px solid var(--danger); border-radius: var(--r-md); padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); }
.locked-title { font-weight: 700; margin: 0; }
.locked p { margin: 0; font-size: var(--fs-sm); }

@media (max-width: 560px) {
  .qr-row { flex-direction: column; }
  .qr-side { order: 1; }
  .qr { order: 2; align-self: center; }
  .qr svg { width: 180px; height: 180px; }
  .codes { grid-template-columns: 1fr; }
  .code-input { font-size: var(--fs-lg); letter-spacing: 0.25em; }
  .card { padding: var(--s-4); }
}

/* Printing the recovery codes: everything else comes off the paper. */
@media print {
  html.printing-codes body > *:not(#enroll) { display: none !important; }
  html.printing-codes #enroll .brand, html.printing-codes #enroll .steps, html.printing-codes #enroll .qr-row,
  html.printing-codes #enroll form, html.printing-codes #enroll .row, html.printing-codes #enroll .check,
  html.printing-codes #enroll > .card > p, html.printing-codes #enroll .status-line { display: none !important; }
  html.printing-codes .card { border: 0; box-shadow: none; }
  html.printing-codes .recovery { background: none; }
  html.printing-codes .codes { color: #000; }
}
