/*
  HonestRead "Quiet confidence" design tokens.
  The same 14 roles exist in light and dark. Components only ever use these
  variables, never raw hex values, so every screen supports both modes.
  All text pairings meet WCAG 2.2 AA; see CLAUDE.md for the contrast table.
*/
:root {
  color-scheme: light dark;

  --hr-bg: #f4f6f5;
  --hr-surface: #ffffff;
  --hr-surface-raised: #eef2f1;
  --hr-border: #dde2e0;
  --hr-border-strong: #7d8b88; /* inputs and controls: 3:1 against surface */
  --hr-text: #16211f;
  --hr-text-muted: #4f5c59;
  --hr-primary: #0e6b66;
  --hr-primary-hover: #0a4f4b;
  --hr-on-primary: #ffffff;
  --hr-tint: #e3f1ef;
  --hr-tint-text: #0a4f4b;
  --hr-accent: #e8925b;
  --hr-accent-outline: #a3521f;
  /* The one warm note in the logo mark (its back bubble). */
  --hr-mark-warm: #c4692e;

  /* Results scale: orange against blue, color-blind safe. Always paired with text. */
  --hr-result-negative: #c2410c;
  --hr-result-neutral: #cbd0dc;
  --hr-result-positive: #1d5fa8;

  --hr-focus: #0e6b66;

  /* Admin navigation rail: a deep teal panel in both modes. */
  --hr-nav-bg: #0f2e2b;
  --hr-nav-border: #1d4440;
  --hr-nav-text: #e2efec;
  --hr-nav-muted: #9cb6b1;
  --hr-nav-hover: #173c38;
  --hr-nav-active: #1f4f4a;
  --hr-nav-indicator: #5cc2b4;
  --hr-nav-focus: #8fdcd1;

  --hr-font-heading: "Plus Jakarta Sans", system-ui, sans-serif;
  --hr-font-body: "Inter", system-ui, sans-serif;
  --hr-radius: 14px;
  --hr-radius-card: 16px;
  --hr-target: 44px; /* minimum touch target */
}

@media (prefers-color-scheme: dark) {
  :root {
    --hr-bg: #0f1716;
    --hr-surface: #172220;
    --hr-surface-raised: #1f2d2b;
    --hr-border: #2c3c39;
    --hr-border-strong: #7f908b;
    --hr-text: #e7efed;
    --hr-text-muted: #a4b4b0;
    --hr-primary: #5cc2b4;
    --hr-primary-hover: #7fd3c8;
    --hr-on-primary: #0b1312;
    --hr-tint: #143431;
    --hr-tint-text: #8fdcd1;
    --hr-accent: #f0a574;
    --hr-accent-outline: #f0a574;
    --hr-mark-warm: #f0a574;

    --hr-result-negative: #f0884a;
    --hr-result-neutral: #64746f;
    --hr-result-positive: #6fa8f2;

    --hr-focus: #5cc2b4;

    --hr-nav-bg: #0b1312;
    --hr-nav-border: #22312e;
    --hr-nav-text: #e2efec;
    --hr-nav-muted: #93a6a2;
    --hr-nav-hover: #15211f;
    --hr-nav-active: #1b2e2b;
    --hr-nav-indicator: #5cc2b4;
    --hr-nav-focus: #8fdcd1;
  }
}

/* Admin styles. Served after src/tokens.css; colors come only from the tokens.
   System fonts for now; the brand fonts can be self-hosted here later. */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--hr-bg);
  color: var(--hr-text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}
