#account-dialog {
  width: min(25rem, calc(100% - 24px));
  max-height: min(92dvh, 54rem);
  padding: clamp(20px, 4vw, 28px);
  border-radius: 18px;
  overflow-y: auto;
}
#account-dialog h2 { margin: 0 35px 15px 0; font-size: 23px; }
#account-dialog #account-description { margin: -8px 10px 16px 0; color: var(--muted); line-height: 1.55; font-size: 14px; }
#account-dialog #account-description:empty { display:none; }
#account-dialog:is([data-mode=login],[data-mode=register]) h2 {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%);
}
#account-dialog .account-auth-modes { display: inline-flex; gap: 20px; margin: 0 40px 18px 0; }
#account-dialog .account-auth-modes button {
  padding: 0 0 5px; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; color: var(--muted); font-family: inherit; font-size: 19px; font-weight: 600; line-height: 1.3;
}
#account-dialog .account-auth-modes button[aria-pressed=true] { color: #a7e8c8; border-bottom-color: #76cda5; }
#account-dialog .primary, .account-page .primary { background: #266949; border-color: #469268; color: #fff; }
#account-dialog .primary:hover, .account-page .primary:hover { background: #327953; }
#account-dialog form, #account-key-panel { display: grid; gap: 13px; }
#account-dialog [hidden] { display: none !important; }
#account-dialog .account-field { min-width: 0; }
#account-dialog label, #account-dialog legend {
  margin: 0 0 4px; font-weight: 550; color: var(--text);
}
#account-dialog input, #account-dialog select {
  min-width: 0; min-height: 42px; margin: 0; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); background: var(--surface-input);
}
#account-dialog .account-label-row, #account-dialog .account-links, #account-dialog .account-key-actions {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 18px;
}
#account-dialog .account-label-row { justify-content: space-between; }
#account-dialog .text-link { margin: 0; padding: 3px 0; }
#account-dialog .account-links { margin-top: 12px; justify-content: space-between; }
#account-dialog .primary { width: 100%; min-height: 44px; justify-content: center; }
#account-dialog :is(#account-status, #account-key-status) {
  margin: 0; line-height: 1.5; color: var(--action);
}
#account-dialog :is(#account-status, #account-key-status):empty { display: none; }
#account-dialog #account-status.account-error { color: var(--red); }
#account-challenge {
  min-width: 0; margin: 0; padding: 6px 12px 12px; border: 1px solid var(--line); border-radius: 10px;
}
#account-dialog #account-challenge legend { padding: 0 5px; font-size: 14px; }
#account-dialog .account-challenge-row {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px;
}
#account-dialog .account-challenge-content { display: grid; align-items: center; min-height: 42px; }
#account-dialog #account-challenge-image { width: min(158px, 100%); height: auto; border-radius: 5px; }
#account-dialog .account-challenge-actions { display: flex; align-items: start; flex-direction: column; }
#account-dialog .account-challenge-actions button { font-size: 13px; }
#account-dialog #account-recovery-value {
  padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-input);
  color: var(--text); font: 600 1.1rem/1.55 ui-monospace, monospace; overflow-wrap: anywhere; user-select: all;
}
#account-dialog .account-key-actions { justify-content: flex-start; }
#account-dialog .account-key-actions button { min-height: 40px; }
#account-dialog label[for="account-key-saved"] { display: flex; align-items: center; gap: 9px; font-weight: 400; }
#account-dialog #account-key-saved { display: inline; width: 18px; height: 18px; min-height: 0; }
.header-inner #account-entry { display: inline-flex; align-items: center; gap: 7px; max-width: min(24vw,15rem); }
.header-inner #account-entry > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-avatar, .profile-avatar { display: inline-grid; place-items: center; flex: none; overflow: hidden; border-radius: 50%; }
.header-avatar { width: 26px; height: 26px; background: #294635; }
.header-avatar img, .profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.account-page { max-width: 44rem; margin: 16px auto 42px; color: var(--text); }
.account-page [hidden] { display: none !important; }
.account-page .profile-back { display: inline-block; margin: 0 0 10px; padding: 4px 0; }
.account-page h1 { margin: 0 0 20px; font-size: clamp(26px, 4vw, 34px); letter-spacing: -.025em; }
.profile-content { display: grid; gap: 16px; }
.profile-card { min-width: 0; padding: clamp(16px, 3vw, 26px); border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.profile-card h2 { margin: 0; font-size: 18px; }
.profile-identity-row { display: flex; align-items: center; gap: clamp(9px, 2vw, 20px); }
.profile-nameplate { min-width: 0; flex: 1; }
.profile-nameplate h2 { font-size: clamp(18px, 3vw, 25px); overflow-wrap: anywhere; }
.profile-nameplate p, .profile-guest p { margin: 3px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.profile-guest .primary { margin-top: 14px; }
.profile-avatar { width: clamp(48px, 10vw, 72px); height: clamp(48px, 10vw, 72px); font-size: clamp(28px, 5vw, 38px); background: #294635; }
#profile-edit { flex: none; }
#profile-editor { display: grid; gap: 16px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
#profile-editor label { display: block; margin: 0; }
#profile-editor label small { color: var(--muted); font-weight: 400; }
#profile-editor input:not([type=file]) { width: 100%; margin-top: 5px; }
.profile-avatar-field { min-width: 0; border: 0; margin: 0; padding: 0; }
.profile-avatar-field legend { margin-bottom: 6px; }
.profile-avatar-options { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.profile-avatar-options button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; background: var(--surface-input); border: 1px solid var(--line); border-radius: 50%; }
.profile-avatar-options button[aria-pressed=true] { background: #284739; border-color: #91d6ae; box-shadow: inset 0 0 0 1px #91d6ae; }
#profile-editor .profile-upload { position: relative; display: inline-flex; margin: 3px 6px; vertical-align: middle; color: #a7e8c8; cursor: pointer; }
.profile-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.profile-upload input:focus-visible+span { outline: 2px solid currentColor; outline-offset: 3px; }
.profile-edit-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.profile-feedback { margin: 0; color: #a7e8c8; }
.profile-feedback:empty { display: none; }
.profile-feedback.profile-error { color: var(--red); }
.nickname-count { color: var(--muted); font-size: .78rem; font-weight: 400; white-space: nowrap; }
.nickname-hint { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; font-weight: 400; }
.account-page .avatar-crop {
  box-sizing: border-box; width: min(23rem,calc(100vw - 24px)); max-height: 92dvh; margin: auto;
  padding: 18px; overflow: auto; border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); color: var(--text);
}
.avatar-crop::backdrop { background: rgb(4 12 18 / 76%); }
.avatar-crop header, .avatar-crop-actions { display: flex; gap: 10px; align-items: center; }
.avatar-crop header { justify-content: space-between; margin-bottom: 12px; }
.avatar-crop header h2 { margin: 0; font-size: 21px; }
.avatar-crop-preview { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; }
.avatar-crop-frame {
  position: relative; width: min(100%,53dvh); aspect-ratio: 1; margin: 0 auto;
  overflow: hidden; border-radius: 6px; background: #27343e; cursor: grab; touch-action: none; user-select: none;
}
.avatar-crop-frame:active { cursor: grabbing; }
.avatar-crop-frame:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.avatar-crop-frame canvas { display: block; width: 100%; height: 100%; }
.avatar-crop-frame::after {
  content: ''; position: absolute; inset: 0; border: 1px solid rgb(255 255 255 / 85%);
  border-radius: 50%; box-shadow: 0 0 0 100vmax rgb(0 0 0 / 55%); pointer-events: none;
}
.avatar-crop p { margin: 10px 0; color: var(--muted); font-size: .82rem; }
#profile-editor .avatar-zoom { display: flex; align-items: center; gap: 10px; margin-block: 10px; }
#profile-editor .avatar-zoom input { flex: 1; width: auto; min-width: 0; margin: 0; padding: 0; accent-color: #8be0ad; }
.avatar-zoom output { min-width: 4ch; font-variant-numeric: tabular-nums; }
.avatar-crop-actions { justify-content: flex-end; }
.avatar-crop-actions [data-crop=reset] { margin-right: auto; }
.profile-security h2 { margin: 0 0 10px; }
.profile-security > div { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; min-height: 46px; }
.profile-security > div + div { border-top: 1px solid var(--line); }
.profile-security .profile-phone, .profile-security .profile-key-state { color: var(--muted); font-size: 14px; }
.profile-security .text-link { margin: 0 0 0 auto; }
.account-page .profile-logout { justify-self: start; margin: 0; }
.garage-heading, .garage-list li, .garage-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.garage h2, .garage .garage-empty, .garage-status { margin: 0; }
.garage-list { list-style: none; margin: 0; padding: 0; }
.garage-list li { flex-wrap: wrap; padding-block: 10px; border-top: 1px solid var(--line); }
.garage-list li > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.garage-list small { display: block; color: var(--muted); margin-top: 3px; }
.garage [hidden] { display: none !important; }
.garage .text-link { min-height: 42px; display: inline-flex; align-items: center; padding-inline: 3px; }
.garage .garage-empty, .garage-status { color: var(--muted); font-size: 14px; }
.garage-status:not(:empty) { margin-top: 8px; }
.garage-editor { display: grid; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.garage-editor label { display: grid; gap: 5px; font-size: 14px; }
.garage-editor .garage-actions { justify-content: flex-start; flex-wrap: wrap; }
.garage-actions .garage-remove { margin-left: auto; }
@media (max-width: 480px) {
  #account-dialog { padding: 22px 18px; }
  #account-dialog input, #account-dialog select { font-size: 16px; }
  #account-dialog .account-links { gap: 2px 12px; }
  #profile-editor input { font-size: 16px; }
  .account-page .profile-security > div { gap: 4px 8px; }
}
