/* Tuglu design tokens. Mirrors docs/tuglu-design.html. */
:root {
  --ground: #f5f7f8;
  --paper: #ffffff;
  --ink: #141a1f;
  --muted: #56626b;
  --rule: #dce2e6;
  --accent: #0e6b7a;
  --accent-ink: #ffffff;
  --accent-soft: #e0eff1;
  --warn: #9a5b00;
  --warn-soft: #fbf0dd;
  --danger: #a3291f;
  --danger-soft: #fae4e2;
  --ok: #1d6b45;
  --ok-soft: #dff0e7;
  --code: #eef2f4;

  /* Typography is the system stack on purpose: Segoe UI on Windows, the
     system face elsewhere, and no web font anywhere. A candidate's browser
     makes zero third-party requests to render an assessment, and nothing waits
     on a font to paint. One family throughout, so heading and body separate on
     weight — 700 headings, 400 body, 600 for buttons and emphasis — rather
     than on a typeface the page had to go and fetch. */
  --display: "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --body: "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: Consolas, ui-monospace, "SF Mono", Menlo, "Cascadia Mono", monospace;

  --gap: 16px;
  --radius: 4px;
  --shell: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f1417;
    --paper: #161d21;
    --ink: #e6ecef;
    --muted: #94a3ac;
    --rule: #2a353b;
    --accent: #5cc3d1;
    --accent-ink: #06222a;
    --accent-soft: #16333a;
    --warn: #e6b366;
    --warn-soft: #33280f;
    --danger: #f0938a;
    --danger-soft: #3a1c19;
    --ok: #7fd3a8;
    --ok-soft: #14301f;
    --code: #1d262b;
  }
}

:root[data-theme="dark"] {
  --ground: #0f1417;
  --paper: #161d21;
  --ink: #e6ecef;
  --muted: #94a3ac;
  --rule: #2a353b;
  --accent: #5cc3d1;
  --accent-ink: #06222a;
  --accent-soft: #16333a;
  --warn: #e6b366;
  --warn-soft: #33280f;
  --danger: #f0938a;
  --danger-soft: #3a1c19;
  --ok: #7fd3a8;
  --ok-soft: #14301f;
  --code: #1d262b;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.6 var(--body);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

h1 { font: 700 clamp(26px, 3.4vw, 34px)/1.15 var(--display); margin: 0 0 10px; letter-spacing: -0.01em; }
h2 { font: 700 21px/1.25 var(--display); margin: 0 0 10px; }
h3 { font: 700 17px/1.3 var(--display); margin: 20px 0 6px; }

.skip {
  position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; z-index: 50;
}
.skip:focus { left: 0; }

/* ---------- shell ---------- */

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 58px;
  background: var(--paper); border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 20;
}
.brand { text-decoration: none; }
.brand-mark { font: 700 20px/1 var(--display); color: var(--accent); letter-spacing: -0.02em; }
.topnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topnav a {
  color: var(--muted); text-decoration: none; padding: 7px 11px; border-radius: var(--radius);
  font-size: 15px;
}
.topnav a:hover { background: var(--ground); color: var(--ink); }
.topnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  background: none; border: 1px solid var(--rule); color: var(--muted);
  border-radius: var(--radius); width: 32px; height: 32px; cursor: pointer; font-size: 15px;
}

.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; padding: 6px 10px; border: 1px solid var(--rule);
  border-radius: var(--radius); font-size: 14px; color: var(--muted); max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--paper);
  border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px;
  min-width: 200px; box-shadow: 0 8px 24px rgb(0 0 0 / 12%); z-index: 30;
}
.menu-meta { color: var(--muted); font-size: 13px; margin: 0 0 8px; }

.app-main { flex: 1; width: 100%; max-width: var(--shell); margin: 0 auto; padding: 28px 24px 56px; }
.bare-main { flex: 1; display: grid; place-items: center; padding: 48px 20px; }

.footer {
  border-top: 1px solid var(--rule); color: var(--muted); font-size: 13px;
  padding: 14px 24px; text-align: center;
}

/* ---------- pieces ---------- */

.page-head { margin-bottom: 24px; }
.page-head .lede, .lede { color: var(--muted); font-size: 18px; margin: 0; max-width: 62ch; }
.eyebrow {
  font: 500 12px/1 var(--mono); color: var(--accent); letter-spacing: 0.06em;
  text-transform: uppercase; margin: 0 0 10px;
}
.muted { color: var(--muted); }
.small { font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--gap); }
.card {
  display: block; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 18px 20px; text-decoration: none; color: inherit;
}
.card:hover { border-color: var(--accent); }
.card b { display: block; font: 600 17px/1.3 var(--display); margin-bottom: 6px; }
.card span { color: var(--muted); font-size: 15px; }

.panel {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 20px 22px; margin-top: 24px;
}
.panel.tight { padding: 14px 16px; }
.panel + .panel { margin-top: 16px; }

.steps { color: var(--muted); padding-left: 20px; margin: 0 0 12px; }
.steps li { margin: 4px 0; }

.auth-card {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 32px 34px; width: min(440px, 100%);
}
.stack-form { display: grid; gap: 8px; margin: 18px 0 0; }
.stack-form label { font-size: 14px; font-weight: 600; }

