:root {
  color-scheme: light dark;
  --bg: #f6f5f2; --card: #ffffff; --text: #1d1d1b; --muted: #5d5b57; --line: #e2dfd8;
  --accent: #1f5f8b; --accent-text: #ffffff; --accent-soft: #e6f0f7;
  --danger: #b42318; --danger-soft: #fdeceb; --success: #1d6b3a; --success-soft: #e7f4ec;
  --focus: #1f5f8b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414; --card: #1e1e1e; --text: #f1efea; --muted: #b3afa7; --line: #34322f;
    --accent: #8cc3ea; --accent-text: #10202c; --accent-soft: #1d2b36;
    --danger: #f2a39b; --danger-soft: #3a1f1c; --success: #8fd1a6; --success-soft: #1b3024;
    --focus: #8cc3ea;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; justify-content: center; align-items: flex-start;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (min-height: 700px) and (min-width: 700px) { body { align-items: center; } }
.card { width: 100%; max-width: 34rem; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px 20px 20px; }
@media (min-width: 600px) { .card { padding: 32px 32px 24px; } }
.brand { margin: 0 0 12px; display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); letter-spacing: .02em; user-select: none; }
.progress { white-space: nowrap; }
h1 { margin: 0 0 16px; font-size: 24px; line-height: 1.25; }
h2 { margin: 0 0 8px; font-size: 18px; line-height: 1.3; display: flex; align-items: center; gap: 10px; }
p { margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 15px; }
.form { display: flex; flex-direction: column; gap: 8px; margin: 0 0 8px; }
label { font-weight: 600; }
input[type=text], input[type=password], select {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; font-size: 17px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input + label, .hint + label, select + label, fieldset + label, fieldset + fieldset { margin-top: 8px; }
fieldset { border: 0; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.choice { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-weight: 400; cursor: pointer; user-select: none; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin: 3px 0 0; width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.choice > span { display: flex; flex-direction: column; }
.choice .hint { font-size: 14px; }
details { display: flex; flex-direction: column; gap: 8px; }
details[open] > summary { margin-bottom: 8px; }
summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 6px 0; user-select: none; }
details > .choice + .choice { margin-top: 8px; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 20px; margin-top: 8px;
  font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  text-decoration: none; cursor: pointer; user-select: none; width: 100%;
}
@media (min-width: 600px) { button, .button { width: auto; align-self: flex-start; } }
button.secondary { background: transparent; color: var(--accent); }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--card); }
button.small { min-height: 40px; padding: 6px 14px; margin: 0; width: auto; }
.link-button { background: none; border: 0; color: var(--accent); padding: 8px 0; min-height: 44px; width: auto; font-weight: 600; }
.secondary-form { margin: 8px 0 0; }
.button + .hint { margin-top: 8px; }
.alert { padding: 12px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); }
.success { padding: 12px 14px; border-radius: 10px; background: var(--success-soft); color: var(--success); font-weight: 600; }
.fact { margin: 0 0 8px; }
.fact .label, .secret .label { display: block; font-size: 14px; color: var(--muted); }
.steps { margin: 0 0 16px; padding-left: 1.4em; display: flex; flex-direction: column; gap: 8px; }
.secret { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 10px; margin: 0 0 8px; }
.secret .label { flex-basis: 100%; }
.secret code { font: 600 20px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .04em; word-break: break-all; user-select: all; }
.waiting { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.done { margin-top: 4px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
a { color: var(--accent); }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.qr-frame { margin: 0 0 12px; display: flex; justify-content: center; }
.qr-frame svg { width: min(100%, 240px); height: auto; border-radius: 8px; }

/* "Geräte verwalten": a wider sheet with a top bar, lists as tables (cards on phones). */
body.manage { display: block; padding: 0 0 max(24px, env(safe-area-inset-bottom)); }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); background: var(--card); border-bottom: 1px solid var(--line); }
.topbar .brand { margin: 0; font-weight: 600; color: var(--text); }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; user-select: none; }
.topbar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.this-device { margin: 0 0 0 auto; font-size: 14px; color: var(--muted); text-align: right; }
.this-device .label { display: block; font-size: 12px; }
.sheet { max-width: 76rem; margin: 0 auto; padding: 24px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.sheet > h1 { margin-bottom: 20px; }
.sheet section { margin: 0 0 28px; }
.sheet h2 { margin: 0 0 12px; font-size: 19px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.panel.narrow { max-width: 38rem; }
.panel .form { max-width: 34rem; }
.count { font-weight: 400; color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); font-size: 14px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
a.button.small, .button.small { min-height: 40px; padding: 6px 14px; margin: 0; width: auto; font-size: 15px; }
.button.secondary, a.button.secondary { background: transparent; color: var(--accent); }
.button.danger, a.button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); user-select: none; }
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.current td { background: var(--accent-soft); }
.actions { display: flex; flex-wrap: nowrap; gap: 8px; align-items: flex-start; justify-content: flex-end; }
details.inline > summary { display: inline-flex; align-items: center; min-height: 40px; padding: 0 6px; font-size: 15px; }
details.inline[open] { flex-basis: 100%; }
.actions:has(details[open]) { flex-wrap: wrap; }
.row-form, .inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.row-form input[type=text] { min-height: 40px; font-size: 16px; padding: 6px 10px; }
.row-form button, .inline-form button { margin: 0; }
details.section { margin: 0 0 28px; }
details.section > summary { margin-bottom: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 0 0 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; min-width: 12rem; flex: 1 1 12rem; }
.filters input[type=text], .filters select { min-height: 44px; font-size: 16px; }
.filters button { margin: 0; }
@media (max-width: 760px) {
  .this-device { margin-left: 0; text-align: left; flex-basis: 100%; }
  .table-wrap { border: 0; background: none; border-radius: 0; overflow: visible; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.list tr { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 12px; padding: 6px 0; }
  table.list td { border: 0; padding: 6px 14px; }
  table.list td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); }
  table.list td.actions-cell::before { display: none; }
  .actions { justify-content: flex-start; }
}
