body.auth-view .public-auth-page {
  width: min(1280px, 100%);
}

/* Public entry: brand left, centered links, account actions right. */
body.auth-view .top {
  display: grid;
  grid-template-columns: minmax(205px, 1fr) minmax(0, auto) minmax(205px, 1fr);
  align-items: center;
  gap: 16px;
  padding-inline: max(18px, calc((100vw - 1280px) / 2));
}

body.auth-view .top #top-actions { display: contents; }

body.auth-view .auth-public-brand {
  grid-column: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

body.auth-view .auth-public-nav,
body.auth-view .auth-public-controls {
  display: inline-flex;
  align-items: center;
}

body.auth-view .auth-public-nav {
  grid-column: 2;
  justify-self: center;
  gap: 2px;
  min-width: 0;
}

body.auth-view .auth-public-nav .top-public-link,
body.auth-view .auth-public-country-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #9db0ad;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

body.auth-view .auth-public-nav .top-public-link:hover,
body.auth-view .auth-public-nav .top-public-link:focus-visible,
body.auth-view .auth-public-country-toggle:hover,
body.auth-view .auth-public-country-toggle:focus-visible,
body.auth-view .auth-public-country-toggle[aria-expanded="true"] {
  color: #73decd;
  border-color: rgba(115, 222, 205, .20);
  background: rgba(115, 222, 205, .07);
  outline: none;
}

body.auth-view .auth-public-country-toggle svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .18s ease;
}

body.auth-view .auth-public-country-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

body.auth-view .auth-public-country-menu { position: relative; }

body.auth-view .auth-public-country-panel {
  position: fixed;
  z-index: 30;
  top: 70px;
  left: 50vw;
  right: auto;
  width: min(680px, calc(100vw - 28px));
  padding: 16px;
  border: 1px solid rgba(184, 215, 211, .18);
  border-radius: 10px;
  background: #10191b;
  box-shadow: 0 20px 48px rgba(0, 0, 0, .34);
  transform: translateX(-50%);
}

