/* Tokens follow notera.no: near-black on off-white, one rule colour, one
   focus colour. Every text colour meets WCAG AA on its background. */
:root {
  --fg: #1a1a1a;
  --fg-muted: #5c5c5c;
  --bg: #fdfdfc;
  --surface: #f4f4f2;
  --rule: #e2e2df;
  --focus: #0b5cd5;
  --ok: #1d6b3a;
  --warn-fg: #7a4100;
  --warn-bg: #fdf3e4;
  --danger-fg: #8a1c1c;
  --danger-bg: #fcecec;
  --page-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 1px rgba(0, 0, 0, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg: #ededeb;
    --fg-muted: #a3a39f;
    --bg: #17171a;
    --surface: #1f1f23;
    --rule: #2e2e33;
    --focus: #8ab4ff;
    --ok: #7fd49b;
    --warn-fg: #f5c98a;
    --warn-bg: #33270f;
    --danger-fg: #f4b3b3;
    --danger-bg: #3a1616;
    --page-shadow: 0 0 0 1px #2e2e33;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

body.in-room { height: 100vh; overflow: hidden; }
body.in-room, body.in-room * { -webkit-user-select: none; user-select: none; }

h1, h2, h3, p { margin: 0; }
h1 {
  font-size: clamp(1.85rem, 5.5vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.2;
  text-wrap: balance;
  margin-bottom: 1.25rem;
}
h1:focus, [tabindex="-1"]:focus { outline: none; }
h2 { font-size: 1.0625rem; font-weight: 600; }
p { text-wrap: pretty; }
a { color: inherit; text-underline-offset: .2em; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 20;
  background: var(--fg);
  color: var(--bg);
  padding: .5rem 1rem;
  border-radius: 999px;
  text-decoration: none;
}
.skip:focus { top: 1rem; }

/* --- Frame */

.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .875rem 1.5rem;
  min-height: 3.5rem;
}
body.in-room .top { border-bottom: 1px solid var(--rule); }
.brand { font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand .by { font-weight: 400; color: var(--fg-muted); margin-left: .25rem; }
.room-name { color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-name:not(:empty)::before { content: "/"; margin-right: 1rem; color: var(--rule); }
.spacer { flex: 1; }
.session { color: var(--fg-muted); font-size: .9375rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
main:focus { outline: none; }

.bottom {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  justify-content: space-between;
  max-width: 38rem;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--fg-muted);
  font-size: .9375rem;
}
body.in-room .bottom { display: none; }

/* --- Single-column pages */

.page-column {
  width: 100%;
  max-width: 38rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 10vh, 6rem) 1.5rem 4rem;
}
.lead {
  font-size: clamp(1.125rem, 3vw, 1.3rem);
  letter-spacing: -.01em;
  line-height: 1.5;
  margin-bottom: 2.5rem;
}
.page-column > p + p, .page-column .prose p + p { margin-top: 1rem; }
.muted { color: var(--fg-muted); }
.small { font-size: .9375rem; }

.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 2.5rem 0 0; }
.actions + p { margin-top: 1.25rem; }

/* --- Buttons: pills, as on notera.no */

button { font: inherit; color: inherit; }
.button {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 2.75rem;
  border: 1px solid var(--fg);
  border-radius: 999px;
  padding: .6rem 1.25rem;
  background: transparent;
  color: var(--fg);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.button.primary { background: var(--fg); color: var(--bg); }
.button:hover { background: var(--fg); color: var(--bg); }
.button.primary:hover { background: transparent; color: var(--fg); }
.button[aria-disabled="true"] { opacity: .6; cursor: progress; }
.button[aria-disabled="true"]:hover { background: var(--fg); color: var(--bg); }
.button:not(.primary)[aria-disabled="true"]:hover { background: transparent; color: var(--fg); }

.link {
  border: 0;
  background: none;
  padding: .25rem 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: .2em;
  cursor: pointer;
}
.top .link { color: var(--fg-muted); font-size: .9375rem; }
.link:hover { color: var(--fg); }

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 .6rem;
  border: 1px solid var(--fg-muted);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: .9375rem;
  font-variant-numeric: tabular-nums;
}
.icon-button:hover { border-color: var(--fg); }
.icon-button:disabled { opacity: .4; cursor: default; }
.icon-button:disabled:hover { border-color: var(--fg-muted); }

/* --- Notices */

.notice {
  padding: .875rem 1rem;
  border-radius: .5rem;
  margin: 1.25rem 0 0;
  font-size: .9375rem;
}
.notice.warn { background: var(--warn-bg); color: var(--warn-fg); }
.notice.danger { background: var(--danger-bg); color: var(--danger-fg); }

details.technical { margin-top: 2rem; color: var(--fg-muted); font-size: .9375rem; }
details.technical summary { cursor: pointer; }
details.technical pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  padding: .75rem 1rem;
  border-radius: .5rem;
  -webkit-user-select: text;
  user-select: text;
}

/* --- Steps */

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 2rem 3rem;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -.05rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  font-size: .9375rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
}
.steps > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 1rem;
  top: 2.25rem;
  bottom: .25rem;
  border-left: 1px solid var(--rule);
}
.steps > li[data-state="current"]::before { border-color: var(--fg); background: var(--fg); color: var(--bg); }
.steps > li[data-state="done"]::before { content: "✓"; border-color: var(--ok); color: var(--ok); }
.steps h2 { margin-bottom: .25rem; }
.steps p { color: var(--fg-muted); }
.steps li[data-state="current"] p { color: var(--fg); }
.steps .actions { margin-top: 1rem; }
.steps li > div { margin-top: 1rem; }

