/* gematik brand colours (as in zero-lab metsubushi), resolved per theme. */
:root {
  --dark-blue: #000e52;
  --green: #00ff64;
  --bright-blue: #00b7ff;
  --medium-blue: #1391bc;

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #1b1e2b;
  --muted: #59677c;
  --border: #d1dbe7;
  --code-bg: #f4f6f9;
  --code-text: #000e52;
  --accent: #000e52;
  --accent-text: #ffffff;
  --accent-hover: #1a2a75;
  --link: #0b6b8f;
  --focus: #1391bc;
  --ok-bg: #d8f3e5;
  --ok-text: #00592a;
  --warn-bg: #fff4d6;
  --warn-border: #f1c75b;
  --warn-text: #5c3b00;
  --shadow: 0 1px 2px rgb(0 14 82 / 6%), 0 4px 16px rgb(0 14 82 / 6%);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", Menlo, Consolas, monospace;
  --radius: 14px;
  --radius-s: 8px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e1f;
    --surface: #121833;
    --surface-2: #1a2244;
    --text: #e8edf3;
    --muted: #a3b0c2;
    --border: #283257;
    --code-bg: #0b1026;
    --code-text: #cfe3ff;
    --accent: #00ff64;
    --accent-text: #000e52;
    --accent-hover: #5cff9a;
    --link: #5fd0ff;
    --focus: #00b7ff;
    --ok-bg: rgb(0 255 100 / 12%);
    --ok-text: #6dffa8;
    --warn-bg: rgb(255 196 14 / 10%);
    --warn-border: rgb(255 196 14 / 45%);
    --warn-text: #ffd666;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0e1f;
  --surface: #121833;
  --surface-2: #1a2244;
  --text: #e8edf3;
  --muted: #a3b0c2;
  --border: #283257;
  --code-bg: #0b1026;
  --code-text: #cfe3ff;
  --accent: #00ff64;
  --accent-text: #000e52;
  --accent-hover: #5cff9a;
  --link: #5fd0ff;
  --focus: #00b7ff;
  --ok-bg: rgb(0 255 100 / 12%);
  --ok-text: #6dffa8;
  --warn-bg: rgb(255 196 14 / 10%);
  --warn-border: rgb(255 196 14 / 45%);
  --warn-text: #ffd666;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

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

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

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.1rem); letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.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;
}

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---- top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 3px 0 var(--green);
}

.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  min-width: 0;
}

.brand img { display: block; flex: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { color: var(--muted); font-weight: 500; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.topbar-actions form { margin: 0; }

.user {
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 14ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.theme-switch button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 15%);
}

.theme-switch svg, .copy svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- content ---- */
.intro { margin: 40px 0 24px; }
.lead { color: var(--muted); font-size: 1.05rem; margin: 10px 0 0; max-width: 62ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-narrow {
  max-width: 460px;
  margin: 12vh auto 40px;
  text-align: center;
}

.card-narrow .lead { margin: 12px auto 24px; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.card-head p { margin: 6px 0 0; }

.step {
  font-size: 0.8rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 22px 0 8px;
}

.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.badge-ok { background: var(--ok-bg); color: var(--ok-text); }

/* ---- masked tokens ---- */
.secret-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.secret-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--code-bg);
}

.secret-value {
  flex: 1 1 260px;
  min-width: 0;
  padding: 0;
  background: none;
  color: var(--code-text);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* One click selects the whole token; app.js swaps in the full value on copy. */
  user-select: all;
  cursor: text;
}

.secret-value.revealed { white-space: normal; word-break: break-all; }
.secret-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.hint { margin: 8px 0 0; }

/* ---- example tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.tabs [role="tab"] {
  flex: none;
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--muted);
  font: 600 0.9rem var(--font);
  cursor: pointer;
}

.tabs [role="tab"]:hover { color: var(--text); }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--green); }

/* ---- examples and docs ---- */
.examples { display: grid; gap: 22px; }
/* Grid items default to their content's width; a wide results table must scroll in
   its own box instead of widening the page. */
.examples > * { min-width: 0; }
.example h3 { margin: 0; font-size: 1rem; }
.example p { margin: 4px 0 12px; }

.docs-line { margin: 20px 0 0; color: var(--muted); }

details.more { margin-top: 16px; }
details.more summary { cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--muted); margin-bottom: 10px; }

.try-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 140px; min-width: 0; }
.field span { font-size: 0.75rem; font-weight: 600; color: var(--muted); }

.field input {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 0.88rem var(--mono);
}

.field input:focus-visible { outline-offset: 0; border-color: var(--focus); }

.run svg { width: 14px; height: 14px; fill: currentColor; }
.run:disabled { opacity: 0.7; cursor: progress; }

.result { margin-top: 12px; }

.result-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.status {
  font: 700 0.8rem var(--mono);
  padding: 2px 8px;
  border-radius: 6px;
}

.status-ok { background: var(--ok-bg); color: var(--ok-text); }
.status-err { background: var(--warn-bg); color: var(--warn-text); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
}

table.results {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.results th, .results td {
  text-align: left;
  vertical-align: top;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.results th {
  background: var(--surface-2);
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.results tr:last-child td { border-bottom: 0; }
.results .strong { font-weight: 600; }
.results .mono { font-family: var(--mono); font-size: 0.8rem; white-space: pre-line; overflow-wrap: anywhere; }
.results .tid { white-space: nowrap; overflow-wrap: normal; }

details.raw { margin-top: 10px; }
details.raw summary { cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; }

/* ---- code blocks with copy ---- */
.code {
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--code-bg);
  overflow: hidden;
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 4px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.code-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.code pre {
  margin: 0;
  padding: 14px 16px;
  max-height: 22rem;
  overflow: auto;
}

.code pre code {
  display: block;
  padding: 0;
  background: none;
  color: var(--code-text);
  font-size: 0.84rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code.token pre code { word-break: break-all; }

.copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: 600 0.8rem var(--font);
  cursor: pointer;
}

.copy:hover { background: var(--surface); border-color: var(--border); }
.copy.copied { color: var(--ok-text); background: var(--ok-bg); }

/* ---- buttons, notices ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: 600 0.95rem var(--font);
  text-decoration: none;
  cursor: pointer;
}

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn .gh { width: 18px; height: 18px; fill: currentColor; }

.notice {
  border-radius: var(--radius-s);
  padding: 14px 16px;
  border: 1px solid;
}

.notice p { margin: 0 0 6px; }
.notice p:last-child { margin-bottom: 0; }
.notice-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.notice-warn .muted { color: inherit; opacity: 0.85; }

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-top: 16px;
  padding-bottom: 32px;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 560px) {
  .brand-sub, .user { display: none; }
  .card { padding: 18px 16px; }
  .code pre { padding: 12px; }
  .intro { margin-top: 28px; }
}

@media (max-width: 420px) {
  .brand-name { display: none; }
}