body.auth-view .auth-public-country-menu-content { display: block; }
body.auth-view .auth-public-country-loading { color: #8fa5a1; font-size: 12px; }
body.auth-view .auth-public-country-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px 24px;
}
body.auth-view .auth-public-country-group { display: grid; gap: 5px; align-content: start; }
body.auth-view .auth-public-country-group strong {
  margin-bottom: 2px;
  color: #8ca5a0;
  font-size: 11px;
  font-weight: 700;
}
body.auth-view .auth-public-country-menu-link {
  overflow: hidden;
  color: #e0eeeb;
  font-size: 12px;
  line-height: 1.45;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.auth-view .auth-public-country-menu-link:hover,
body.auth-view .auth-public-country-menu-link:focus-visible { color: #73decd; outline: none; }
body.auth-view .auth-public-country-all {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid rgba(184, 215, 211, .14);
  color: #73decd;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
body.auth-view .auth-public-country-all:hover { color: #b2f3e6; }

body.auth-view .auth-public-controls {
  grid-column: 3;
  justify-self: end;
  gap: 7px;
  min-width: 0;
}
body.auth-view .auth-public-controls .btn { min-height: 38px; padding: 8px 14px; border-radius: 999px; box-shadow: none; }
body.auth-view .auth-public-controls .auth-entry-link { text-decoration: none; }
body.auth-view .auth-card { scroll-margin-top: 14px; }
body.auth-view .auth-public-controls .theme-toggle { min-width: 78px; }
body.auth-view .auth-public-controls #lang-toggle { order: -1; }

html[data-theme="light"] body.auth-view .auth-public-nav .top-public-link,
html[data-theme="light"] body.auth-view .auth-public-country-toggle { color: #536a78; }
html[data-theme="light"] body.auth-view .auth-public-nav .top-public-link:hover,
html[data-theme="light"] body.auth-view .auth-public-nav .top-public-link:focus-visible,
html[data-theme="light"] body.auth-view .auth-public-country-toggle:hover,
html[data-theme="light"] body.auth-view .auth-public-country-toggle:focus-visible,
html[data-theme="light"] body.auth-view .auth-public-country-toggle[aria-expanded="true"] {
  color: #0877d1;
  border-color: #bfd7ee;
  background: #edf6fd;
}
html[data-theme="light"] body.auth-view .auth-public-country-panel {
  border-color: #d4e0eb;
  background: #fff;
  box-shadow: 0 20px 48px rgba(24, 48, 72, .18);
}
html[data-theme="light"] body.auth-view .auth-public-country-group strong { color: #718696; }
html[data-theme="light"] body.auth-view .auth-public-country-menu-link { color: #28465c; }
html[data-theme="light"] body.auth-view .auth-public-country-menu-link:hover,
html[data-theme="light"] body.auth-view .auth-public-country-menu-link:focus-visible,
html[data-theme="light"] body.auth-view .auth-public-country-all { color: #0877d1; }

body.auth-view .public-auth-stage {
  grid-template-columns: minmax(0, 1.8fr) minmax(310px, .72fr);
  gap: 18px;
}

body.auth-view .auth-public-directory { padding: 20px; }
body.auth-view .auth-public-head h1 { font-size: 34px; }
body.auth-view .auth-public-head p:not(.auth-card-kicker) { max-width: 680px; }
body.auth-view .auth-public-vitals { grid-template-columns: minmax(0, 1.45fr) minmax(190px, .7fr); }
body.auth-view .auth-public-footer { grid-template-columns: 1.1fr 1fr 1.1fr; }

body.auth-view .auth-country-section {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  gap: 9px;
  margin-top: 3px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

body.auth-view .auth-country-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

body.auth-view .auth-country-head strong { color: var(--text); font-size: 12px; }
body.auth-view .auth-country-head a,
body.auth-view .auth-country-retry { color: var(--cyan); font-size: 11px; text-decoration: none; }
body.auth-view .auth-country-retry { border: 0; padding: 0; background: transparent; cursor: pointer; }
body.auth-view .auth-country-loading { color: var(--muted); font-size: 11px; }
body.auth-view .auth-country-featured,
body.auth-view .auth-country-list { display: flex; flex-wrap: wrap; gap: 6px 15px; }
body.auth-view .auth-country-link { color: var(--soft); font-size: 11px; line-height: 1.6; text-decoration: none; }
body.auth-view .auth-country-link:hover,
body.auth-view .auth-country-link:focus-visible { color: var(--cyan); text-decoration: underline; }
body.auth-view .auth-country-all { color: var(--muted); font-size: 11px; }
body.auth-view .auth-country-all > summary { width: fit-content; cursor: pointer; }
body.auth-view .auth-country-list { margin-top: 9px; padding: 10px 0 2px; border-top: 1px solid var(--line); }

html[data-theme="light"] body.auth-view .top-public-link { color: #475c70; }
html[data-theme="light"] body.auth-view .top-public-link:hover,
html[data-theme="light"] body.auth-view .top-public-link:focus-visible {
  color: #075dbd;
  background: #eaf3fd;
  outline: 2px solid #8bbdf1;
  outline-offset: 1px;
}

html[data-theme="light"] body.auth-view .auth-country-section { border-color: #d5dee7; }
html[data-theme="light"] body.auth-view .auth-country-head strong { color: #203447; }
html[data-theme="light"] body.auth-view .auth-country-head a,
html[data-theme="light"] body.auth-view .auth-country-retry,
html[data-theme="light"] body.auth-view .auth-country-link:hover,
html[data-theme="light"] body.auth-view .auth-country-link:focus-visible { color: #075dbd; }
html[data-theme="light"] body.auth-view .auth-country-link { color: #465c70; }

html[data-theme="light"] body.auth-view #support-widget .support-panel {
  border-color: #d5dee8;
  background: #fff;
  box-shadow: 0 18px 46px rgba(24, 48, 72, .18);
}

html[data-theme="light"] body.auth-view #support-widget .support-head { border-color: #e0e7ef; }
html[data-theme="light"] body.auth-view #support-widget .support-title strong,
html[data-theme="light"] body.auth-view #support-widget .support-card strong,
html[data-theme="light"] body.auth-view #support-widget .support-code strong { color: #172b3d; }
html[data-theme="light"] body.auth-view #support-widget .support-title p,
html[data-theme="light"] body.auth-view #support-widget .support-card p,
html[data-theme="light"] body.auth-view #support-widget .support-code span { color: #52677b; }
html[data-theme="light"] body.auth-view #support-widget .support-icon,
html[data-theme="light"] body.auth-view #support-widget .support-round:not(.support-qq-mark) {
  color: #0968bd;
  border-color: #c8dcf2;
  background: #edf5fd;
}

html[data-theme="light"] body.auth-view #support-widget .support-close,
html[data-theme="light"] body.auth-view #support-widget .support-secondary,
html[data-theme="light"] body.auth-view #support-widget .support-code button {
  color: #334b62;
  border-color: #d4dee8;
  background: #f5f8fb;
}

html[data-theme="light"] body.auth-view #support-widget .support-tabs {
  border-color: #d5dee8;
  background: #f1f5f9;
}

html[data-theme="light"] body.auth-view #support-widget .support-tabs button { color: #53687b; }
html[data-theme="light"] body.auth-view #support-widget .support-tabs button.active {
  color: #fff;
  background: #0877d1;
  box-shadow: 0 5px 14px rgba(8, 119, 209, .18);
}

html[data-theme="light"] body.auth-view #support-widget .support-card {
  border-color: #d7e1eb;
  background: #f7f9fc;
}

html[data-theme="light"] body.auth-view #support-widget .qr-frame { border-color: #d8e2ec; }
html[data-theme="light"] body.auth-view #support-widget .support-primary { color: #fff; background: #0877d1; }
html[data-theme="light"] body.auth-view #support-widget .support-code {
  border-color: #d7e1eb;
  background: #f3f6fa;
}

html[data-theme="light"] body.auth-view #support-widget .support-fab {
  color: #1a3044;
  border-color: #cfdae5;
  background: #fff;
  box-shadow: 0 10px 28px rgba(24, 48, 72, .18);
}

html[data-theme="light"] body.auth-view #support-widget .support-fab b { color: #1b3045; }
html[data-theme="light"] body.auth-view #support-widget .support-fab small { color: #52677b; }
html[data-theme="light"] body.auth-view #support-widget .support-fab > span { color: #0868bc; background: #e8f3fd; }

/* Public entry support must read as part of the light shell, not as a dark overlay. */
html[data-theme="light"] body.auth-view #support-widget .support-fab:focus-visible,
html[data-theme="light"] body.auth-view #support-widget .support-close:focus-visible,
html[data-theme="light"] body.auth-view #support-widget .support-tabs button:focus-visible,
html[data-theme="light"] body.auth-view #support-widget .support-primary:focus-visible,
html[data-theme="light"] body.auth-view #support-widget .support-secondary:focus-visible,
html[data-theme="light"] body.auth-view #support-widget .support-code button:focus-visible {
  outline: 3px solid rgba(8, 119, 209, .28);
  outline-offset: 2px;
}

html[data-theme="light"] body.auth-view #support-widget .support-fab:hover,
html[data-theme="light"] body.auth-view #support-widget .support-close:hover,
html[data-theme="light"] body.auth-view #support-widget .support-secondary:hover,
html[data-theme="light"] body.auth-view #support-widget .support-code button:hover {
  border-color: #9fc4e5;
  background: #eef6fd;
}

html[data-theme="light"] body.auth-view #support-widget .support-primary:hover {
  background: #0768b8;
}

html[data-theme="light"] body.auth-view #support-widget .support-tabs button.active:hover {
  background: #0768b8;
}

body.auth-view #support-widget .support-panel,
body.auth-view #support-widget .support-fab {
  backdrop-filter: none;
}

body.auth-view #support-widget .support-panel {
  max-height: min(640px, calc(100dvh - 32px));
  overflow-y: auto;
  overscroll-behavior: contain;
}