input[type="text"], input[type="email"], input[type="number"], input[type="url"], input[type="search"],
select, textarea {
  font: inherit; color: var(--ink); background: var(--ground);
  border: 1px solid var(--rule); border-radius: var(--radius); padding: 9px 11px; width: 100%;
}
textarea { min-height: 150px; resize: vertical; font: 400 15px/1.55 var(--body); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  padding: 9px 18px; border-radius: var(--radius); font: 600 15px/1.4 var(--body);
  text-decoration: none; cursor: pointer; text-align: center;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--paper); color: var(--ink); border-color: var(--rule); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 5px 11px; font-size: 14px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
button.link {
  background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0;
  text-decoration: underline;
}

.provider-buttons { display: grid; gap: 8px; }
.divider { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0 12px; position: relative; }
.divider::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--rule);
}
.divider span { background: var(--paper); position: relative; padding: 0 10px; }

.alert { background: var(--danger-soft); color: var(--ink); border-left: 3px solid var(--danger); padding: 10px 14px; }
.notice { background: var(--warn-soft); color: var(--ink); border-left: 3px solid var(--warn); padding: 10px 14px; }
.ok-note { background: var(--ok-soft); color: var(--ink); border-left: 3px solid var(--ok); padding: 10px 14px; }
.devbox {
  background: var(--warn-soft); border-left: 3px solid var(--warn); padding: 12px 14px; font-size: 14px;
  word-break: break-all;
}

.pill {
  display: inline-block; font: 500 11.5px/1 var(--mono); padding: 4px 7px; border-radius: 3px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.good { background: var(--ok-soft); color: var(--ok); }
.pill.grey { background: var(--code); color: var(--muted); }

table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th {
  font: 600 12px/1.3 var(--body); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); background: var(--ground);
}
td.num, th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); }

code, pre { font-family: var(--mono); }
pre { background: var(--code); padding: 14px 16px; overflow-x: auto; font-size: 13.5px; border-radius: var(--radius); }
code { background: var(--code); padding: 1px 5px; border-radius: 3px; font-size: 0.88em; }
.stack { white-space: pre-wrap; font-size: 12.5px; color: var(--muted); }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--gap); }
.stack-gap { display: grid; gap: 12px; }
.empty { color: var(--muted); padding: 28px; text-align: center; border: 1px dashed var(--rule); border-radius: var(--radius); }

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .app-main { padding: 20px 16px 40px; }
}

/* ---------- integrity timeline (M4) ---------- */

.track {
  position: relative; height: 34px; margin: 14px 0 6px;
  background: var(--code); border-radius: var(--radius); overflow: hidden;
}
.track-mark {
  position: absolute; top: 6px; width: 4px; height: 22px; border-radius: 2px;
  background: var(--muted);
}
.track-mark.sev-high { background: var(--danger); }
.track-mark.sev-medium { background: var(--warn); }
.track-mark.sev-low { background: var(--accent); }
.track-mark.sev-info { background: var(--rule); }
.track-mark.faint { opacity: 0.35; height: 12px; top: 11px; }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.shot { margin: 0; }
.shot img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--rule); background: var(--code);
}
.shot figcaption { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* The still taken at the moment a signal fired, shown in its timeline row. */
.shot-thumb {
  width: 72px; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  border-radius: var(--radius); border: 1px solid var(--rule); background: var(--code);
}

/* ---------- reports (M5) ---------- */

.score-badge {
  text-align: right; padding: 10px 18px; border: 1px solid var(--rule);
  border-radius: var(--radius); background: var(--paper); display: grid; gap: 2px;
}
.score-badge strong { font: 700 28px/1 var(--display); color: var(--accent); }

.bar { background: var(--code); border-radius: 3px; height: 10px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }

.answer-options { list-style: none; padding: 0; margin: 12px 0; }
.answer-options li {
  padding: 10px 12px; margin-bottom: 6px; border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.answer-options li.correct { border-color: var(--ok); background: var(--ok-soft); }
.answer-options li.chosen:not(.correct) { border-color: var(--danger); background: var(--danger-soft); }

.review {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 14px 16px; margin-top: 14px; border-radius: 0 var(--radius) var(--radius) 0;
}
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 10px 0; }
.review-grid dt { font-size: 13px; font-weight: 600; color: var(--muted); }
.review-grid dd { margin: 2px 0 0; font-size: 14.5px; }

.override { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--rule); }

/* Report header facts: started, submitted, duration, billable. */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.facts dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.facts dd { margin: 2px 0 0; }

/* Settings -> Team. The role picker and the actions sit inside the row, so
   changing someone's role is one control rather than a screen of its own. */
.row-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn-quiet {
  background: transparent; color: var(--accent); border: 1px solid var(--rule);
  padding: 4px 10px; font-size: 13px; border-radius: var(--radius); cursor: pointer;
}
.btn-quiet:hover { border-color: var(--accent); }
.row-muted td { opacity: 0.62; }

/* Status reads at a glance: waiting, working, stopped. */
.pill-invited { background: var(--warn-soft); color: var(--warn); }
.pill-active { background: var(--ok-soft); color: var(--ok); }
.pill-deactivated { background: var(--code); color: var(--muted); }

.notice-bad { background: var(--danger-soft); border-left-color: var(--danger); }
