:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, .86);
  --text: #111827;
  --muted: #64748b;
  --border: rgba(15, 23, 42, .09);
  --accent: #2764ff;
  --accent-pressed: #164ee2;
  --accent-soft: rgba(39, 100, 255, .11);
  --success: #12a150;
  --shadow: 0 24px 70px rgba(18, 33, 62, .12);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -15%, var(--accent-soft), transparent 42%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

.shell {
  width: min(100%, 470px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: auto;
  padding: max(48px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  display: grid;
  align-content: center;
  gap: 20px;
}

.card {
  padding: 36px 24px 28px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}

.brand-mark {
  width: 70px;
  height: 70px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 21px;
  color: white;
  background: linear-gradient(145deg, #4383ff, #174be0);
  box-shadow: 0 14px 30px rgba(39, 100, 255, .28);
}

.brand-mark svg { width: 40px; fill: currentColor; }
.brand-mark svg path:last-child { opacity: .9; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .14em;
}

h1 { margin: 0; font-size: clamp(30px, 9vw, 38px); letter-spacing: -.045em; }
h2 { margin: 28px 0 10px; font-size: 19px; letter-spacing: -.02em; }
.view { margin-top: 30px; }
.muted { margin: 0; color: var(--muted); line-height: 1.5; }

.statuses {
  padding: 17px 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  text-align: left;
}

.status { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.status + .status { margin-top: 11px; }
.status span { display: inline-block; width: 8px; height: 8px; margin-right: 9px; border-radius: 50%; background: #94a3b8; }
.status.ok { color: var(--text); }
.status.ok span { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 16%, transparent); }

.hint {
  margin-top: 16px;
  padding: 13px 15px;
  color: var(--muted);
  border-radius: 15px;
  background: var(--accent-soft);
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}

.actions { display: grid; gap: 12px; margin-top: 22px; }

.button {
  width: 100%;
  min-height: 54px;
  padding: 13px 18px;
  border: 0;
  border-radius: 16px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, opacity .12s ease, background .12s ease;
}

.button:active:not(:disabled) { transform: scale(.985); }
.button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 32%, transparent); outline-offset: 3px; }
.button:disabled { cursor: default; opacity: .46; }
.button.primary { color: #fff; background: var(--accent); }
.button.primary:hover:not(:disabled) { background: var(--accent-pressed); }
.button.secondary { color: var(--accent); background: var(--accent-soft); }
#enrollment-view .button { margin-top: 22px; }

.history {
  margin-top: 30px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
  text-align: left;
}

.history h2 { margin: 0 0 14px; }
.history-status { padding: 14px 0 2px; font-size: 14px; }
.history-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }

.history-item {
  position: relative;
  overflow: hidden;
  padding: 15px 15px 14px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.history-item::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--level-color, var(--accent));
  content: "";
}

.history-item.level-success { --level-color: var(--success); }
.history-item.level-warning { --level-color: #d98100; }
.history-item.level-error { --level-color: #c43232; }
.history-item-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.history-item h3 { margin: 0; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }

.level-badge {
  flex: none;
  padding: 3px 7px;
  color: var(--level-color, var(--accent));
  border-radius: 999px;
  background: color-mix(in srgb, var(--level-color, var(--accent)) 12%, transparent);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.4;
}

.history-message {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.history-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.history-meta > * + *::before { margin-right: 12px; content: "·"; }
.history-meta a { color: var(--accent); font-weight: 700; text-underline-offset: 2px; }
.history-meta a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.feedback { min-height: 20px; margin: 18px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.feedback.error { color: #c43232; }
.privacy { margin: 0; color: var(--muted); font-size: 12px; text-align: center; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1018;
    --surface: rgba(20, 28, 40, .9);
    --text: #f7f9fc;
    --muted: #9aa8bc;
    --border: rgba(255, 255, 255, .09);
    --accent: #6d97ff;
    --accent-pressed: #537ee9;
    --accent-soft: rgba(87, 133, 255, .15);
    --success: #46cf79;
    --shadow: 0 26px 75px rgba(0, 0, 0, .34);
  }
}

@media (max-height: 650px) {
  .shell { align-content: start; padding-top: max(24px, env(safe-area-inset-top)); }
  .card { padding-top: 26px; }
  .brand-mark { width: 58px; height: 58px; margin-bottom: 14px; }
  .brand-mark svg { width: 34px; }
  .view { margin-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
}
