:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --surface: rgba(255,255,255,.94);
  --surface-solid: #fff;
  --surface-muted: #f7f8fa;
  --text: #101319;
  --muted: #6d7480;
  --line: #e3e6ea;
  --line-strong: #d7dbe1;
  --accent: #111318;
  --accent-contrast: #fff;
  --accent-soft: #eef0f3;
  --success: #247655;
  --success-bg: #edf8f3;
  --warning: #8c5f16;
  --warning-bg: #fff8e8;
  --shadow: 0 18px 45px rgba(17,24,39,.065), 0 2px 8px rgba(17,24,39,.035);
  --shadow-small: 0 8px 24px rgba(17,24,39,.055), 0 1px 4px rgba(17,24,39,.03);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 13px;
}

* { box-sizing: border-box; }
html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -6%, rgba(255,255,255,.98), transparent 32rem),
    radial-gradient(circle at 95% 5%, rgba(224,228,234,.82), transparent 30rem),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

.page-shell {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 780;
  letter-spacing: -.025em;
  font-size: 17px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
}
.brand-mark svg { width: 22px; height: 22px; fill: var(--accent-contrast); }
.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.62);
  color: #626a76;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.privacy-pill svg { width: 15px; height: 15px; fill: currentColor; }
.topbar-actions {
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  min-width:0;
}
.lock-button {
  min-height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  padding:0 11px;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(255,255,255,.62);
  color:#626a76;
  font:inherit;
  font-size:11px;
  font-weight:720;
  white-space:nowrap;
}
.lock-button svg { width:14px; height:14px; fill:currentColor; }
.lock-button:disabled { opacity:.55; cursor:wait; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(350px, .92fr);
  grid-template-areas:
    "create preview"
    "appearance preview"
    "privacy preview";
  gap: 16px 22px;
  align-items: start;
}
.card {
  background: var(--surface);
  border: 1px solid rgba(220,224,229,.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.create-card { grid-area: create; border-radius: var(--radius-xl); padding: 28px; }
.appearance-card { grid-area: appearance; border-radius: var(--radius-xl); padding: 24px 28px 28px; }
.preview-card { grid-area: preview; border-radius: var(--radius-xl); padding: 26px; position: sticky; top: 16px; }
.privacy-card { grid-area: privacy; border-radius: 18px; padding: 15px 17px; display: flex; gap: 13px; align-items: flex-start; }

.section-heading,
.preview-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}
.section-heading > div,
.preview-title-wrap > div { min-width: 0; }
.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--accent-soft);
  color: #5f6671;
  font-size: 11px;
  font-weight: 850;
  margin-top: 1px;
}
.section-heading h1 {
  margin: 4px 0 7px;
  font-size: clamp(28px, 4vw, 36px);
  line-height: 1.03;
  letter-spacing: -.045em;
}
.section-heading p,
.appearance-heading p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 13px; }
.eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #858c96;
}

