:root {
  --bg: #f4f1ec;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #fbfaf7 0%, transparent 60%);
  --card: #ffffff;
  --card-hover: #ffffff;
  --text: #1f2430;
  --muted: #6b6f78;
  --line: #e4dfd6;
  --brand: #1f2430;
  --mark-fg: #f4f1ec;
  --primary: #1f2430;
  --primary-fg: #ffffff;
  --danger-bg: #fdecea;
  --danger: #a3302a;
  --warn-bg: #fff4d6;
  --warn: #7a5600;
  --focus: #2f6fdd;
  --shadow: 0 1px 2px rgba(31, 36, 48, .06), 0 4px 16px rgba(31, 36, 48, .05);
  --shadow-hover: 0 2px 4px rgba(31, 36, 48, .06), 0 14px 32px rgba(31, 36, 48, .10);
  --radius: 18px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, #1c1f25 0%, transparent 60%);
    --card: #1c1f25;
    --card-hover: #21252c;
    --text: #ecebe8;
    --muted: #9a9ea6;
    --line: #2b2f37;
    --brand: #ecebe8;
    --mark-fg: #14161a;
    --primary: #ecebe8;
    --primary-fg: #14161a;
    --danger-bg: #3a1d1b;
    --danger: #ffb3ad;
    --warn-bg: #352a10;
    --warn: #f3d384;
    --focus: #7ea7ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-hover: 0 12px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-grad), var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
code { font-family: var(--mono); font-size: .9em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

/* ---------------------------------------------------------------- Marke */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.brand .mark { width: 30px; height: 30px; color: var(--brand); flex: none; }

/* ------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: 12px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { width: 100%; background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.link { background: none; border: 0; color: var(--muted); font-weight: 500; padding: 6px; }
.btn.link:hover { color: var(--text); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------ Hinweise */
.alert {
  margin: 0 0 18px; padding: 11px 14px; border-radius: 12px;
  background: var(--danger-bg); color: var(--danger); font-size: 14.5px;
}
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: color-mix(in srgb, #2f9e6b 14%, transparent); color: var(--text); }

/* --------------------------------------------------------- Login/Setup */
body.auth { display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  padding: 32px 28px 26px; box-shadow: var(--shadow);
}
.auth-card.wide { max-width: 560px; }
.auth-card .brand { margin-bottom: 26px; color: var(--muted); font-size: 15px; }
.auth-card h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-card h2 { font-size: 17px; margin: 0 0 6px; }
.lead { color: var(--muted); margin: 0 0 22px; }
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
label small { font-weight: 400; color: var(--muted); }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 400; color: var(--muted); }
label.check input { width: 18px; height: 18px; accent-color: var(--primary); }
input:not([type=checkbox]) {
  font: inherit; font-weight: 400; width: 100%;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.code-input { font-family: var(--mono) !important; font-size: 26px !important; letter-spacing: .35em; text-align: center; padding: 14px !important; }
.code-input::placeholder { color: color-mix(in srgb, var(--muted) 40%, transparent); }
.hint { color: var(--muted); font-size: 13.5px; margin: 0; }
.hint code { background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.cancel-form { margin-top: 8px; justify-items: center; }
.step-icon {
  width: 52px; height: 52px; border-radius: 16px; margin-bottom: 16px;
  display: grid; place-items: center; background: var(--bg); color: var(--text);
}
.step-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.qr-wrap { display: flex; gap: 20px; align-items: center; margin: 4px 0 22px; flex-wrap: wrap; }
.qr { border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 6px; width: 230px; height: auto; max-width: 100%; }
.qr-wrap > div { flex: 1; min-width: 200px; display: grid; gap: 8px; }
.secret {
  display: block; font-size: 15px; word-spacing: .2em; line-height: 1.7;
  background: var(--bg); border: 1px dashed var(--line); padding: 10px 12px; border-radius: 10px;
  user-select: all; word-break: break-word;
}
.recovery { background: var(--bg); border-radius: 16px; padding: 18px; margin: 0 0 18px; }
.recovery p { margin: 0 0 12px; font-size: 14.5px; color: var(--muted); }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 18px; margin: 0; padding-left: 22px; }
.codes code { font-size: 16px; user-select: all; }

/* --------------------------------------------------------------- Portal */
.topbar {
  max-width: 1080px; margin: 0 auto; padding: 22px 24px 0;
  display: flex; justify-content: space-between; align-items: center;
}
.portal { max-width: 1080px; margin: 0 auto; padding: 40px 24px 32px; }
.hello { margin-bottom: 30px; }
.hello .date { color: var(--muted); margin: 0 0 4px; font-size: 15px; }
.hello h1 { margin: 0; font-size: clamp(28px, 4.5vw, 40px); line-height: 1.1; letter-spacing: -.025em; font-weight: 700; }

.tiles {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}
.tile {
  --accent: #5b6472;
  position: relative; display: grid; gap: 18px; height: 100%;
  grid-template-rows: auto 1fr auto;
  padding: 20px 20px 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
  color: inherit; text-decoration: none; overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.tile::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent); opacity: 0; transition: opacity .18s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); background: var(--card-hover);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.tile:hover::before { opacity: 1; }
.tile:active { transform: translateY(-1px); }

.tile-icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.tile-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tile-icon svg .f { fill: currentColor; stroke: none; }
.tile-text { display: grid; gap: 3px; align-content: start; }
.tile-title { font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.tile-desc { color: var(--muted); font-size: 14.5px; }
.tile-host {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 12px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
}
.tile-host svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .18s ease, color .18s ease; }
.tile:hover .tile-host svg { transform: translate(2px, -2px); color: var(--accent); }

@media (prefers-color-scheme: dark) {
  .tile-icon { background: color-mix(in srgb, var(--accent) 20%, transparent); color: color-mix(in srgb, var(--accent) 70%, white); }
}

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 24px 32px; }

@media (max-width: 560px) {
  .portal { padding-top: 28px; }
  .tiles { gap: 12px; }
  .tile { grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 4px 14px; padding: 16px; }
  .tile-icon { grid-row: span 1; width: 44px; height: 44px; }
  .tile-text { align-self: center; }
  .tile-host { grid-column: 1 / -1; margin-top: 8px; padding-top: 8px; }
  .auth-card { padding: 26px 20px 20px; }
  .codes { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
