.profile-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--motion-hover) var(--motion-ease), background var(--motion-hover) var(--motion-ease);
}
:root:has(.auth-dialog[open]) { overflow: hidden; scrollbar-gutter: stable; background: var(--bg); }
.profile-toggle .nv-icon { width: 20px; height: 20px; }
.profile-toggle:hover { background: var(--secondary-hover); color: var(--on-secondary-hover); }
.auth-dialog {
  --auth-error: var(--danger);
  width: min(480px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: clamp(24px, 5vw, 36px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 90px #090b1170;
}
[data-theme="dark"] .auth-dialog { --auth-error: color-mix(in srgb, var(--danger) 55%, var(--text)); }
@supports (backdrop-filter: blur(1px)) {
  [data-theme="dark"] .auth-dialog { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(28px) saturate(150%); }
}
.auth-dialog::backdrop { background: #090b1199; backdrop-filter: blur(6px); }
.auth-dialog [data-auth-close] { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; padding: 0; }
.auth-brand {
  padding-top: var(--space-3);
  color: var(--text);
}
.auth-brand .logo-mark { display: block; width: auto; height: 24px; overflow: visible; }
.auth-dialog h2 { margin: var(--space-5) 0 var(--space-3); padding-right: var(--space-3); font-size: clamp(28px, 7vw, 36px); font-weight: 500; }
.auth-copy { margin: 0 0 var(--space-6); color: var(--text-secondary); font-size: var(--text-md); }
.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 52px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid #d8d9df;
  border-radius: var(--radius-pill);
  background: var(--neutral-white);
  color: #17191e;
  font-size: var(--text-sm);
  font-weight: 500;
}
.auth-google svg { width: 20px; height: 20px; flex: none; }
.auth-google:hover:not(:disabled) { border-color: var(--focus); }
.auth-google:disabled { opacity: .65; cursor: not-allowed; }
.auth-google-note { margin-top: var(--space-2); text-align: center; }
.auth-divider { display: flex; align-items: center; gap: var(--space-4); margin-block: var(--space-5); color: var(--text-secondary); font-size: var(--text-xs); }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-dialog form { display: grid; gap: var(--space-5); }
.auth-dialog .field { font-size: var(--text-sm); font-weight: 500; }
.auth-dialog :is(input, select) { min-width: 0; font-size: 16px; }
.auth-field-error { color: var(--auth-error); font-size: var(--text-xs); line-height: 1.6; font-weight: 500; }
.auth-field-error:empty { display: none; }
.auth-dialog input[aria-invalid="true"] { border-color: var(--auth-error); outline-color: var(--auth-error); }
.auth-dialog input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-error) 18%, transparent); }
.auth-dialog .auth-field-flash { animation: auth-invalid-feedback 360ms var(--ease); }
@keyframes auth-invalid-feedback {
  0%, 100% { background-color: var(--surface); }
  45% { background-color: color-mix(in srgb, var(--auth-error) 10%, var(--surface)); }
}
.auth-dialog .auth-primary { width: 100%; justify-content: space-between; margin-top: var(--space-1); }
.auth-primary .nv-icon { width: 18px; height: 18px; }
.auth-primary:disabled { cursor: wait; }
.auth-password { position: relative; display: block; }
.auth-password input { padding-right: 52px; }
.auth-eye { position: absolute; inset: 4px 4px 4px auto; display: grid; place-items: center; width: 44px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); }
.auth-eye .nv-icon { width: 20px; height: 20px; transition: transform var(--duration-fast) var(--ease); }
.auth-eye-slash { stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; transition: stroke-dashoffset var(--duration-fast) var(--ease), opacity var(--duration-fast) var(--ease); }
.auth-eye[aria-pressed="true"] { color: var(--focus); }
.auth-eye[aria-pressed="true"] .auth-eye-slash { stroke-dashoffset: 0; opacity: 1; }
.auth-eye:active .nv-icon { transform: scale(.9); }
.auth-eye:hover { color: var(--text); }
.auth-hint { margin: 0; color: var(--text-secondary); font-size: var(--text-xs); line-height: 1.6; }
.auth-dialog form + .auth-hint { margin-top: var(--space-4); }
.auth-dialog form .auth-hint { margin-top: calc(var(--space-3) * -1); }
.auth-switch { margin: var(--space-5) 0 0; text-align: center; font-size: var(--text-sm); color: var(--text-secondary); }
.auth-link { min-height: 44px; padding: var(--space-1); border: 0; border-radius: var(--radius-sm); background: none; color: var(--focus); font-size: inherit; font-weight: 500; text-decoration: underline; text-underline-offset: 4px; }
.auth-forgot { margin-top: calc(var(--space-4) * -1); text-align: right; font-size: var(--text-sm); }
.auth-email-summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); padding: var(--space-2) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: var(--text-sm); }
.auth-email-summary > span { min-width: 0; overflow-wrap: anywhere; }
.auth-message { margin: var(--space-4) 0 0; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: var(--text-sm); line-height: 1.5; }
.auth-message:empty { display: none; }
.auth-message.is-error { border-color: var(--auth-error); }
.auth-trap, .auth-hidden-username { position: absolute; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; overflow: hidden; clip-path: inset(50%); }
.auth-profile { display: flex; align-items: center; gap: var(--space-4); margin-block: var(--space-6); }
.auth-profile > div { min-width: 0; overflow-wrap: anywhere; }
.auth-profile p { margin: var(--space-1) 0 0; font-size: var(--text-sm); color: var(--text-secondary); }
.auth-avatar { display: grid; place-items: center; flex: none; width: 56px; height: 56px; border-radius: 50%; background: var(--blue-soft); color: var(--focus); font-size: var(--text-xl); }
.auth-profile-details { margin: 0 0 var(--space-6); font-size: var(--text-sm); }
.auth-profile-details > div { display: flex; justify-content: space-between; gap: var(--space-4); padding-block: var(--space-4); border-top: 1px solid var(--border); }
.auth-profile-details dt { color: var(--text-secondary); }
.auth-profile-details dd { margin: 0; }
@media (max-width: 760px) {
  .home-header .nav { gap: var(--space-3); }
  .auth-dialog { padding: var(--space-5); }
}