body.auth-view #support-widget .support-panel::-webkit-scrollbar { width: 8px; }
body.auth-view #support-widget .support-panel::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--line);
  background-clip: padding-box;
}

@media (max-width: 640px) {
  body.auth-view #support-widget {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  body.auth-view #support-widget .support-fab {
    max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  body.auth-view #support-widget .support-panel {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  body.auth-view #support-widget .support-panel,
  body.auth-view #support-widget .support-fab,
  body.auth-view #support-widget .support-close,
  body.auth-view #support-widget .support-tabs button {
    transition: none;
  }
}

@media (max-width: 900px) {
  body.auth-view .public-auth-stage { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1060px) {
  body.auth-view .top {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 8px 12px;
    padding-inline: 16px;
  }
  body.auth-view .auth-public-brand { grid-column: 1; grid-row: 1; }
  body.auth-view .auth-public-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-self: stretch;
    overflow-x: auto;
    justify-content: center;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }
  body.auth-view .auth-public-controls {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    gap: 4px;
  }
  body.auth-view .auth-public-controls .btn { padding-inline: 10px; }
  body.auth-view .top #top-actions .auth-public-controls .btn {
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
    white-space: nowrap;
  }
  body.auth-view .top #top-actions .auth-public-controls .theme-toggle > span,
  body.auth-view .top #top-actions .auth-public-controls #lang-toggle > span { display: none; }
  body.auth-view .auth-public-country-panel {
    top: 108px;
    left: 14px;
    right: 14px;
    width: auto;
    max-height: calc(100dvh - 124px);
    transform: none;
  }
}