h1 { margin: 0; font-size: 1.75rem; line-height: 1.2; }
p { margin: 0; }
a { color: var(--hr-primary); }
:focus-visible { outline: 3px solid var(--hr-focus); outline-offset: 2px; }
.skip-link {
  position: absolute; left: 8px; top: -60px; padding: 12px 16px;
  background: var(--hr-primary); color: var(--hr-on-primary); border-radius: 8px;
}
.skip-link:focus { top: 8px; }
.admin-header {
  min-height: 64px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; background: var(--hr-surface); border-bottom: 1px solid var(--hr-border);
}
.wordmark {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--hr-target);
  color: var(--hr-text); text-decoration: none; font-weight: 800; font-size: 1.125rem;
}
.wordmark .honest { color: var(--hr-primary); }
.mark-warm { stroke: var(--hr-mark-warm); }
.mark-fill { fill: var(--hr-primary); }
.tag {
  font-size: 0.75rem; font-weight: 600; color: var(--hr-tint-text); background: var(--hr-tint);
  border-radius: 999px; padding: 2px 8px;
}
.admin-main {
  max-width: 560px; margin: 0 auto; padding: 32px 20px 48px;
  display: flex; flex-direction: column; gap: 18px;
}
.lede { color: var(--hr-text-muted); font-size: 1.0625rem; }
.muted { color: var(--hr-text-muted); font-size: 0.9375rem; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%;
  min-height: 52px; padding: 0 20px; border-radius: var(--hr-radius);
  border: 1px solid var(--hr-primary); background: var(--hr-primary); color: var(--hr-on-primary);
  font: 600 1rem system-ui, sans-serif; cursor: pointer;
}
.btn:hover { background: var(--hr-primary-hover); border-color: var(--hr-primary-hover); }
.btn-link {
  min-height: var(--hr-target); padding: 0 12px; border: 0; background: none;
  color: var(--hr-primary); font: 500 0.9375rem system-ui, sans-serif; text-decoration: underline; cursor: pointer;
}
label { font-weight: 600; }
input {
  min-height: var(--hr-target); padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--hr-border-strong); background: var(--hr-surface); color: var(--hr-text);
  font: 1.25rem ui-monospace, monospace; letter-spacing: 0.2em; max-width: 12rem;
}
.alert {
  padding: 12px 14px; border-radius: 12px; background: var(--hr-surface);
  border: 2px solid var(--hr-accent-outline);
}
.steps { margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 24px; }
.steps > li > * + * { margin-top: 10px; }
/* The QR SVG draws its own white background and margin, so it scans in dark mode too. */
.qr { width: 220px; height: 220px; border-radius: 12px; overflow: hidden; }
.qr svg { width: 100%; height: 100%; display: block; }
.key { word-break: break-all; }
.codes {
  margin: 0; padding: 12px 16px; list-style: none; display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px;
  background: var(--hr-surface); border: 1px solid var(--hr-border); border-radius: 12px;
}
code { font-family: ui-monospace, monospace; }
h2 { margin: 0; font-size: 1.25rem; }
.panel { padding: 18px; background: var(--hr-surface); border: 1px solid var(--hr-border); border-radius: var(--hr-radius-card); }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--hr-tint); color: var(--hr-tint-text); }
.list { margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 8px; }
.list a { display: inline-flex; align-items: center; min-height: var(--hr-target); }
input.text { font: 1rem system-ui, sans-serif; letter-spacing: normal; max-width: none; width: 100%; }
.choice { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 8px; }
.choice legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.choice label { font-weight: 400; display: flex; align-items: center; gap: 10px; min-height: var(--hr-target); }
.choice input { min-height: auto; width: 20px; height: 20px; }
.members { width: 100%; border-collapse: collapse; text-align: left; }
.members th, .members td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--hr-border); vertical-align: middle; }
.members thead th { font-size: 0.875rem; color: var(--hr-text-muted); }
.members tbody th { font-weight: 500; overflow-wrap: anywhere; }
.tag { white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline { display: inline; }
.btn-small {
  min-height: var(--hr-target); padding: 0 12px; border-radius: 10px; border: 1px solid var(--hr-border-strong);
  background: var(--hr-surface); color: var(--hr-text); font: 500 0.875rem system-ui, sans-serif; cursor: pointer;
}
.btn-small:hover { background: var(--hr-surface-raised); }
textarea.text { width: 100%; min-height: 6rem; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--hr-border-strong); background: var(--hr-surface); color: var(--hr-text); font: 1rem/1.5 system-ui, sans-serif; }
.facts { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; }
.members caption { text-align: left; font-weight: 600; padding: 12px 0 6px; }
h3 { margin: 0; font-size: 1.0625rem; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Survey builder (the only admin page with a script). */
.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; }
.admin-main:has(#builder:not([hidden])) { max-width: 760px; }
.templates { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.templates a { display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--hr-border-strong); color: var(--hr-text); text-decoration: none; }
.templates a:hover { border-color: var(--hr-primary); }
.templates a strong { color: var(--hr-primary); text-decoration: underline; }
.templates a span { color: var(--hr-text-muted); font-size: 0.9375rem; }
.builder { display: flex; flex-direction: column; gap: 24px; }
.builder h2 { margin: 0; font-size: 1.125rem; }
.q-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.q-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--hr-border); background: var(--hr-surface); }
.q-item.dragging { opacity: 0.5; }
.q-item.drop-target { border-color: var(--hr-primary); border-style: dashed; }
.drag-handle { grid-row: 1 / span 2; align-self: start; padding-top: 30px; color: var(--hr-text-muted); cursor: grab; user-select: none; letter-spacing: -0.2em; }
.q-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.q-label { font-size: 0.875rem; color: var(--hr-text-muted); font-weight: 600; }
.q-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.q-issues { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.issue { font-size: 0.875rem; padding: 6px 10px; border-radius: 8px; border-left: 4px solid; }
.issue.block { border-color: var(--hr-result-negative); background: var(--hr-surface-raised); }
.issue.warn { border-color: var(--hr-accent-outline); background: var(--hr-surface-raised); }
.add-own { align-self: flex-start; }
.library { padding: 14px; border-radius: 12px; border: 1px solid var(--hr-border); background: var(--hr-surface); }
.library summary { min-height: var(--hr-target); display: flex; align-items: center; font-weight: 600; cursor: pointer; color: var(--hr-primary); }
.library h3 { margin-top: 14px; }
.lib-list { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.lib-list li { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--hr-border); }
.lib-list li > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-why { font-size: 0.8125rem; }
textarea.q-text { min-height: 0; resize: vertical; }
.fit { align-self: flex-start; }