/* --- Security code: six groups of five digits */

.code {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: .5rem 1.25rem;
  margin: 1rem 0 0;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-radius: .75rem;
  font: 600 clamp(1.35rem, 5vw, 1.75rem)/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
}
.code.short { grid-template-columns: auto; }

/* --- Room: documents left, viewer right */

.room { flex: 1; min-height: 0; display: flex; }

.tree {
  width: 20rem;
  flex: none;
  overflow: auto;
  border-right: 1px solid var(--rule);
  padding: 1.25rem .75rem 1.5rem;
  display: flex;
  flex-direction: column;
}
.tree-head { padding: 0 .5rem .75rem; }
.tree-head h2 { font-size: .8125rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-muted); }
.tree-head p { font-size: .875rem; color: var(--fg-muted); }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { padding-left: .875rem; }
.tree summary {
  display: flex;
  align-items: center;
  gap: .375rem;
  padding: .3rem .5rem;
  border-radius: .375rem;
  cursor: pointer;
  list-style: none;
  font-weight: 500;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before {
  content: "";
  width: .4rem;
  height: .4rem;
  border-right: 1.5px solid var(--fg-muted);
  border-bottom: 1.5px solid var(--fg-muted);
  transform: rotate(-45deg);
  margin: 0 .3rem 0 .1rem;
  flex: none;
}
.tree details[open] > summary::before { transform: rotate(45deg); }
.tree summary:hover, .tree .file:hover { background: var(--surface); }
.tree .file {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: .375rem;
  background: none;
  padding: .35rem .5rem .35rem 1.4rem;
  cursor: pointer;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.tree .file[aria-current="page"] { background: var(--fg); color: var(--bg); }
.tree-foot {
  margin-top: auto;
  padding: 1.5rem .5rem 0;
  font-size: .8125rem;
  color: var(--fg-muted);
  display: grid;
  gap: .5rem;
}

.viewer { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.viewer-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  min-height: 3.25rem;
}
.viewer-bar h2 {
  font-size: 1rem;
  letter-spacing: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.viewer-bar .meta { color: var(--fg-muted); font-size: .9375rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.zoom { display: flex; gap: .375rem; }
.pages { flex: 1; overflow: auto; padding: 1.5rem; }
.pages:focus-visible { outline-offset: -3px; }
.viewer .empty { margin: auto; padding: 2rem; color: var(--fg-muted); text-align: center; max-width: 24rem; }

.page {
  display: block;
  width: 100%;
  margin: 0 auto 1.5rem;
  background: #fff;
  box-shadow: var(--page-shadow);
  border-radius: 2px;
}

/* --- Pause and print */

#paused {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--fg-muted);
  text-align: center;
  padding: 1.5rem;
}
#paused[hidden] { display: none; }
.paused-title { color: var(--fg); font-weight: 600; font-size: 1.125rem; margin-bottom: .25rem; }

#print-block { display: none; }

/* --- Sender screens */

.page-column.wide { max-width: 60rem; padding-top: clamp(1.5rem, 5vh, 3rem); }
.sender-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; margin-bottom: 2rem; padding-bottom: .75rem; border-bottom: 1px solid var(--rule); }
.sender-nav a { color: var(--fg-muted); text-decoration: none; padding: .25rem 0; }
.sender-nav a:hover { color: var(--fg); text-decoration: underline; }
.sender-nav a[aria-current="page"] { color: var(--fg); font-weight: 600; }
.back { margin: -.75rem 0 1rem; font-size: .9375rem; }
.back a { color: var(--fg-muted); }
.page-column.wide .actions { margin-top: 1.5rem; }
.page-column.wide h2 { margin: 2.5rem 0 .75rem; }
.page-column.wide .lead { margin-bottom: 1.5rem; }

.button.small { min-height: 2.25rem; padding: .3rem .9rem; font-size: .9375rem; }
label.button { user-select: none; }

ul.plain { list-style: none; margin: .5rem 0 0; padding: 0; }
ul.plain li { padding: .375rem 0; }
.attention { margin-bottom: 2rem; padding: 1rem 1.25rem; border-radius: .5rem; background: var(--warn-bg); color: var(--warn-fg); }
.attention h2 { margin: 0 0 .25rem !important; }
.attention li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }

.cards { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.cards li { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.cards a { font-weight: 600; font-size: 1.125rem; }

.inline-form { margin-top: 2.5rem; }
.inline-form .row, .confirm .row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: .375rem; }
.inline-form input { flex: 1; min-width: 12rem; }

.field { margin-top: 1.5rem; }
.field label, label[for="invite-text"] { display: block; font-weight: 600; }
.hint { color: var(--fg-muted); font-size: .9375rem; margin-top: .125rem; }
input[type="text"], input[type="email"], select, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--fg-muted);
  border-radius: .5rem;
  padding: .55rem .75rem;
  min-height: 2.75rem;
  width: 100%;
  margin-top: .375rem;
}
.field input, .field select { max-width: 28rem; }
textarea { resize: vertical; line-height: 1.5; }
#invite-text { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .875rem; margin-top: .5rem; }
.code-input { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.125rem; letter-spacing: .05em; font-variant-numeric: tabular-nums; }
[aria-invalid="true"] { border-color: var(--danger-fg); box-shadow: 0 0 0 1px var(--danger-fg); }

