:root {
  --bg: #f6f9fb;
  --panel: #ffffff;
  --text: #16212a;
  --muted: #5f6f7b;
  --accent: #2b6f9c;
  --accent-soft: #e7f1f8;
  --green: #2f8f6e;
  --green-soft: #e4f5ee;
  --line: #e3ebf2;
  --shadow: 0 18px 40px rgba(20, 35, 50, 0.08);
  --radius: 18px;
  --radius-lg: 24px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Vazirmatn", "IBM Plex Sans", "Manrope", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fbfdff 0%, var(--bg) 55%, #f3f6f9 100%);
  min-height: 100vh;
}

body.rtl {
  direction: rtl;
  font-family: "Vazirmatn", "Tahoma", "Arial", "IBM Plex Sans", "Manrope", sans-serif;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 5%, rgba(45, 122, 160, 0.12), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(70, 150, 120, 0.12), transparent 45%),
    radial-gradient(circle at 50% 85%, rgba(70, 120, 170, 0.08), transparent 50%);
}

.page {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.trust-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title actions"
    "descriptor actions";
  align-items: center;
  gap: 10px 16px;
}

.trust-copy {
  grid-area: title;
}

.header-actions {
  grid-area: actions;
  display: grid;
  justify-items: end;
  gap: 6px;
}

.header-controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  row-gap: 6px;
}

.trust-copy .title {
  margin: 0;
  font-weight: 650;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.trust-copy .subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.descriptor {
  margin: 4px 0 0;
  color: #7a8893;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  line-height: 1.3;
  grid-area: descriptor;
}

.chip {
  background: rgba(43, 111, 156, 0.14);
  color: #1e4f73;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  font-family: inherit;
  line-height: 1;
  border: 1px solid rgba(43, 111, 156, 0.35);
  box-shadow: 0 10px 22px rgba(43, 111, 156, 0.18);
}

.chip-note {
  font-size: 0.7rem;
  color: var(--muted);
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: #f0f4f8;
  border: 1px solid #d7e4ee;
  border-radius: 999px;
  padding: 2px;
  height: 32px;
}

.lang-button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

.lang-button.is-active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 6px 12px rgba(20, 35, 50, 0.08);
}

@media (max-width: 560px) {
  .trust-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "descriptor"
      "actions";
    align-items: start;
  }

  .header-actions {
    justify-items: start;
  }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}

.identity-card {
  display: flex;
  gap: 18px;
  align-items: center;
}

.flag {
  margin-inline-end: 6px;
  font-size: 0.95rem;
}

.avatar {
  width: 150px;
  height: 200px;
  border-radius: 26px;
  border: 1px solid #d9e4ee;
  background: #eef3f7;
  flex-shrink: 0;
  object-fit: cover;
}

.identity-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.name {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.meta div {
  display: grid;
  gap: 4px;
}

.meta dt {
  font-size: 0.78rem;
  color: var(--muted);
}

.meta dd {
  margin: 0;
  font-weight: 500;
}

.note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.status-card h2 {
  margin: 6px 0 0;
  font-size: 1.25rem;
}

.status-summary {
  margin: 0 0 10px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.status-pill {
  background: var(--green-soft);
  color: var(--green);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: inherit;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 20px;
  margin: 16px 0 0;
}

.status-grid dt {
  color: var(--muted);
  font-size: 0.78rem;
}

.status-grid dd {
  margin: 6px 0 0;
  font-weight: 500;
}

.doctor-gate h3 {
  margin: 6px 0 0;
  font-size: 1.05rem;
}

.role-controls {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.role-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.role-select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: inherit;
  font-size: 0.95rem;
}

.role-error {
  margin: 0;
  font-size: 0.78rem;
  color: #8a3b3b;
}

.primary.is-disabled,
.primary[aria-disabled="true"] {
  background: #cdd9e2;
  box-shadow: none;
  cursor: not-allowed;
  color: #6d7c86;
}

.access-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(47, 143, 110, 0.2);
}

.access-banner-text {
  font-size: 0.8rem;
  font-weight: 600;
}

.bypass-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(47, 143, 110, 0.15);
  color: var(--green);
}

.access-banner .ghost.ghost-muted {
  padding: 4px 10px;
  font-size: 0.75rem;
}

.extended-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.access-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--green);
  background: var(--green-soft);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.policy,
