/* The profile is a cabinet panel; other dialogs retain their own presentation. */
dialog:has(#profile-form) {
  width: min(840px,calc(100vw - 24px));
  height: min(490px,calc(100svh - 24px));
  max-width: none; max-height: none; border: 0; border-radius: 0; padding: 0;
  background: transparent; color: #fff1d3; overflow: hidden; isolation: isolate;
  box-shadow: none; filter: drop-shadow(0 20px 36px #03000cb3);
}
dialog:has(#profile-form)::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border: 64px solid transparent;
  border-image: url('/assets/atlas-profile-dialog-frame-v1.webp') 128 fill / 1 / 0 stretch;
}
dialog:has(#profile-form)::backdrop { background: #10051d9c; backdrop-filter: blur(5px); }
dialog:has(#profile-form) .modal-content {
  height: 100%; min-height: 0; display: flex; flex-direction: column;
  padding: 38px 42px 32px;
  animation: profile-panel-enter .28s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes profile-panel-enter { from { opacity: 0; transform: translateY(8px); } }
dialog:has(#profile-form) .eyebrow {
  text-align: center; color: #cda96d; font-size: 10px; letter-spacing: .24em; margin: 0 0 5px;
}
dialog:has(#profile-form) #modal-title {
  color: #ffe5a5; text-align: center; text-transform: uppercase;
  font: 700 clamp(22px,3.2vw,32px)/1.1 Georgia,serif; letter-spacing: .025em;
  text-shadow: 0 2px 0 #6d391d,0 4px 7px #09010e;
  margin: 0 0 22px;
}
#profile-form { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0,1fr) auto; gap: 16px; }
.profile-dialog-body {
  min-height: 0; display: grid; grid-template-columns: minmax(140px,.8fr) minmax(0,1.8fr); gap: 30px;
  overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #b68947 #23102d;
  padding: 3px 5px 6px;
}
.profile-identity { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.profile-avatar-art {
  display: block; width: 108px; aspect-ratio: 1; flex: 0 0 auto;
  background: url('/assets/reel-drawer-icons.png') 0 0 / 200% 200% no-repeat;
  filter: drop-shadow(0 5px 7px #09000e);
}
.profile-name { color: #ffebbc; font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; margin: 5px 0 6px; }
.profile-tier { color: #e7bd72; font-weight: 650; font-size: 14px; }
.profile-tier > span { color: #c6abc8; font-size: 12px; white-space: nowrap; }
.profile-milestone { width: 100%; max-width: 200px; margin-top: 15px; }
.profile-milestone small { color: #bca6c4; font-size: 11px; line-height: 1.6; }
.profile-milestone small strong { color: #f2d9a3; }
.profile-milestone progress {
  display: block; width: 100%; height: 7px; appearance: none; border: 1px solid #9e7143;
  border-radius: 9px; overflow: hidden; margin-bottom: 8px; background: #10091a;
}
.profile-milestone progress::-webkit-progress-bar { background: #10091a; }
.profile-milestone progress::-webkit-progress-value { background: linear-gradient(#ffe7a4,#bc782f); }
.profile-milestone progress::-moz-progress-bar { background: #e7b866; }
.profile-details { align-self: center; min-width: 0; padding: 0 0 6px; }
.profile-details h3 { margin: 0 0 15px; color: #d1ad75; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; }
.profile-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px 13px; }
.profile-fields label { min-width: 0; gap: 6px; font-size: 12px; color: #e1c89c; }
.profile-fields input {
  height: 46px; min-width: 0; border: 1px solid #8f683d; border-radius: 8px;
  background: linear-gradient(180deg,#12091c,#25132e); color: #fff2da;
  padding: 9px 11px; font-size: 14px; box-shadow: inset 0 3px 8px #030007a6,0 1px 0 #e7bf6840;
  transition: border-color .15s,box-shadow .15s;
}
.profile-fields input:hover { border-color: #c3995c; }
.profile-fields input:-webkit-autofill {
  -webkit-box-shadow: inset 0 0 0 1000px #25132e;
  -webkit-text-fill-color: #fff2da; caret-color: #fff2da;
}
.profile-fields input:focus-visible {
  outline: 2px solid #f4ce83; outline-offset: 2px; border-color: #e9bf72;
  box-shadow: inset 0 2px 5px #03000799,0 0 12px #c68d453d;
}
.profile-dialog-footer { min-width: 0; border-top: 1px solid #bc8a413f; padding-top: 15px; }
.profile-dialog-footer .error:not(:empty) { font-size: 13px; line-height: 1.3; margin: 0 0 10px; }
.profile-dialog-actions { --profile-button-height: 60px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.profile-dialog-actions .profile-action {
  --button-ratio: calc(1136 / 421);
  --button-regular: url('/assets/atlas-close-regular.webp');
  --button-over: url('/assets/atlas-close-over.webp');
  --button-pressed: url('/assets/atlas-close-pressed.webp');
  position: relative; isolation: isolate; flex: 0 1 auto; min-height: 44px; min-width: 0;
  width: calc(var(--profile-button-height) * var(--button-ratio)); height: var(--profile-button-height);
  padding: 0; border: 0; border-radius: 12px;
  background: var(--button-regular) center / contain no-repeat;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.profile-dialog-actions .primary {
  --button-ratio: calc(1439 / 351);
  --button-regular: url('/assets/atlas-save-profile-regular.webp');
  --button-over: url('/assets/atlas-save-profile-over.webp');
  --button-pressed: url('/assets/atlas-save-profile-pressed.webp');
}
/* Real raster states share the same bounds, preventing any layout jump on press. */
.profile-action::before,.profile-action::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: var(--button-over) center / contain no-repeat; opacity: 0;
  transition: opacity .1s linear;
}
.profile-action::after { background-image: var(--button-pressed); transition: none; }
@media (hover: hover) {
  .profile-action:enabled:hover::before { opacity: 1; }
}
.profile-action:enabled:focus-visible::before { opacity: 1; }
.profile-action:enabled:active::after { opacity: 1; }
.profile-dialog-actions .profile-action:focus-visible { outline: 2px solid #ffe4a0; outline-offset: 1px; }
@media (max-height: 450px) and (min-width: 621px) {
  dialog:has(#profile-form)::before { border-width: 40px; }
  dialog:has(#profile-form) .modal-content { padding: 23px 30px 21px; }
  dialog:has(#profile-form) .eyebrow { display: none; }
  dialog:has(#profile-form) #modal-title { font-size: 23px; margin-bottom: 12px; }
  #profile-form { gap: 9px; }
  .profile-dialog-body { gap: 24px; }
  .profile-avatar-art { width: 68px; }
  .profile-name { font-size: 17px; margin: 2px 0 3px; }
  .profile-milestone { margin-top: 9px; }
  .profile-details h3 { margin-bottom: 9px; }
  .profile-fields { gap: 10px 12px; }
  .profile-fields label { gap: 4px; }
  .profile-fields input { height: 44px; }
  .profile-dialog-footer { padding-top: 8px; }
  .profile-dialog-actions { --profile-button-height: 48px; }
}
@media (max-width: 620px) {
  dialog:has(#profile-form) { width: calc(100vw - 16px); height: min(680px,calc(100svh - 16px)); }
  dialog:has(#profile-form)::before { border-width: 44px; }
  dialog:has(#profile-form) .modal-content { padding: 28px 25px 24px; }
  dialog:has(#profile-form) #modal-title { margin-bottom: 16px; }
  .profile-dialog-body { grid-template-columns: minmax(0,1fr); gap: 20px; }
  .profile-identity { display: grid; grid-template-columns: 80px minmax(0,1fr); text-align: left; column-gap: 12px; }
  .profile-avatar-art { width: 80px; grid-row: span 3; }
  .profile-name { font-size: 18px; }
  .profile-milestone { max-width: none; grid-column: 2; margin-top: 6px; }
  .profile-milestone small { font-size: 10px; }
  .profile-fields { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .profile-details h3 { margin-bottom: 12px; }
  .profile-dialog-actions { --profile-button-height: 48px; gap: 8px; }
}

/* Compact tabbed editor: reserve the lower half for the native keyboard. */
dialog:has(#profile-form) {
  width: min(620px,calc(100vw - 16px)); height: min(390px,calc(var(--app-height,100dvh) - 16px));
}
dialog:has(#profile-form) .modal-content { padding: 22px 28px 20px; }
dialog:has(#profile-form)::before { border-width: 38px; }
dialog:has(#profile-form) .eyebrow { display: none; }
dialog:has(#profile-form) #modal-title { font-size: 22px; text-align: left; padding-right: 150px; margin: 0 0 12px; }
#profile-form { display: grid; grid-template-rows: auto minmax(0,1fr) auto; gap: 10px; }
.profile-dismiss-keyboard {
  position: absolute; right: 26px; top: 12px; width: 140px; height: 44px;
  min-height: 44px; padding: 6px 0; display: grid; place-items: center;
  color: #f4dc9b; background: none; border: 0; border-radius: 0; box-shadow: none;
  appearance: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.profile-dismiss-keyboard img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.profile-dismiss-keyboard:active { opacity: .7; }
.profile-dismiss-keyboard:focus-visible { outline: 2px solid #ffe4a0; outline-offset: 1px; }
.profile-tabs { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
.profile-tabs button {
  min-height: 40px; padding: 4px 8px; border: 1px solid #99714a; color: #dfcaa8;
  background: #23102e; font-size: 14px; border-radius: 8px;
}
.profile-tabs button[aria-selected="true"] { color: #2b1409; background: linear-gradient(#ffe5a2,#c78f41); border-color: #ffe1a0; }
.profile-dialog-body { display: block; padding: 2px; min-height: 0; overflow-y: auto; }
.profile-tab-panel[hidden] { display: none !important; }
.profile-fields { display: grid; grid-template-columns: minmax(0,1fr); gap: 8px; align-content: start; }
.profile-fields label { display: grid; gap: 3px; font-size: 12px; margin: 0; }
.profile-fields input { height: 42px; min-height: 42px; padding: 7px 9px; font-size: 16px; }
.profile-fields small { font-size: 11px; color: #d5c4da; }
.profile-identity { display: grid; grid-template-columns: 62px minmax(0,1fr); gap: 4px 12px; text-align: left; align-content: center; }
.profile-avatar-art { width: 62px; grid-row: span 3; }
.profile-name { font-size: 18px; margin: 0; }
.profile-tier { font-size: 13px; }
.profile-milestone { grid-column: 2; max-width: none; margin-top: 4px; }
.profile-milestone small { display: block; font-size: 11px; }
.profile-dialog-footer { padding-top: 6px; }
.profile-dialog-footer .error:not(:empty) { font-size: 12px; line-height: 1.2; margin: 0 0 4px; }
.profile-dialog-actions { --profile-button-height: 44px; gap: 8px; }
.profile-dialog-actions .profile-action { flex-shrink: 1; }
@media (max-width: 620px), (pointer: coarse) {
  dialog:has(#profile-form) {
    position: fixed; inset: auto; top: calc(var(--viewport-top,0px) + max(8px,env(safe-area-inset-top)));
    left: calc(var(--viewport-left,0px) + 50%); transform: translateX(-50%); margin: 0;
    width: min(620px,calc(var(--app-width,100vw) - 16px));
    height: min(380px,50svh,calc(var(--app-height,100dvh) - max(16px,env(safe-area-inset-top))));
  }
  dialog:has(#profile-form) .modal-content { padding: 14px 18px 10px; }
  dialog:has(#profile-form) #modal-title { font-size: 16px; min-height: 32px; margin-bottom: 6px; padding-right: 122px; }
  .profile-dismiss-keyboard { width: 114px; right: 18px; top: 7px; }
  #profile-form { gap: 4px; }
  .profile-tabs button { min-height: 36px; }
  .profile-fields { gap: 6px; }
  .profile-fields input { min-height: 40px; height: 40px; }
  .profile-dialog-actions { --profile-button-height: 44px; }
  .profile-dialog-footer { padding-top: 4px; }
}
@media (max-height: 480px) and (orientation: landscape) {
  dialog:has(#profile-form) { height: calc(var(--app-height,100dvh) - 16px); }
  .profile-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
