/* Focused settings with a quiet list and large, readable controls. */
body.dh-profile-open { overflow: hidden !important; }
#profile-modal[hidden],
#profile-modal .hidden,
#profile-modal [hidden],
#profile-modal.hidden { display: none !important; }

#profile-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
  background: #060b10c9;
  backdrop-filter: blur(4px);
}
.dh-profile-shell {
  width: 100%;
  max-width: 520px;
  height: min(660px, calc(100dvh - 24px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--dh-border, #2b3946);
  border-radius: 20px;
  background: var(--dh-surface, #141e28);
  color: var(--dh-text, #f1f5f7);
  box-shadow: 0 16px 48px #0004;
}
#profile-modal .dh-profile-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 12px 18px !important;
  border-bottom: 1px solid var(--dh-border, #2b3946);
  background: var(--dh-surface, #141e28);
}
#profile-modal h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -.25px;
  outline: none;
  overflow-wrap: anywhere;
}
#profile-modal button {
  min-height: 48px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  white-space: normal;
  cursor: pointer;
  touch-action: manipulation;
}
#profile-modal button:disabled { opacity: .5; cursor: default; }
#profile-modal button:focus-visible,
#profile-modal a:focus-visible,
#profile-modal summary:focus-visible,
#profile-modal input:focus-visible,
#profile-modal select:focus-visible,
#profile-modal textarea:focus-visible {
  outline: 2px solid var(--dh-accent, #75d6bf);
  outline-offset: 3px;
}
.dh-profile-back,
.dh-profile-close {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--dh-border, #2b3946);
  border-radius: 12px;
  background: transparent;
  color: var(--dh-text, #f1f5f7);
}
#profile-modal .dh-profile-back,
#profile-modal .dh-profile-close { font-size: .9rem; }
.dh-profile-back > span,
.dh-profile-close > span { font-size: 22px; line-height: 1; }
.dh-profile-body {
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.dh-profile-intro {
  margin: 0 0 18px;
  font-size: .95rem;
  line-height: 1.55;
  color: var(--dh-muted, #a4b1bc);
}
.dh-profile-menu {
  overflow: hidden;
  border: 1px solid var(--dh-border, #2b3946);
  border-radius: 14px;
}
.dh-profile-menu > button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 12px;
  width: 100%;
  min-height: 72px !important;
  padding: 14px;
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--dh-text, #f1f5f7);
}
.dh-profile-menu > button + button { border-top: 1px solid var(--dh-border, #2b3946); }
.dh-profile-menu > button:hover,
.dh-profile-menu > button:active { background: var(--dh-raised, #1c2935); }
.dh-profile-menu strong {
  display: block;
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.dh-profile-menu small {
  display: block;
  margin-top: 3px;
  font-size: .875rem;
  line-height: 1.4;
  color: var(--dh-muted, #a4b1bc);
}
.dh-profile-menu-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: transparent;
  color: var(--dh-muted, #a4b1bc);
}
.dh-profile-menu-icon svg { width: 22px; height: 22px; }
.dh-profile-menu > button > span:last-child { font-size: 22px; color: var(--dh-muted, #a4b1bc); }
.dh-profile-field { min-width: 0; margin-bottom: 20px; }
#profile-modal label {
  display: block;
  margin-bottom: 8px;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 550;
  color: var(--dh-text, #f1f5f7);
}
#profile-modal label > span,
.dh-profile-details summary > span {
  font-size: .875rem;
  font-weight: 400;
  color: var(--dh-muted, #a4b1bc);
}
#profile-modal input:not([type=checkbox]):not([type=hidden]),
#profile-modal select,
#profile-modal textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 52px;
  padding: 12px;
  border: 1px solid #40505e;
  border-radius: 12px;
  background: var(--dh-bg, #0d141b);
  color: var(--dh-text, #f1f5f7);
  font-family: inherit;
  font-size: 1rem !important;
  line-height: 1.5;
  outline-offset: 3px;
}
#profile-modal select { padding-right: 28px; }
#profile-modal select:disabled { opacity: .6; }
#profile-modal textarea {
  min-height: 84px;
  resize: vertical;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
#profile-modal input[readonly],
#profile-modal textarea[readonly] {
  background: var(--dh-raised, #1c2935);
  border-color: var(--dh-border, #2b3946);
}
#profile-modal input::placeholder,
#profile-modal textarea::placeholder { color: var(--dh-muted, #a4b1bc); opacity: 1; }
.dh-field-note {
  margin: 8px 0 12px;
  font-size: .875rem;
  line-height: 1.55;
  color: var(--dh-muted, #a4b1bc);
  overflow-wrap: anywhere;
}
.dh-profile-details {
  margin: 18px 0;
  padding: 0 14px;
  border: 1px solid var(--dh-border, #2b3946);
  border-radius: 12px;
  background: transparent;
}
.dh-profile-details summary {
  display: block;
  position: relative;
  min-height: 56px;
  padding: 15px 28px 15px 0;
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 550;
  cursor: pointer;
  list-style: none;
}
.dh-profile-details summary::-webkit-details-marker { display: none; }
.dh-profile-details summary::after {
  content: '+';
  position: absolute;
  top: 13px;
  right: 0;
  font-size: 22px;
  color: var(--dh-muted, #a4b1bc);
}
.dh-profile-details[open] summary::after { content: '−'; }
.dh-profile-details > button:last-child,
.dh-profile-details > p { margin-bottom: 14px; }
.dh-profile-secondary,
.dh-profile-danger {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #40505e;
  border-radius: 12px;
  background: var(--dh-raised, #1c2935);
  color: var(--dh-text, #f1f5f7);
  font-weight: 550;
}
.dh-profile-danger { border-color: #89525b; background: #39242b; color: #ffb1b9; }
.dh-profile-footer {
  padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--dh-border, #2b3946);
  background: var(--dh-surface, #141e28);
}
.dh-profile-save {
  width: 100%;
  min-height: 52px !important;
  border: 0;
  border-radius: 12px;
  background: var(--dh-accent, #75d6bf);
  color: #102b25;
  font-weight: 650;
}
.dh-profile-footer > span {
  display: block;
  text-align: center;
  font-size: .875rem;
  line-height: 1.45;
  color: var(--dh-muted, #a4b1bc);
}
.dh-profile-privacy {
  display: flex;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  text-align: center;
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.5;
}
.dh-family-code {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--dh-border, #2b3946);
  border-radius: 12px;
  background: var(--dh-bg, #0d141b);
}
.dh-family-code > span { display: block; font-size: .9rem; color: var(--dh-muted, #a4b1bc); }
.dh-family-code strong {
  display: block;
  margin-top: 6px;
  color: var(--dh-text, #f1f5f7);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: .5px;
  overflow-wrap: anywhere;
}
.dh-family-preview {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid #3c695e;
  border-radius: 12px;
  background: #182c29;
  font-size: .9rem;
  line-height: 1.5;
}
.dh-family-preview p { margin-top: 8px; }
#profile-modal .dh-profile-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 12px;
  border: 1px solid var(--dh-border, #2b3946);
  border-radius: 12px;
}
#profile-modal input[type=checkbox] {
  width: 24px !important;
  height: 24px !important;
  min-height: 24px !important;
  flex-shrink: 0;
  accent-color: var(--dh-accent, #75d6bf);
}
#profile-modal .dh-profile-checkbox span { font-size: 1rem; line-height: 1.5; color: var(--dh-text, #f1f5f7); }
.dh-profile-feedback {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #3c695e;
  border-radius: 12px;
  background: #182c29;
  color: #d3eae3;
  font-size: .9rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.dh-profile-feedback.is-error { border-color: #89525b; background: #39242b; color: #ffbcc2; }

/* Keep the title clear when system text is enlarged. */
@media (max-width: 430px) {
  #profile-modal .dh-profile-header { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #profile-modal h2 { grid-column: 1 / -1; grid-row: 1; }
  #profile-modal .dh-profile-back { grid-column: 1; justify-self: start; }
  #profile-modal .dh-profile-close { grid-column: 2; justify-self: end; }
}
@media (max-width: 359px) {
  #profile-modal { padding: 8px; }
  .dh-profile-shell { height: min(660px, calc(100dvh - 16px)); border-radius: 16px; }
  #profile-modal .dh-profile-header { padding: 12px !important; }
  #profile-modal h2 { font-size: 1.1rem; }
  .dh-profile-body { padding: 16px 12px; scrollbar-gutter: auto; }
  .dh-profile-menu > button { grid-template-columns: 24px minmax(0, 1fr) 10px; padding: 14px 12px; gap: 10px; }
  .dh-profile-menu-icon { width: 24px; height: 24px; }
  .dh-profile-footer { padding-left: 12px; padding-right: 12px; }
}
@media (max-height: 500px) {
  #profile-modal { padding: 0; }
  .dh-profile-shell { height: 100dvh; border: 0; border-radius: 0; }
  #profile-modal .dh-profile-header { min-height: 60px; }
}

/* The menu needs only its content height; editing screens retain a fixed save bar. */
.dh-profile-shell:has(#profile-menu:not([hidden])){height:auto;max-height:calc(100dvh - 24px)}
@media(max-width:430px){#profile-modal .dh-profile-header:has(#profile-back-btn[hidden]){grid-template-columns:minmax(0,1fr) auto;gap:10px;min-height:70px}#profile-modal .dh-profile-header:has(#profile-back-btn[hidden]) h2{grid-column:1;grid-row:1;font-size:1.125rem}#profile-modal .dh-profile-header:has(#profile-back-btn[hidden]) .dh-profile-close{grid-column:2;grid-row:1}}
