@font-face {
  font-family: Vazir;
  src: url('fonts/Vazir-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #173c33;
  --muted: #667a72;
  --green: #176b50;
  --border: #dce6df;
}

* { box-sizing: border-box; }
html { min-height: 100%; overflow-y: auto; scrollbar-gutter: stable; scroll-padding-block: 20px; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  background: #f4f7f3;
  color: var(--ink);
  font: 14px/1.85 Vazir, Tahoma, sans-serif;
}
main { width: 100%; max-width: 760px; margin-inline: auto; padding: 22px 20px max(24px, env(safe-area-inset-bottom)); }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.brand { direction: ltr; font-size: 14px; font-weight: 800; letter-spacing: 1.5px; }
.badge { display: inline-flex; align-items: center; gap: 6px; background: #e6f2e9; border-radius: 20px; padding: 3px 11px; font-size: 11px; font-weight: 600; color: var(--green); }
.badge::before { content: ''; width: 6px; height: 6px; background: #25835f; border-radius: 50%; }
.intro { padding: 22px 0 16px; }
.eyebrow { font-size: 11px; color: var(--green); }
h1 { font-size: clamp(23px, 4.5vw, 29px); line-height: 1.6; font-weight: 750; margin: 4px 0 6px; }
p { color: var(--muted); margin: 7px 0 12px; overflow-wrap: anywhere; }
h2 { font-size: 18px; margin: 14px 0 8px; }
.card { min-width: 0; padding: 22px; border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: 0 6px 24px #173c3305; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; }
.steps span { flex: 1; padding: 7px 4px; border-radius: 7px; background: #f4f6f3; color: #7a8b82; font-size: 12px; text-align: center; }
.steps .active { background: #e8f3ec; color: var(--green); font-weight: 700; }
label { display: block; margin: 12px 0 5px; font-size: 13px; font-weight: 500; }
form > label:first-child { margin-top: 0; }
input, textarea { width: 100%; min-width: 0; padding: 9px 12px; border: 1px solid #d4e0d8; border-radius: 8px; background: #fafcf9; color: var(--ink); font: inherit; }
input { min-height: 44px; }
input::placeholder { color: #99a69f; }
input:focus-visible, textarea:focus-visible { outline: 3px solid #d8eee0; outline-offset: 1px; border-color: #518d70; }
textarea { resize: vertical; }
button { min-height: 42px; padding: 9px 17px; margin-top: 14px; border: 1px solid var(--green); border-radius: 8px; background: var(--green); color: white; cursor: pointer; font: 600 13px/1.7 Vazir, Tahoma, sans-serif; transition: background .15s, box-shadow .15s; }
button:hover { background: #11553e; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #b6dbc7; outline-offset: 3px; }
button:disabled { opacity: .5; cursor: wait; }
form > button { width: 100%; }
.secondary { background: #fff; color: var(--green); }
.secondary:hover { background: #eef6f0; }
.danger { background: #fff; color: #a24037; border-color: #e8cbc6; }
.danger:hover { background: #fff4f2; }
.hint { font-size: 11px; line-height: 1.9; margin: 5px 0 10px; }
.notice { padding: 14px; margin-top: 14px; border: 1px solid #d4e5d9; border-radius: 10px; background: #f2f8f3; }
.notice strong { font-size: 13px; font-weight: 700; }
.notice p { font-size: 12px; margin-block: 7px 10px; }
.notice button { margin-top: 9px; }
.error { color: #a13229; font-size: 12px; white-space: pre-line; }
.error:empty { display: none; }
details { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
summary { cursor: pointer; color: var(--green); font-size: 12px; }
#status { margin: 0 0 10px; font-weight: 600; color: var(--ink); }
#qr { display: block; width: 224px; height: auto; max-width: 100%; margin: 12px auto; background: white; image-rendering: pixelated; }
#qr-help { font-size: 12px; line-height: 1.9; }
.connection-layout:has(#qr:not([hidden])) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.connection-layout:has(#qr:not([hidden])) .notice { margin-top: 0; }
.credentials-stage, .qr-stage { min-width: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); margin-top: 16px; }
code, pre { direction: ltr; font: 12px/1.8 ui-monospace, monospace; overflow-wrap: anywhere; }
#session-id { display: block; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: #fafcf9; }
pre { padding: 12px; border-radius: 8px; background: #f1f5f0; white-space: pre-wrap; }
footer { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; font-size: 11px; color: var(--muted); }
a { color: var(--green); text-underline-offset: 3px; }
[hidden] { display: none !important; }
@media (max-width: 540px) {
  main { padding: 16px 14px max(22px, env(safe-area-inset-bottom)); }
  .intro { padding-top: 18px; }
  .card { padding: 16px; border-radius: 13px; }
  .steps { margin-bottom: 15px; }
  .steps span { font-size: 11px; }
  .connection-layout:has(#qr:not([hidden])) { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  #qr { width: 220px; }
  footer { display: block; }
  footer a { display: inline-block; margin-inline-start: 6px; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