.type-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  margin: 24px 0 21px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-muted);
}
.type-tab {
  min-width: 0;
  min-height: 40px;
  border: 1px solid transparent;
  background: transparent;
  color: #6c737e;
  border-radius: 10px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.type-tab:hover { color: #343942; background: rgba(255,255,255,.65); }
.type-tab:active { transform: scale(.97); }
.type-tab.active {
  background: var(--surface-solid);
  color: var(--text);
  border-color: var(--line);
  box-shadow: 0 3px 10px rgba(17,24,39,.06);
}

.dynamic-fields { min-height: 108px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-grid .span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span:first-child { color: #484f59; font-size: 12px; font-weight: 740; }
.field input:not([type="color"]),
.field textarea,
.field select {
  width: 100%;
  min-height: 47px;
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
  color: var(--text);
  border-radius: var(--radius-md);
  outline: none;
  padding: 11px 12px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.field textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: #9ea4ad;
  box-shadow: 0 0 0 4px rgba(17,19,24,.055);
}
.field input::placeholder, .field textarea::placeholder { color: #a1a6ae; }
.helper { margin: 6px 0 0; font-size: 11px; color: #9096a0; line-height: 1.45; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 2px;
  color: #444b55;
  font-size: 13px;
  font-weight: 650;
}
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--accent); }

.appearance-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 19px;
}
.appearance-heading h2 {
  margin: 3px 0 4px;
  font-size: 19px;
  letter-spacing: -.025em;
}
.text-button {
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: #646b76;
  border-radius: 10px;
  min-height: 36px;
  padding: 0 11px;
  font-size: 11px;
  font-weight: 760;
}
.text-button:hover { color: var(--text); background: var(--surface-solid); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.color-control {
  display: grid;
  grid-template-columns: 44px 1fr;
  border: 1px solid var(--line-strong);
  background: var(--surface-solid);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 47px;
}
.color-control input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 45px;
  padding: 8px 4px 8px 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.color-control input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-control input[type="color"]::-webkit-color-swatch,
.color-control input[type="color"]::-moz-color-swatch { border: 0; border-radius: 7px; }
.color-control input[type="text"] {
  min-height: 45px !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding-left: 9px !important;
  box-shadow: none !important;
  text-transform: uppercase;
}
.notice {
  margin-top: 17px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 13px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.45;
}
.notice svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; fill: currentColor; }
.notice.warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #f2dfb7; }

.preview-topline { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.preview-topline h2 { margin: 3px 0 0; font-size: 20px; letter-spacing: -.03em; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 11px;
  font-weight: 780;
  white-space: nowrap;
}
.status-badge span { width: 7px; height: 7px; border-radius: 50%; background: #35a576; box-shadow: 0 0 0 3px rgba(53,165,118,.12); }
.status-badge.invalid { background: var(--accent-soft); color: #7b818b; }
.status-badge.invalid span { background: #9da3ab; box-shadow: none; }
.qr-stage {
  width: min(100%, 390px);
  aspect-ratio: 1;
  margin: 24px auto 16px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255,255,255,.82), transparent 58%),
    #eff1f4;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 25px);
  position: relative;
  overflow: hidden;
  border: 1px solid #e6e8ec;
}
#qr-canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 342px;
  max-height: 342px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(18,23,31,.1);
  image-rendering: crisp-edges;
  position: relative;
  z-index: 1;
}
.empty-preview {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 30px;
  color: #858c96;
}
.empty-preview svg { width: 46px; height: 46px; fill: #a8adb5; }
.empty-preview p { margin: 0; font-size: 13px; }
.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #858c96;
  font-size: 11px;
  margin-bottom: 14px;
}
.preview-meta span:first-child { color: #555c67; font-weight: 760; }
.download-actions { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 8px; }
.button {
  min-height: 47px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  font-weight: 740;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  transition: transform .14s ease, background .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.button:active { transform: scale(.98); }
.button.primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  box-shadow: 0 7px 18px rgba(17,19,24,.14);
}
.button.primary:hover { filter: brightness(1.12); }
.button.secondary { background: var(--surface-solid); color: #363c45; }
.button.secondary:hover { background: var(--surface-muted); border-color: #cdd1d6; }
.button svg { width: 16px; height: 16px; fill: currentColor; }
.button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.scan-tip {
  margin-top: 11px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  color: #8c929c;
  font-size: 10.5px;
  line-height: 1.4;
  text-align: center;
}
.scan-tip svg { width: 14px; height: 14px; flex: 0 0 auto; margin-top: 1px; fill: currentColor; }

.mini-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center; flex: 0 0 auto; }
.mini-icon svg { width: 18px; height: 18px; fill: #626a75; }
.privacy-card strong { display: block; font-size: 12px; margin-bottom: 3px; }
.privacy-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
footer { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #9298a1; font-size: 11px; padding: 0 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 20;
  transform: translate(-50%, 18px);
  background: #111318;
  color: #fff;
  border-radius: 12px;
  padding: 11px 14px;
  box-shadow: 0 12px 30px rgba(17,19,24,.25);
  font-size: 12px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid #737983;
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .page-shell { width: min(700px, calc(100% - 28px)); }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "create"
      "preview"
      "appearance"
      "privacy";
    gap: 12px;
  }
  .preview-card { position: static; }
  .qr-stage { width: min(100%, 360px); }
}

@media (max-width: 560px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .page-shell { width: 100%; padding-inline: 12px; }
  .topbar {
    min-height: 60px;
    height: calc(60px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    padding-inline: 2px;
    gap: 10px;
  }
  .brand { font-size: 16px; gap: 9px; }
  .brand-mark { width: 31px; height: 31px; border-radius: 9px; }
  .brand-mark svg { width: 20px; height: 20px; }
  .topbar-actions { gap:6px; }
  .privacy-pill { min-height: 44px; padding: 0 10px; font-size: 10.5px; background: rgba(255,255,255,.74); }
  .privacy-pill svg { width: 14px; height: 14px; }
  .lock-button { min-width:44px; min-height:44px; padding:0 10px; background:rgba(255,255,255,.74); }

  .workspace { gap: 10px; }
  .create-card, .preview-card, .appearance-card { padding: 17px; border-radius: 19px; }
  .privacy-card { padding: 14px 15px; border-radius: 16px; }
  .card {
    box-shadow: var(--shadow-small);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .section-heading, .preview-title-wrap { gap: 10px; }
  .step-badge { width: 25px; height: 25px; border-radius: 8px; font-size: 10px; }
  .section-heading h1 { margin: 3px 0 5px; font-size: 27px; line-height: 1.04; }
  .section-heading p, .appearance-heading p { font-size: 12.5px; line-height: 1.42; }
  .eyebrow { font-size: 9px; }

  .type-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 18px 0 17px;
    padding: 5px;
    border-radius: 14px;
  }
  .type-tab { min-height: 42px; padding: 0 5px; border-radius: 10px; font-size: 12px; }

  .dynamic-fields { min-height: 0; }
  .field-grid { grid-template-columns: 1fr; gap: 13px; }
  .field-grid .span-2 { grid-column: auto; }
  .field { gap: 7px; }
  .field > span:first-child { font-size: 12.5px; }
  .field input:not([type="color"]), .field textarea, .field select {
    min-height: 50px;
    border-radius: 13px;
    padding: 12px 13px;
    font-size: 16px;
  }
  .field textarea { min-height: 112px; }
  .helper { margin-top: 4px; font-size: 10.5px; }
  .checkbox-row { min-height: 48px; padding: 2px 0; font-size: 14px; }
  .checkbox-row input { width: 19px; height: 19px; }

  .preview-topline { align-items: center; }
  .preview-topline h2 { font-size: 18px; }
  .status-badge { padding: 7px 9px; }
  .qr-stage {
    width: min(100%, 310px);
    margin: 17px auto 13px;
    padding: 15px;
    border-radius: 18px;
  }
  #qr-canvas { border-radius: 10px; }
  .preview-meta { margin-bottom: 12px; font-size: 10.5px; }
  .download-actions { grid-template-columns: 1fr 1fr; gap: 8px; }
  .download-actions .button.primary { grid-column: 1 / -1; }
  .button { min-height: 50px; border-radius: 13px; font-size: 13px; }
  .copy-button { width: auto; }
  .scan-tip { margin-top: 10px; font-size: 10.5px; }

  .appearance-heading { margin-bottom: 16px; align-items: center; }
  .appearance-heading h2 { font-size: 18px; }
  .appearance-heading p { max-width: 220px; }
  .text-button { min-height: 36px; flex: 0 0 auto; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 9px; }
  .settings-grid .color-field { grid-column: 1 / -1; }
  .color-control { grid-template-columns: 50px 1fr; min-height: 50px; border-radius: 13px; }
  .color-control input[type="color"] { width: 50px; height: 48px; padding: 8px 5px 8px 8px; }
  .color-control input[type="text"] { min-height: 48px !important; font-size: 16px !important; }
  .notice { margin-top: 15px; }

  footer { min-height: 55px; padding: 0 4px max(3px, env(safe-area-inset-bottom)); font-size: 10px; }
  footer span:last-child { text-align: right; }
  .toast { width: calc(100% - 28px); max-width: 360px; bottom: max(18px, env(safe-area-inset-bottom)); text-align: center; }
}

@media (max-width: 370px) {
  .page-shell { padding-inline: 9px; }
  .topbar { height: 57px; }
  .privacy-pill { width: 44px; padding: 0; justify-content: center; font-size: 0; }
  .privacy-pill span { display:none; }
  .privacy-pill svg { width: 16px; height: 16px; }
  .lock-button { width:44px; padding:0; }
  .lock-button span { display:none; }
  .create-card, .preview-card, .appearance-card { padding: 15px; border-radius: 17px; }
  .section-heading h1 { font-size: 25px; }
  .type-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .color-field { grid-column: auto; }
  .appearance-heading { align-items: flex-start; }
  .qr-stage { width: min(100%, 286px); padding: 13px; }
  .preview-meta { align-items: flex-start; }
  .preview-meta span:last-child { text-align: right; }
  footer span:last-child { display: none; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --surface: rgba(22,25,31,.94);
    --surface-solid: #1b1f26;
    --surface-muted: #171a20;
    --text: #f5f7fa;
    --muted: #9ba3af;
    --line: #2a2f38;
    --line-strong: #343a45;
    --accent: #f5f7fa;
    --accent-contrast: #101319;
    --accent-soft: #242932;
    --success: #78d3aa;
    --success-bg: #173326;
    --warning: #e1b968;
    --warning-bg: #312a19;
    --shadow: 0 18px 50px rgba(0,0,0,.2), 0 2px 8px rgba(0,0,0,.14);
    --shadow-small: 0 9px 28px rgba(0,0,0,.18);
  }
  body {
    background:
      radial-gradient(circle at 12% -5%, rgba(50,57,68,.45), transparent 30rem),
      radial-gradient(circle at 96% 0%, rgba(34,40,49,.5), transparent 28rem),
      var(--bg);
  }
  .card { border-color: rgba(53,59,69,.92); }
  .privacy-pill { background: rgba(29,33,40,.72); color: #a9b0ba; }
  .field > span:first-child, .checkbox-row { color: #c5cad1; }
  .field input::placeholder, .field textarea::placeholder { color: #6f7782; }
  .type-tab { color: #9ba2ad; }
  .lock-button { background:rgba(27,31,38,.85); color:#c8ced6; border-color:#343a45; }
  .type-tab:hover { color: #e7e9ed; background: rgba(255,255,255,.04); }
  .type-tab.active { background: #242932; color: #f6f7f9; border-color: #353b46; box-shadow: none; }
  .text-button { color: #b1b7c0; }
  .qr-stage {
    background: radial-gradient(circle at 50% 30%, rgba(255,255,255,.07), transparent 58%), #15191f;
    border-color: #2b3039;
  }
  .preview-meta span:first-child { color: #c0c5cc; }
  .button.secondary { color: #e2e5e9; }
  .mini-icon svg { fill: #a8afb9; }
  .notice.warning { border-color: #4e4122; }
}

@media (hover: none) and (pointer: coarse) {
  button, select, input[type="checkbox"], input[type="color"] { touch-action: manipulation; }
  .type-tab { min-height: 44px; }
  .text-button { min-height: 44px; padding-inline: 13px; }
  .formal-toggle { width: 44px; height: 44px; right: 5px; }
  .formal-submit { min-height: 56px; }
  .type-tab:hover { background: transparent; color: inherit; }
  .type-tab.active:hover { background: var(--surface-solid); color: var(--text); }
  .button.primary:hover { filter: none; }
  .button.secondary:hover { background: var(--surface-solid); border-color: var(--line-strong); }
  .text-button:hover { color: #646b76; background: var(--surface-muted); }
  .formal-toggle:hover { background: transparent; }
  .formal-submit:hover:not(:disabled) { filter: none; }
}

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

/* Formal server-access portal */
.auth-page {
  min-height:100vh;
  min-height:100dvh;
  margin:0;
  background:#eef1f4;
  color:#14171b;
}
.formal-access {
  min-height:100vh;
  min-height:100dvh;
  display:grid;
  place-items:center;
  padding:clamp(20px,4vw,48px);
  padding-top:max(clamp(20px,4vw,48px), env(safe-area-inset-top));
  padding-bottom:max(clamp(20px,4vw,48px), env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% -15%, rgba(255,255,255,.95), rgba(255,255,255,0) 40rem),
    linear-gradient(180deg,#f3f5f7 0%,#e9edf1 100%);
}
.formal-access-card {
  width:min(100%, 520px);
  overflow:hidden;
  border:1px solid #d6dbe1;
  border-radius:22px;
  background:rgba(255,255,255,.96);
  box-shadow:0 24px 60px rgba(26,34,44,.10),0 4px 14px rgba(26,34,44,.05);
}
.formal-access-header {
  min-height:76px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:17px 20px;
  border-bottom:1px solid #e8ebef;
  background:#fbfcfd;
}
.formal-brand { display:flex; align-items:center; gap:11px; min-width:0; }
.formal-brand-mark {
  width:38px; height:38px; flex:0 0 38px;
  display:grid; place-items:center;
  border-radius:10px; background:#14171b;
}
.formal-brand-mark svg { width:22px; height:22px; fill:#fff; }
.formal-brand div { display:grid; gap:2px; min-width:0; }
.formal-brand strong { font-size:14px; line-height:1.1; letter-spacing:-.01em; }
.formal-brand span { color:#7b838e; font-size:11.5px; line-height:1.2; }
.formal-status {
  display:inline-flex; align-items:center; gap:7px;
  padding:7px 9px; border:1px solid #dfe3e8; border-radius:999px;
  background:#fff; color:#58616d; font-size:10.5px; font-weight:750;
  letter-spacing:.03em; text-transform:uppercase; white-space:nowrap;
}
.formal-status i { width:7px; height:7px; border-radius:50%; background:#218739; box-shadow:0 0 0 3px rgba(33,135,57,.10); }
.formal-access-body { padding:34px 32px 30px; }
.formal-lock {
  width:48px; height:48px; display:grid; place-items:center;
  margin-bottom:21px; border:1px solid #dfe3e7; border-radius:13px;
  background:#f7f8fa; box-shadow:inset 0 1px 0 #fff;
}
.formal-lock svg { width:23px; height:23px; fill:#343a42; }
.formal-copy { max-width:410px; }
.formal-kicker {
  margin:0 0 7px; color:#69727e; font-size:10.5px; font-weight:800;
  letter-spacing:.095em; text-transform:uppercase;
}
.formal-copy h1 { margin:0; color:#111419; font-size:29px; line-height:1.08; letter-spacing:-.035em; }
.formal-copy > p:last-child { margin:11px 0 0; color:#69717c; font-size:13.5px; line-height:1.55; }
.formal-form { margin-top:27px; }
.formal-field-head { display:flex; align-items:end; justify-content:space-between; gap:10px; margin-bottom:8px; }
.formal-field-head label { color:#30363e; font-size:12px; font-weight:750; }
.formal-field-head span { color:#8a929c; font-size:10.5px; }
.formal-input-wrap { position:relative; }
.formal-input-wrap input {
  width:100%; min-height:54px; box-sizing:border-box;
  padding:0 50px 0 15px;
  border:1px solid #cfd5db; border-radius:12px;
  outline:0; background:#fff; color:#16191d;
  font:inherit; font-size:16px; font-weight:600; letter-spacing:.025em;
  transition:border-color .15s ease,box-shadow .15s ease,background .15s ease;
}
.formal-input-wrap input::placeholder { color:#9ba2ab; font-weight:450; letter-spacing:0; }
.formal-input-wrap input:focus { border-color:#5d6670; box-shadow:0 0 0 4px rgba(24,28,33,.07); }
.formal-toggle {
  position:absolute; right:7px; top:50%; transform:translateY(-50%);
  width:40px; height:40px; display:grid; place-items:center;
  border:0; border-radius:9px; background:transparent; cursor:pointer;
}
.formal-toggle:hover { background:#f2f4f6; }
.formal-toggle svg { width:19px; height:19px; fill:#707986; }
.formal-help { margin:7px 1px 0; color:#8b929b; font-size:10.5px; line-height:1.35; }
.formal-error { min-height:19px; margin:7px 1px 2px; color:#b42318; font-size:11.5px; font-weight:650; line-height:1.35; }
.formal-submit {
  width:100%; min-height:54px; display:flex; align-items:center; justify-content:center; gap:8px;
  margin-top:5px; border:0; border-radius:12px;
  background:#14171b; color:#fff; font:inherit; font-size:13px; font-weight:760;
  cursor:pointer; box-shadow:0 7px 18px rgba(20,23,27,.15);
  transition:transform .14s ease,filter .14s ease,opacity .14s ease;
}
.formal-submit svg { width:17px; height:17px; fill:currentColor; }
.formal-submit:hover:not(:disabled) { filter:brightness(1.12); }
.formal-submit:active:not(:disabled) { transform:translateY(1px); }
.formal-submit:disabled { opacity:.65; cursor:wait; }
.formal-access-footer {
  min-height:49px; display:flex; align-items:center; justify-content:center; gap:9px;
  padding:0 18px; border-top:1px solid #e8ebef; background:#fafbfc;
  color:#8a929c; font-size:10px; font-weight:600; letter-spacing:.02em;
}
.formal-footer-dot { width:3px; height:3px; border-radius:50%; background:#b1b7bf; }
.formal-form.access-denied .formal-input-wrap { animation:access-shake .30s ease; }
.formal-form.access-denied .formal-input-wrap input { border-color:#c9342d; box-shadow:0 0 0 4px rgba(201,52,45,.07); }
html.access-success .formal-access-card { opacity:.65; transform:scale(.995); transition:opacity .15s ease,transform .15s ease; }

@media (max-width:560px) {
  html { min-width:0; }
  body.auth-page {
    width:100%;
    min-width:0;
    min-height:100vh;
    min-height:100svh;
    overflow-x:hidden;
  }
  .formal-access {
    width:100%;
    min-height:100vh;
    min-height:100svh;
    display:block;
    padding-top:max(14px, env(safe-area-inset-top));
    padding-right:max(12px, env(safe-area-inset-right));
    padding-bottom:max(18px, env(safe-area-inset-bottom));
    padding-left:max(12px, env(safe-area-inset-left));
  }
  .formal-access-card {
    width:100%;
    max-width:440px;
    margin:0 auto;
    border-radius:20px;
  }
  .formal-access-header {
    min-height:68px;
    gap:10px;
    padding:13px 14px;
  }
  .formal-brand { gap:10px; }
  .formal-brand-mark { width:36px; height:36px; flex-basis:36px; }
  .formal-brand strong { font-size:13.5px; }
  .formal-brand span { font-size:11px; }
  .formal-status { flex:0 0 auto; padding:6px 8px; font-size:9px; }
  .formal-access-body { padding:25px 18px 23px; }
  .formal-lock { width:44px; height:44px; margin-bottom:17px; }
  .formal-kicker { margin-bottom:6px; }
  .formal-copy h1 { font-size:clamp(24px, 7.1vw, 27px); line-height:1.08; }
  .formal-copy > p:last-child { margin-top:9px; font-size:13px; line-height:1.5; }
  .formal-form { margin-top:22px; }
  .formal-field-head { align-items:center; }
  .formal-input-wrap input { min-height:54px; font-size:16px; }
  .formal-submit { min-height:54px; }
  .formal-access-footer {
    min-height:46px;
    padding:10px 14px;
    gap:7px;
    flex-wrap:wrap;
    line-height:1.25;
    text-align:center;
  }
}

@media (max-width:370px) {
  .formal-status { display:none; }
  .formal-access-header { padding-inline:13px; }
  .formal-access-body { padding-inline:16px; }
  .formal-copy h1 { font-size:24px; }
  .formal-field-head span { display:none; }
  .formal-access-footer { font-size:9.5px; }
}

@media (max-height:650px) and (max-width:560px) {
  .formal-access { padding-top:max(8px, env(safe-area-inset-top)); padding-bottom:max(10px, env(safe-area-inset-bottom)); }
  .formal-access-header { min-height:60px; padding-block:10px; }
  .formal-access-body { padding-top:19px; padding-bottom:19px; }
  .formal-lock { width:40px; height:40px; margin-bottom:13px; }
  .formal-copy > p:last-child { margin-top:7px; }
  .formal-form { margin-top:17px; }
  .formal-access-footer { min-height:40px; padding-block:8px; }
}

@media (prefers-color-scheme:dark) {
  .auth-page { background:#0b0d10; color:#eef1f4; }
  .formal-access {
    background:
      radial-gradient(circle at 50% -15%, rgba(54,61,70,.30), rgba(54,61,70,0) 38rem),
      linear-gradient(180deg,#101318 0%,#0b0d10 100%);
  }
  .formal-access-card { background:#15191e; border-color:#2c323a; box-shadow:0 28px 70px rgba(0,0,0,.34); }
  .formal-access-header,.formal-access-footer { background:#12161a; border-color:#292f36; }
  .formal-brand strong,.formal-copy h1 { color:#f4f6f8; }
  .formal-brand span,.formal-copy > p:last-child,.formal-help,.formal-access-footer { color:#8f98a3; }
  .formal-status { background:#181d22; border-color:#303740; color:#aeb5be; }
  .formal-lock { background:#1b2026; border-color:#303740; box-shadow:none; }
  .formal-lock svg { fill:#cbd0d7; }
  .formal-kicker { color:#8e97a2; }
  .formal-field-head label { color:#cbd0d7; }
  .formal-field-head span { color:#818a95; }
  .formal-input-wrap input { background:#101419; border-color:#373e47; color:#f3f5f7; }
  .formal-input-wrap input:focus { border-color:#747e89; box-shadow:0 0 0 4px rgba(255,255,255,.055); }
  .formal-toggle:hover { background:#20262d; }
  .formal-submit { background:#eef1f4; color:#14171b; box-shadow:none; }
  .formal-footer-dot { background:#59616b; }
}

/* iOS touch safeguards. These intentionally do not resize/reposition the access card. */
@media (hover: none) and (pointer: coarse) {
  .formal-toggle { width:44px; height:44px; right:5px; touch-action:manipulation; }
  .formal-toggle:hover { background:transparent; }
  .formal-submit { min-height:56px; touch-action:manipulation; }
  .formal-submit:hover:not(:disabled) { filter:none; }
}