table.readers { width: 100%; border-collapse: collapse; font-size: .9375rem; }
table.readers th { text-align: left; font-weight: 600; color: var(--fg-muted); padding: .5rem .75rem .5rem 0; border-bottom: 1px solid var(--rule); }
table.readers td { padding: .75rem .75rem .75rem 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.readers td.row-actions { white-space: nowrap; text-align: right; }
table.readers td.row-actions > * + * { margin-left: .5rem; }
.status { white-space: nowrap; }
.status.pending { color: var(--warn-fg); font-weight: 600; }
.status.approved { color: var(--ok); }
.status.expired, .status.revoked { color: var(--fg-muted); }
.confirm { text-align: left; white-space: normal; max-width: 24rem; margin-left: auto; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .375rem 1.5rem; margin: 0 0 1rem; }
dl.facts dt { color: var(--fg-muted); }
dl.facts dd { margin: 0; }

.plan { margin-top: 1rem; }
.plan details { margin-top: .75rem; }
.plan summary { cursor: pointer; font-weight: 500; }
progress { width: 100%; height: .5rem; margin: 1rem 0 .75rem; accent-color: var(--fg); }
.progress-text { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

ol.activity { list-style: none; margin: 0; padding: 0; font-size: .9375rem; }
ol.activity li { padding: .5rem 0; border-bottom: 1px solid var(--rule); }
ol.activity time { color: var(--fg-muted); font-variant-numeric: tabular-nums; margin-right: .75rem; }
table.compact { border-collapse: collapse; margin-top: .5rem; font-size: .9375rem; }
table.compact th, table.compact td { padding: .25rem 1.5rem .25rem 0; text-align: left; font-weight: normal; }
.report { margin-top: 1rem; }

@media (max-width: 760px) {
  .top { padding: .75rem 1rem; gap: .75rem; }
  .session { display: none; }
  body.in-room { height: auto; overflow: auto; }
  .room { flex-direction: column; }
  .tree { width: 100%; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--rule); }
  .tree-foot { display: none; }
  .pages { padding: 1rem; }
  .viewer-bar { padding: .5rem 1rem; flex-wrap: wrap; }
  .page-column { padding-left: 1rem; padding-right: 1rem; }
  table.readers thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.readers tr { display: block; padding: .75rem 0; border-bottom: 1px solid var(--rule); }
  table.readers td { display: block; border: 0; padding: .125rem 0; }
  table.readers td[data-label]::before { content: attr(data-label) ": "; color: var(--fg-muted); }
  table.readers td.row-actions { text-align: left; padding-top: .5rem; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dd { margin-bottom: .5rem; }
}

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

@media (forced-colors: active) {
  .button, .icon-button, .tree .file[aria-current="page"] { border: 1px solid ButtonText; }
  .tree .file[aria-current="page"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}

/* Printing shows only a notice. Deterrence, not a control: see docs. */
@media print {
  body > *:not(#print-block) { display: none !important; }
  #print-block { display: block; padding: 2.5rem; font-size: 1.125rem; }
}
