/* Layout and components. Colours and type come only from the theme tokens (scope section 11.2).
   Coloured and muted text stands only on --bg; panels use --text and --text-2. */

@font-face { font-family: "DM Sans"; font-weight: 400; font-display: swap; src: url("fonts/dm-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 500; font-display: swap; src: url("fonts/dm-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 700; font-display: swap; src: url("fonts/dm-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

[hidden] { display: none !important; }

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

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

.skip { position: absolute; left: -9999px; top: 8px; background: var(--bg); color: var(--text); padding: 6px 10px; z-index: 10; }
.skip:focus { left: 8px; }

/* ------------------------------------------------------------ header */

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 24px; height: 24px; }
.wordmark { font-family: var(--font-mono); font-weight: 500; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--text); }

.views { display: flex; gap: 4px; flex-wrap: wrap; }
.views button[aria-current="page"] { border-color: var(--accent); color: var(--accent); }

.connection { margin: 0 0 0 auto; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.connection.offline { color: var(--attention-text); }

.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }

/* ------------------------------------------------------------ main */

main { padding: 24px 20px 64px; max-width: 1100px; margin: 0 auto; }
main:focus { outline: none; }

h1 { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 17px; font-weight: 700; margin: 28px 0 8px; }
h3 { font-size: 15px; font-weight: 700; margin: 18px 0 6px; }

.lede { color: var(--text-2); margin: 0 0 18px; max-width: 68ch; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.loading { color: var(--muted); }

.panel {
  background: var(--panel);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 12px 0;
  color: var(--text);
}
.panel .secondary { color: var(--text-2); }
.panel .label, .panel .muted, .panel .saved, .raised .label, .raised .muted, .raised .saved { color: var(--text-2); }

.raised {
  background: var(--raised);
  border: 1px solid var(--raised-border);
  border-radius: 8px;
  padding: 14px 16px;
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--font-mono); font-size: 20px; font-weight: 500; }

/* ------------------------------------------------------------ controls */

button, .button {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--text-2); }
button:disabled { cursor: not-allowed; opacity: .6; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 500; }
button.quiet { border-color: transparent; background: transparent; color: var(--text-2); }
button.quiet:hover { border-color: var(--line); }

label { display: block; font-size: 13px; color: var(--text-2); margin: 10px 0 4px; }

input[type="text"], input[type="email"], input:not([type]), select, textarea {
  font: inherit;
  font-size: 14px;
  width: 100%;
  max-width: 420px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 6px;
  padding: 7px 10px;
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.saved { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-left: 6px; }

/* ------------------------------------------------------------ messages */

.notice { border-left: 3px solid var(--accent); padding: 8px 12px; margin: 12px 0; background: var(--bg); color: var(--text); }
.notice.risk { border-left-color: var(--attention); }
.notice .title { font-weight: 700; display: block; }
.error-text { color: var(--attention-text); }

.issues { list-style: none; padding: 0; margin: 8px 0; }
.issues li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.issues .where { font-family: var(--font-mono); font-size: 12px; color: var(--muted); display: block; }

/* ------------------------------------------------------------ tables */

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--text-2); border-bottom: 1px solid var(--line); padding: 6px 8px; }
td { border-bottom: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
.table-wrap { overflow-x: auto; }

td input[type="text"] { max-width: none; padding: 4px 6px; }

/* ------------------------------------------------------------ process view */

.criteria { list-style: none; padding: 0; margin: 4px 0 10px; }
.criteria li { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; }
.criteria .state { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); min-width: 64px; }
.stage-bar { display: flex; gap: 3px; margin: 6px 0 2px; }
.stage-bar span { flex: 1; height: 4px; background: var(--line); border-radius: 2px; }
.stage-bar span.on { background: var(--accent); }
.tone-risk { color: var(--attention-text); }
.tone-positive { color: var(--accent); }
.tone-muted, .tone-normal { color: var(--text-2); }

details { margin: 6px 0; }
summary { cursor: pointer; font-weight: 500; }

/* ------------------------------------------------------------ dialogs and sign-in */

.signin { max-width: 420px; margin: 8vh auto 0; }
.signin h1 { font-family: var(--font-mono); font-weight: 500; font-size: 15px; letter-spacing: .08em; text-transform: uppercase; }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); padding: 20px; max-width: 520px; width: calc(100% - 32px); }
dialog::backdrop { background: var(--text); opacity: .35; }

/* ------------------------------------------------------------ narrow screens */

@media (max-width: 767px) {
  .top { padding: 8px 12px; gap: 8px; }
  .connection { order: 4; width: 100%; margin: 0; }
  main { padding: 16px 12px 48px; }
  .grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------ decision card (scope section 11.8) */

.dec { border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin: 16px 0; background: var(--bg); }
.dec h2 { margin-top: 0; }
.dec .ctx { color: var(--text-2); margin: 6px 0; max-width: 72ch; }
.opts { display: grid; gap: 8px; margin: 6px 0 12px; }
.opt { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.opt[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.opt .ol { font-weight: 500; }
.opt .rec { font-family: var(--font-mono); font-size: 11px; color: var(--accent); align-self: center; }
.opt .od { grid-column: 1 / -1; color: var(--text-2); font-size: 13px; }
.why { margin: 8px 0 12px; color: var(--text); max-width: 72ch; }
.blast { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 6px 0; }
.area { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.area .al { color: var(--text-2); }
.area .av { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.meter { display: inline-flex; gap: 2px; }
.meter i { display: inline-block; width: 10px; height: 6px; border-radius: 2px; background: var(--line); }
.meter.v1 i:first-child, .meter.v2 i { background: var(--text-2); }
.blast-note { color: var(--text-2); font-size: 13px; margin: 4px 0 10px; }
.dec textarea { max-width: none; }
.decide { margin-top: 10px; }
