:root {
  color-scheme: light;
  --brand: #2b1767;
  --brand-strong: #191044;
  --brand-soft: #f0ecfb;
  --accent: #ed1732;
  --accent-strong: #a90016;
  --signal: #22b8e8;
  --ink: #211b2d;
  --muted: #686174;
  --line: #ded9e8;
  --surface: #ffffff;
  --background: #f7f5fc;
  --danger: #a52b2b;
  --danger-soft: #fff0f0;
  --success-soft: #e8f8fd;
  --shadow: 0 10px 28px rgba(37, 20, 83, 0.1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0, rgba(43, 23, 103, 0.12), transparent 18rem),
    var(--background);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button,
select,
input[type="checkbox"] { cursor: pointer; }

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 12px max(30px, env(safe-area-inset-bottom));
}

.app-header { padding: 2px 4px 12px; }

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.brand-logo {
  display: block;
  width: min(52vw, 180px);
  height: auto;
}

.mode-pill {
  padding: 6px 9px;
  border: 1px solid #d8cee9;
  border-radius: 999px;
  background: #fff;
  color: var(--brand);
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

h1,
h2,
p { margin-top: 0; }

h1 {
  max-width: 620px;
  margin-bottom: 7px;
  font-size: clamp(29px, 8.5vw, 46px);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.app-header > p {
  max-width: 580px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.progress {
  position: relative;
  z-index: 5;
  top: 0;
  margin: 0 -2px 10px;
  padding: 6px 2px;
  background: transparent;
}

.progress ol {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
}

.progress ol::before {
  position: absolute;
  z-index: -1;
  top: 14px;
  right: 12.5%;
  left: 12.5%;
  height: 2px;
  background: var(--line);
  content: "";
}

.progress li {
  display: grid;
  justify-items: center;
  gap: 3px;
  color: #80908a;
  font-size: 10px;
  font-weight: 700;
}

.progress li span {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
}

.progress li.active,
.progress li.done { color: var(--brand); }

.progress li.active span {
  border-color: var(--brand);
  background: linear-gradient(145deg, var(--brand), #4f2ba1);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(43, 23, 103, 0.12);
}

.progress li.done span {
  border-color: var(--signal);
  background: #e9f9fe;
}

.flow-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.flow-card { padding: 18px 15px; }

.card-heading { margin-bottom: 16px; }

.step-label {
  display: inline-block;
  margin-bottom: 5px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(22px, 6.5vw, 29px);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.card-heading p,
.field-help,
.contract span,
.app-footer { color: var(--muted); }

.card-heading p {
  margin-bottom: 0;
  line-height: 1.5;
}

.field-group { margin-bottom: 16px; }

.birthdate-fields {
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.birthdate-fields legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 14px;
  font-weight: 760;
}

.birthdate-grid {
  display: grid;
  grid-template-columns: minmax(74px, 0.9fr) minmax(116px, 1.35fr) minmax(66px, 0.75fr);
  gap: 8px;
}

.birthdate-grid label {
  margin-bottom: 6px;
  font-size: 12px;
}

.birthdate-grid input,
.birthdate-grid select {
  min-width: 0;
  padding-right: 8px;
  padding-left: 9px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 760;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.counter {
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid #c2bbcf;
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  border-color: var(--brand);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(34, 184, 232, 0.2);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(165, 43, 43, 0.1);
}

.ssid-field {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid #c2bbcf;
  border-radius: 13px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ssid-field:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(34, 184, 232, 0.2);
}

.ssid-prefix {
  display: flex;
  align-items: center;
  padding: 0 0 0 12px;
  color: var(--brand-strong);
  font-size: 14px;
  font-weight: 850;
  white-space: nowrap;
}

.ssid-field input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding-left: 2px;
  box-shadow: none;
}

.ssid-field input:focus { box-shadow: none; }

.ssid-field:has(input[aria-invalid="true"]) {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(165, 43, 43, 0.1);
}

.field-help {
  display: block;
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.4;
}

.field-error {
  display: block;
  margin-top: 7px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.4;
}

.primary-action,
.secondary-action,
.visibility-toggle {
  min-height: 49px;
  border-radius: 13px;
  font-weight: 800;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.primary-action {
  width: 100%;
  padding: 13px 18px;
  border: 1px solid var(--accent);
  background: linear-gradient(135deg, #fa3048, var(--accent-strong));
  color: #fff;
  font-size: 16px;
}

.primary-action:hover { background: var(--accent-strong); }

.secondary-action {
  padding: 13px 18px;
  border: 1px solid #bcb4ca;
  background: #fff;
  color: var(--brand-strong);
}

button:active { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: 0.55; }

.form-actions {
  display: grid;
  grid-template-columns: minmax(100px, 0.7fr) 1.3fr;
  gap: 10px;
  margin-top: 20px;
}

.form-actions .primary-action { width: auto; }
.full-width { width: 100%; margin-top: 20px; }

.contract-list {
  display: grid;
  gap: 9px;
}

.contract {
  position: relative;
  width: 100%;
  padding: 14px 40px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 4px 13px rgba(37, 20, 83, 0.05);
}

.contract::after {
  position: absolute;
  top: 50%;
  right: 18px;
  color: var(--brand);
  content: ">";
  font-size: 22px;
  transform: translateY(-50%);
}

.contract:hover,
.contract:focus-visible {
  border-color: var(--brand);
  outline: 0;
  background: #faf8ff;
}

.contract strong,
.contract span { display: block; }
.contract strong { margin-bottom: 8px; font-size: 16px; }
.contract-address { color: var(--ink) !important; font-weight: 700; }
.contract span { margin-top: 4px; font-size: 13px; line-height: 1.4; }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.meta-pill {
  display: inline-flex !important;
  width: fit-content;
  margin: 0 !important;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong) !important;
  font-size: 11px !important;
  font-weight: 750;
}

.selection {
  margin-bottom: 17px;
  padding: 13px;
  border: 1px solid #d4c9eb;
  border-radius: 13px;
  background: var(--brand-soft);
}

.selection strong,
.selection span { display: block; }
.selection strong { margin-bottom: 6px; }
.selection span { margin-top: 3px; color: #5c5272; font-size: 13px; }

.password-field { position: relative; }
.password-field input { padding-right: 90px; }

.visibility-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 13px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 2px 0 17px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fcfbff;
  text-transform: none;
}

.switch-row strong,
.switch-row small { display: block; }
.switch-row small { margin-top: 4px; color: var(--muted); font-weight: 400; line-height: 1.35; }

.switch-row input {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: #b6c1bd;
  transition: background 0.2s;
}

.switch-row input::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  content: "";
  transition: transform 0.2s;
}

.switch-row input:checked { background: var(--signal); }
.switch-row input:checked::after { transform: translateX(20px); }

.privacy-note {
  display: grid;
  gap: 4px;
  padding: 14px 15px;
  border-radius: 13px;
  background: #f3effb;
  color: #4b376f;
  font-size: 13px;
  line-height: 1.4;
}

.result-card {
  padding: 24px 18px;
  text-align: center;
}

.result-mark {
  display: grid;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--brand);
  font-size: 28px;
  font-weight: 900;
}

.result-card p { color: var(--muted); line-height: 1.5; }
.result-card .primary-action { margin-top: 12px; }

.error-banner {
  position: fixed;
  z-index: 30;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  width: min(calc(100% - 24px), 680px);
  margin: 0;
  padding: 15px 16px;
  border: 1px solid #f0bcbc;
  border-radius: 14px;
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: 0 12px 32px rgba(87, 12, 24, 0.2);
  transform: translateX(-50%);
}

.error-banner > strong,
.error-banner > span { display: block; }
.error-banner span { margin-top: 4px; line-height: 1.4; }

.identity-support {
  margin-top: 10px !important;
  padding-top: 9px;
  border-top: 1px solid #e5b4bc;
  font-size: 13px;
}

.identity-copy,
.phone-label {
  display: block;
}

.phone-label {
  margin-top: 8px;
  font-weight: 800;
}

.phone-links {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  white-space: nowrap;
}

.identity-support a {
  display: inline-block;
  margin: 0;
  color: #761321;
  font-size: 15px;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.phone-separator {
  display: inline !important;
  color: #a75a65;
  font-weight: 700;
}

@media (max-width: 359px) {
  .phone-links {
    gap: 6px;
  }

  .identity-support a {
    font-size: 14px;
  }
}

.app-footer {
  padding: 18px 10px 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}

.hidden { display: none !important; }

@media (max-width: 719px) {
  .compact-flow .app-header {
    padding-bottom: 2px;
  }

  .compact-flow .app-header h1,
  .compact-flow .app-header > p,
  .compact-flow .app-footer {
    display: none;
  }

  .compact-flow .brand-row {
    margin-bottom: 0;
  }

  .compact-flow .brand-logo {
    width: 128px;
  }

  .compact-flow .mode-pill {
    padding: 5px 8px;
    font-size: 10px;
  }

  #change-panel {
    padding: 14px 13px;
  }

  #change-panel .card-heading {
    margin-bottom: 10px;
  }

  #change-panel .card-heading p {
    display: none;
  }

  #change-panel .selection {
    margin-bottom: 11px;
    padding: 10px 12px;
  }

  #change-panel .field-group {
    margin-bottom: 11px;
  }

  #change-panel input {
    min-height: 46px;
    padding-top: 9px;
    padding-bottom: 9px;
  }

  #change-panel .field-help,
  #change-panel .field-error {
    margin-top: 4px;
    font-size: 11px;
  }

  #change-panel .switch-row {
    margin-bottom: 11px;
    padding: 9px 11px;
  }

  #change-panel .privacy-note {
    padding: 10px 12px;
    font-size: 12px;
  }

  #change-panel .form-actions {
    margin-top: 12px;
  }
}

@media (min-width: 720px) {
  .app-shell { padding: 30px 24px 60px; }
  .app-header { padding: 0 10px 20px; }
  .flow-card { padding: 28px 32px 32px; }
  .result-card { padding: 42px; }
  .primary-action { width: auto; min-width: 190px; }
  #lookup-form > .primary-action { width: 100%; }
  .contract-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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