.auth-connecting { min-height: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-block: 32px; }
.auth-connecting h2 { padding: 0; margin-top: 28px; font-size: clamp(26px, 6vw, 32px); }
.auth-connecting .auth-copy { max-width: 28ch; margin-bottom: 16px; }
.auth-connect-status { color: var(--text-secondary); font-size: 12px; margin: 0; }
/* Standard, restrained loading indicator. */
.auth-spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--action); border-radius: 50%; animation: auth-spinner-turn .8s linear infinite; }
@keyframes auth-spinner-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .auth-spinner { animation: none; } }
.motion-off .auth-spinner { animation: none; }

.auth-connect-cancel { margin-top: 24px; width: 100%; justify-content: center; }

/* Header access follows the existing rounded secondary buttons. */
.area-link, .service-header-link { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 18px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: transparent; color: var(--text); font-size: var(--text-sm); font-weight: 600; white-space: nowrap; text-decoration: none; transition: border-color 180ms, background 180ms; }
.area-link[hidden] { display: none; }
.home-header .area-link { min-height: 40px; padding-block: 8px; }
.area-link:hover, .service-header-link:hover { border-color: var(--focus); background: var(--secondary-hover); }
@media(max-width: 400px) { .area-link, .service-header-link { padding-inline: 10px; font-size: 12px; } .home-header .nav-actions { gap: 6px; } }

@media (max-width: 360px) {
  body:not([data-area]) .home-header .nav { width: calc(100% - 24px); column-gap: 6px; }
  body:not([data-area]) .home-header .logo-mark { height: 22px; }
}

.auth-edit-action { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); width: 100%; min-height: 48px; margin-bottom: var(--space-4); padding: 10px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-align: left; font-size: var(--text-sm); font-weight: 600; }
.auth-edit-action:hover { border-color: var(--focus); }
.auth-edit-action .nv-icon { width: 16px; height: 16px; color: var(--text-secondary); }
.auth-dialog .auth-signout { justify-self: start; }

.auth-profile-edit { position:absolute; top:14px; right:62px; display:grid; place-items:center; width:40px; height:40px; padding:0; border:1px solid var(--border); border-radius:50%; background:var(--surface); color:var(--text); }
.auth-profile-edit[hidden] { display:none; }
.auth-profile-edit:hover { border-color:var(--focus); background:var(--blue-soft); }
.auth-profile-edit .nv-icon { width:18px; height:18px; }
.auth-password-title { margin:24px 0 0; font-size:16px; font-weight:600; }
.auth-optional { color:var(--text-secondary); font-weight:400; }
.auth-dialog .field:has(#auth-profile-name) { margin-top:8px; }

.auth-dialog .auth-security { margin-top:var(--space-6); padding-top:var(--space-5); border-top:1px solid var(--border); gap:var(--space-4); }
.auth-security h3 { margin:0 0 var(--space-2); font-size:var(--text-sm); font-weight:600; }
.auth-security p { margin:0; color:var(--text-secondary); font-size:var(--text-sm); line-height:1.6; }
.auth-security .auth-password-action { width:100%; justify-content:space-between; }
.auth-password-action .nv-icon { width:18px; height:18px; }