@media (max-width: 640px) {
  body.auth-view .top { padding-inline: 12px; gap: 8px 10px; }
  body.auth-view .brand { gap: 8px; }
  body.auth-view .brand-icon { width: 34px; height: 34px; }
  body.auth-view .auth-public-brand > div { font-size: 13px; }
  body.auth-view .brand small { display: none; }
  body.auth-view .top #top-actions .auth-public-controls .btn { padding-inline: 8px; }
  body.auth-view .auth-public-nav { justify-content: flex-start; }
  body.auth-view .auth-public-country-panel { top: 116px; left: 12px; right: 12px; max-height: calc(100dvh - 132px); transform: none; }
  body.auth-view .auth-public-country-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.auth-view .auth-public-footer { grid-template-columns: minmax(0, 1fr); }
  body.auth-view .auth-public-footer .auth-country-section { grid-column: auto; }
}

/* Mobile auth controls: use a real hit-test container instead of display:contents
   so Login/Register remains tappable on mobile browsers. */
@media (max-width: 760px) {
  body.auth-view .top {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: stretch;
  }

  body.auth-view .top #top-actions {
    display: grid;
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 8px 10px;
    width: 100%;
    min-width: 0;
    position: relative;
    z-index: 20;
  }

  body.auth-view .auth-public-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }

  body.auth-view .auth-public-controls {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    position: relative;
    z-index: 21;
    pointer-events: auto;
  }

  body.auth-view .auth-public-controls .btn[data-action="auth-mode"] {
    position: relative;
    z-index: 1;
    min-height: 44px;
    touch-action: manipulation;
    pointer-events: auto;
  }

  body.auth-view .top,
  body.auth-view .auth-public-controls {
    position: relative;
    isolation: isolate;
  }
}

/* Mobile6: keep public controls inside the viewport and prevent the metrics
   row from compressing its number, progress rail, and 3D preview together. */
@media (max-width: 760px) {
  body.auth-view .top #top-actions .auth-public-controls {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: stretch;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) minmax(0, 1fr) 42px;
    width: 100%;
    gap: 6px;
  }

  body.auth-view .top #top-actions .auth-public-controls .btn,
  body.auth-view .top #top-actions .auth-public-controls .auth-entry-link {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding-inline: 6px;
    justify-content: center;
  }

  body.auth-view .top #top-actions .auth-public-controls .theme-toggle,
  body.auth-view .top #top-actions .auth-public-controls #lang-toggle {
    min-width: 0;
    width: 100%;
    padding-inline: 0;
  }

  body.auth-view .top #top-actions .auth-public-controls .theme-toggle > span,
  body.auth-view .top #top-actions .auth-public-controls #lang-toggle > span {
    display: none;
  }

  body.auth-view .auth-public-vitals {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  body.auth-view .auth-public-vitals .auth-telemetry {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 0;
  }

  body.auth-view .auth-public-vitals .auth-telemetry-total strong { font-size: 32px; }

  body.auth-view .auth-public-vitals .auth-public-depth {
    min-height: 112px;
    transform: none;
  }
}
