:root {
  --bg: #fbfaf9;
  --surface: #ffffff;
  --text: #1f1d1b;
  --muted: #6b6560;
  --line: #e4e0db;
  --accent: #b5551f;
  --pending: #f3efe9;
  --waiting-bg: #fdf4e3;
  --waiting-line: #e0b062;
  --code-bg: #f4f1ed;
  --danger: #a32b28;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1a1816;
    --surface: #232019;
    --text: #efe9e2;
    --muted: #a09890;
    --line: #38332c;
    --accent: #e08a52;
    --pending: #2a251f;
    --waiting-bg: #33291a;
    --waiting-line: #8a6a32;
    --code-bg: #2a251f;
    --danger: #f0928c;
  }
}

:root[data-theme='dark'] {
  --bg: #1a1816;
  --surface: #232019;
  --text: #efe9e2;
  --muted: #a09890;
  --line: #38332c;
  --accent: #e08a52;
  --pending: #2a251f;
  --waiting-bg: #33291a;
  --waiting-line: #8a6a32;
  --code-bg: #2a251f;
  --danger: #f0928c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
}

header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.bar {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.bar h1, .bar .doc-name { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.bar .spacer { flex: 1; }
.bar .back { text-decoration: none; }

.chip-status {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

.chip-status.live { color: var(--accent); border-color: var(--accent); }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 16px 96px;
}

a { color: var(--accent); }

h1.doc-title { font-size: 30px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 4px; }
h2 { font-size: 21px; margin: 32px 0 8px; letter-spacing: -0.01em; }
h3 { font-size: 17px; margin: 24px 0 6px; }
p { margin: 0 0 14px; }

ul, ol { margin: 0 0 14px; padding-left: 22px; }
li { margin: 3px 0; }

blockquote {
  margin: 0 0 14px;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

code {
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

pre {
  background: var(--code-bg);
  padding: 14px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}

pre code { background: none; padding: 0; }

/*
 * The scroll lives on the wrapper, not the table. `table { display: block }`
 * makes a wide table scroll, but it also drops the element's implicit table
 * role in several screen readers, and with it every row and column
 * relationship the table exists to express. TASK-034.
 */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: 0 0 16px;
}

.table-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 14.5px;
}

th, td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}

th { background: var(--pending); font-weight: 600; }

hr { border: none; border-top: 1px solid var(--line); margin: 28px 0; }

.chip {
  display: inline-block;
  border-radius: 5px;
  padding: 0 6px;
  font-size: 0.9em;
  background: var(--pending);
  border: 1px solid var(--line);
}

.chip.mention { color: var(--accent); }

/* The pending block: the highest-value piece of UI in the system (10.2). */
.pending {
  border: 1px dashed var(--line);
  background: var(--pending);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14.5px;
  position: relative;
  overflow: hidden;
}

.pending::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: translateX(-100%);
  animation: shimmer 2.2s infinite;
}

@media (prefers-color-scheme: dark) {
  .pending::after {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  }
}

@keyframes shimmer {
  100% { transform: translateX(100%); }
}

.pending .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
  opacity: 0.7;
}

/* A pending block blocked on a question reads differently (10.2). */
.pending.waiting {
  background: var(--waiting-bg);
  border: 1px solid var(--waiting-line);
  border-left-width: 3px;
  color: var(--text);
}

.pending.waiting::after { animation: none; }

.options { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

button.option {
  font: inherit;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--waiting-line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button.option:hover { background: var(--waiting-line); color: #fff; }

.doclist { list-style: none; padding: 0; }

.doclist li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--surface);
}

.doclist a { text-decoration: none; font-weight: 600; }
.doclist .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

.empty { color: var(--muted); }

/* A failure that belongs to one block, shown where the action was. TASK-034. */
.block-error {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--accent);
}

.flash { animation: flash 1.2s ease-out; }

@keyframes flash {
  from { background: rgba(181, 85, 31, 0.14); }
  to { background: transparent; }
}

/*
 * Both of the viewer's animations are decorative: the shimmer says "being
 * written", the flash says "this just changed". Neither is worth triggering
 * vestibular symptoms, and both have a static equivalent. TASK-034.
 */