.doctor-access {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.policy-text {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.primary,
.ghost {
  font-family: inherit;
  font-size: 0.95rem;
  border-radius: 14px;
  padding: 12px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ghost {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 24px rgba(43, 111, 156, 0.25);
}

.primary:hover {
  transform: translateY(-1px);
}

.ghost {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(43, 111, 156, 0.2);
}

.ghost.ghost-muted {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.ghost:hover {
  transform: translateY(-1px);
}

.privacy {
  padding: 4px 4px 0;
}

.privacy-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 10px;
}

.privacy-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.privacy-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.helper {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.cue {
  display: inline-block;
  vertical-align: middle;
  margin-inline-end: 6px;
}

.cue-amber {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f2c97d;
  box-shadow: 0 0 0 2px rgba(242, 201, 125, 0.2);
}

.cue-warning {
  font-size: 0.85rem;
  color: #8a8f96;
}
.icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.legal {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  margin-top: 8px;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 32px 20px;
  align-items: center;
  justify-content: center;
}

body[data-screen="handoff"] #handoff-screen,
body[data-screen="loading"] #loading-screen,
body[data-screen="empty"] #empty-screen {
  display: flex;
}

body[data-screen="handoff"] #main-screen,
body[data-screen="loading"] #main-screen,
body[data-screen="empty"] #main-screen {
  display: none;
}

.handoff-card,
.state-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 420px;
  text-align: center;
  display: grid;
  gap: 14px;
}

.subtext {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.microcopy {
  margin: 0;
  color: #6a7a86;
  font-size: 0.8rem;
  line-height: 1.4;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #d7e4ee;
  border-top-color: var(--accent);
  margin: 0 auto;
  animation: spin 1s linear infinite;
}

.skeleton {
  display: grid;
  gap: 8px;
}

.skeleton span {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e8eff5, #f5f8fb, #e8eff5);
  animation: shimmer 1.6s infinite;
}

.skeleton span:nth-child(2) {
  width: 70%;
}

.skeleton span:nth-child(3) {
  width: 50%;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

.modal-layer {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 25, 35, 0.35);
  padding: 20px;
  z-index: 10;
}

.modal-layer.is-open {
  display: flex;
}

.modal {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: min(420px, 100%);
  width: 100%;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: #f0f4f7;
  color: #4a5a66;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}

.modal-panel {
  display: none;
  gap: 12px;
}

.modal-layer[data-modal="otp"] .modal-panel[data-panel="otp"] {
  display: grid;
}

.modal-actions {
  display: grid;
  gap: 10px;
}

.otp {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
  width: 100%;
  direction: ltr;
}

.otp input {
  height: 46px;
  width: 100%;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid #d6e2ec;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
}

@media (min-width: 768px) {
  .page {
    padding: 40px 24px 64px;
    gap: 24px;
  }

  .trust-copy .title {
    font-size: 1.35rem;
  }

  .identity-card {
    padding: 24px;
  }

  .policy,
  .doctor-access {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

body.rtl .trust-header {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "actions title"
    "actions descriptor";
}

body.rtl .header-actions {
  justify-items: start;
}

body.rtl .header-controls {
  flex-direction: row-reverse;
}

body.rtl .extended-header {
  flex-direction: row-reverse;
}

body.rtl .access-banner {
  flex-direction: row-reverse;
}

@media (max-width: 560px) {
  body.rtl .trust-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "descriptor"
      "actions";
  }
}

body.rtl .identity-card {
  flex-direction: row-reverse;
}

body.rtl .status-header {
  flex-direction: row-reverse;
}

body.rtl .page,
body.rtl .card,
body.rtl .policy-text,
body.rtl .privacy,
body.rtl .legal,
body.rtl .status-grid,
body.rtl .meta,
body.rtl .trust-copy,
body.rtl .note,
body.rtl .subtext,
body.rtl .microcopy,
body.rtl .descriptor,
body.rtl .chip-note,
body.rtl .status-summary,
body.rtl .privacy-note,
body.rtl .helper {
  text-align: right;
}

body.rtl .status-grid dt,
body.rtl .status-grid dd,
body.rtl .meta dt,
body.rtl .meta dd {
  text-align: right;
}

body.rtl .privacy-list li {
  flex-direction: row-reverse;
}

body.rtl .lang-switch {
  direction: ltr;
}

@media (min-width: 1024px) {
  .page {
    max-width: 980px;
    display: grid;
    grid-template-columns: 0.95fr 1.05fr;
    align-items: start;
    gap: 16px 18px;
  }

  .trust-header,
  .privacy,
  .legal {
    grid-column: 1 / -1;
  }

  .trust-header {
    order: 0;
  }

  .identity-card {
    order: 1;
  }

  .status-card {
    order: 2;
  }

  .doctor-gate {
    order: 3;
  }

  .access-banner {
    order: 4;
  }

  .extended-details {
    order: 5;
  }

  .privacy {
    order: 6;
  }

  .legal {
    order: 7;
  }
}

@media (max-width: 420px) {
  .identity-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .avatar {
    width: 150px;
    height: 200px;
  }
}