@media (prefers-reduced-motion: reduce) {
  .pending::after { display: none; }
  .pending { border-style: solid; }
  .flash { animation: none; }
}

@media (max-width: 600px) {
  main { padding: 20px 16px 72px; }
  h1.doc-title { font-size: 24px; }
}

.unsafe-link { color: var(--muted); text-decoration: line-through; }

/* ------------------------------------------------------------ sign-in page
 *
 * One centred card, built entirely from the tokens above so it follows the
 * viewer into dark mode instead of pinning a second palette of its own. The
 * AppMecca screenshot this matches is dark, but "dark" there is the product's
 * only theme; ours has two, and a login screen that ignores the light one
 * would be the single page in the app that flashes black. TASK-025.
 */

/*
 * A class that sets `display` outranks the user-agent's `[hidden]` rule, and
 * both .btn and .auth-or do. Without this, hiding the Google button when the
 * deployment has no Google credentials would silently fail to hide it.
 */
[hidden] { display: none !important; }

.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
}

main.auth {
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

/* ------------------------------------------------------------------ brand */

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 6px;
}

.auth-mark {
  width: 26px;
  height: 26px;
  color: var(--accent);
  flex: none;
}

.auth-wordmark {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.auth-tagline {
  margin: 0 0 30px;
  color: var(--muted);
  font-size: 14px;
}

.auth-title {
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.auth-subtitle {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14.5px;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 550;
  line-height: 1.2;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.btn-block { width: 100%; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  /* Not var(--surface): the accent is a mid-tone in both themes, and the light
   * surface is the only value that holds contrast against it in either. */
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, #000); }

/*
 * The provider button keeps a neutral surface on purpose. Google's brand rules
 * do not allow their mark to be dropped onto an arbitrary brand colour, and an
 * orange "Continue with Google" would look like a phishing page besides.
 */
.btn-provider {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.btn-provider:hover:not(:disabled) { border-color: var(--muted); }

.provider-mark { width: 18px; height: 18px; flex: none; }

.btn:disabled { opacity: 0.55; cursor: default; }

.linkish {
  font: inherit;
  font-size: 13.5px;
  padding: 4px 2px;
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.linkish:hover:not(:disabled) { color: var(--text); }
.linkish:disabled { cursor: default; text-decoration: none; }

/* ---------------------------------------------------------------- divider */

.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.1em;
}

.auth-or::before,
.auth-or::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------------ form */

.auth-form { text-align: left; }

.auth-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Red, and also a literal asterisk -- colour alone is not a message. */
.req { color: var(--danger); }

.auth-input {
  font: inherit;
  font-size: 15px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.auth-input::placeholder { color: var(--muted); opacity: 0.7; }

.auth-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 22px;
  letter-spacing: 0.32em;
  text-align: center;
  /* letter-spacing leaves a trailing gap after the sixth digit, which drags the
   * centred run visually left. Trimming the same amount off the right padding
   * shifts the content box back, without a negative indent that can clip. */
  padding-right: calc(12px + 0.32em);
}

.auth-help {
  margin: 8px 0 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.auth-sent {
  margin: 0 0 18px;
  font-size: 14.5px;
  line-height: 1.5;
  /* An address is the one string here worth wrapping mid-token rather than
   * letting it push the card sideways on a narrow phone. */
  overflow-wrap: anywhere;
}

.auth-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

/* ---------------------------------------------------------------- messages
 *
 * Both live regions stay rendered and in the accessibility tree even while
 * empty -- an empty block box is zero-height, so this costs no layout and
 * keeps announcements working. Hiding them would not.
 */
.auth-msg {
  margin: 16px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  text-align: left;
}

.auth-msg:empty { margin: 0; }
.auth-ok { color: var(--muted); }
.auth-err { color: var(--danger); font-weight: 500; }

/* ----------------------------------------------------------------- focus */

.auth-input:focus-visible,
.btn:focus-visible,
.linkish:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.auth-input:focus-visible { border-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

@media (max-width: 420px) {
  main.auth { padding: 28px 16px; align-items: flex-start; }
  .auth-title { font-size: 23px; }
  .auth-code { font-size: 19px; letter-spacing: 0.24em; padding-right: calc(12px + 0.24em); }
  .auth-actions { flex-wrap: wrap; }
}
