@media (max-width: 700px) {
  #page-profile { padding: 1rem; }
}
#page-profile { min-height: 0; overflow: hidden; }
#settings-page-root { width: 100%; height: 100%; min-height: 0; }
.profile-page { display: flex; flex-direction: column; gap: 1rem; width: 100%; height: 100%; min-height: 0; max-width: 76rem; margin: 0 auto; overflow-y: auto; }
.profile-page-heading { display: flex; flex: 0 0 auto; align-items: center; gap: 0.75rem; padding: 1.15rem 1.25rem; border: 1px solid rgba(148,163,184,0.24); border-radius: 1.25rem; background: rgba(255,255,255,0.97); box-shadow: 0 20px 50px rgba(15,23,42,0.12); }
.profile-page-heading h1 { margin: 0; color: #0f172a; font-size: 1.6rem; font-weight: 800; }
.profile-page-heading > div > p { margin: 0.2rem 0 0; color: #64748b; font-size: 0.85rem; }
.profile-settings-container { display: flex; flex: 1 0 auto; flex-direction: column; gap: 0.9rem; padding: 1.25rem; border: 1px solid rgba(148,163,184,0.24); border-radius: 1.25rem; background: rgba(255,255,255,0.97); }
.profile-settings-grid { display: grid; flex: 1 0 auto; grid-template-columns: repeat(2, minmax(0,1fr)); align-content: start; }
.profile-panel { min-width: 0; padding: 1rem 1.25rem; }
.profile-picture-panel, .profile-theme-panel { border-bottom: 1px solid #e2e8f0; }
.profile-picture-panel { border-right: 1px solid #e2e8f0; }
.profile-section-heading { display: flex; align-items: center; gap: 0.75rem; }
.profile-section-heading h2 { margin: 0; color: #0f172a; font-size: 1rem; font-weight: 800; }
.profile-section-heading p { margin: 0.18rem 0 0; color: #64748b; font-size: 0.78rem; }
.profile-section-icon { display: flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; border-radius: 0.8rem; font-size: 1rem; }
.profile-picture-heading-icon { flex: 0 0 auto; color: #0f172a; font-size: 2.5rem; line-height: 1; }
.profile-appearance-heading-icon { flex: 0 0 auto; color: #0f172a; font-size: 2.5rem; line-height: 1; }
.profile-feedback-heading-icon { flex: 0 0 auto; color: #0f172a; font-size: 2.5rem; line-height: 1; }
.profile-icon-blue { background: #dbeafe; color: #1d4ed8; }
.profile-icon-purple { background: #ede9fe; color: #7c3aed; }
.profile-picture-panel { display: flex; flex-direction: column; align-items: center; }
.profile-picture-panel .profile-section-heading { align-self: stretch; }
.profile-picture-preview { display: flex; align-items: center; justify-content: center; width: 7rem; height: 7rem; margin: 1.25rem 0 0.9rem; overflow: hidden; border: 3px solid #dbeafe; border-radius: 50%; background: linear-gradient(135deg, #1e3a8a, #3b82f6); color: #fff; font-size: 2rem; font-weight: 800; }
.profile-picture-preview img, .profile-sidebar-picture { width: 100%; height: 100%; object-fit: cover; }
.profile-primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.65rem 1rem; border: 0; border-radius: 0.7rem; background: #002147; color: #fff; font: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer; transition: background 160ms ease; }
.profile-primary-button:hover { background: #123b65; }
.profile-error { min-height: 1rem; margin: 0.5rem 0 0; color: #b91c1c; font-size: 0.75rem; text-align: center; }
.profile-theme-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0.75rem; margin-top: 1.25rem; }
.profile-theme-option { display: flex; flex-direction: column; align-items: center; gap: 0.55rem; padding: 0.7rem; border: 2px solid #e2e8f0; border-radius: 0.9rem; background: #fff; color: #334155; font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; }
.profile-theme-option:hover { border-color: #93c5fd; }
.profile-theme-option.is-selected { border-color: #002147; color: #002147; }
.profile-theme-swatch { display: flex; align-items: center; justify-content: center; width: 100%; height: 4.5rem; border: 1px solid #cbd5e1; border-radius: 0.55rem; font-size: 1.25rem; }
.profile-light-swatch { background: linear-gradient(135deg, #fff 50%, #e2e8f0 50%); color: #001F36; }
.profile-dark-swatch { border-color: #334155; background: linear-gradient(135deg, #0f172a 50%, #1e293b 50%); color: #ffffff; }
.profile-feedback-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border: 1px solid #e2e8f0; border-radius: 1rem; background: #f8fafc; }
.profile-feedback-overlay { position: fixed; z-index: 1000; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(15,23,42,0.58); }
.profile-feedback-dialog { box-sizing: border-box; display: flex; flex-direction: column; width: min(32rem, calc(100vw - 2rem)); height: min(38rem, calc(100vh - 2rem)); overflow: hidden; border: 1px solid #dbe3ed; border-radius: 1.25rem; background: #fff; box-shadow: 0 24px 70px rgba(15,23,42,0.3); color: #0f172a; }
.profile-feedback-heading { display: flex; flex: 0 0 auto; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.4rem; border-bottom: 1px solid #e2e8f0; }
.profile-feedback-heading h2 { margin: 0; font-size: 1.2rem; font-weight: 800; }
.profile-feedback-heading p { margin: 0.35rem 0 0; color: #64748b; font-size: 0.82rem; line-height: 1.4; }
.profile-feedback-close { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 2rem; height: 2rem; border: 0; border-radius: 0.55rem; background: transparent; color: #64748b; font-size: 1rem; cursor: pointer; }
.profile-feedback-close:hover { background: #f1f5f9; color: #0f172a; }
.profile-feedback-form { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; padding: 1.1rem 1.4rem 1.25rem; }
.profile-feedback-fields { display: flex; flex: 1 1 auto; flex-direction: column; gap: 0.85rem; min-height: 0; overflow-y: auto; padding: 0.1rem 0.15rem 0.75rem 0; }
.profile-feedback-field { display: flex; flex: 0 0 auto; flex-direction: column; gap: 0.4rem; margin: 0; padding: 0; border: 0; color: #334155; font-size: 0.8rem; font-weight: 700; }
.profile-feedback-field input:not([type="radio"]), .profile-feedback-field select, .profile-feedback-field textarea { box-sizing: border-box; width: 100%; border: 1px solid #cbd5e1; border-radius: 0.65rem; outline: none; background: #fff; color: #0f172a; font: inherit; font-weight: 400; }
.profile-feedback-field input:not([type="radio"]), .profile-feedback-field select { height: 2.65rem; padding: 0 0.75rem; }
.profile-grade-field { position: relative; }
.profile-grade-trigger { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 2.65rem; padding: 0 0.75rem; border: 1px solid #cbd5e1; border-radius: 0.65rem; outline: none; background: #fff; color: #0f172a; font: inherit; font-size: 0.82rem; font-weight: 400; text-align: left; cursor: pointer; }
.profile-grade-trigger:hover { border-color: #94a3b8; }
.profile-grade-trigger:focus, .profile-grade-trigger[aria-expanded="true"] { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.14); }
.profile-grade-trigger[aria-invalid="true"] { border-color: #dc2626; }
.profile-grade-trigger i { color: #64748b; font-size: 0.72rem; transition: transform 160ms ease; }
.profile-grade-trigger[aria-expanded="true"] i { transform: rotate(180deg); }
.profile-grade-options { position: absolute; z-index: 2; top: calc(100% + 0.35rem); right: 0; left: 0; max-height: min(15rem, 32vh); overflow-y: auto; margin: 0; padding: 0.3rem; border: 1px solid #dbe3ed; border-radius: 0.7rem; background: #fff; box-shadow: 0 12px 28px rgba(15,23,42,0.18); list-style: none; }
.profile-grade-options li { padding: 0.55rem 0.65rem; border-radius: 0.45rem; color: #334155; font-size: 0.82rem; font-weight: 500; cursor: pointer; outline: none; }
.profile-grade-options li:hover, .profile-grade-options li:focus { background: #eff6ff; color: #1d4ed8; }
.profile-grade-options li[aria-selected="true"] { background: #dbeafe; color: #1e40af; font-weight: 700; }
.profile-feedback-field textarea { min-height: 6rem; flex: 1 1 auto; resize: none; padding: 0.7rem 0.75rem; line-height: 1.45; }
.profile-feedback-field input:focus, .profile-feedback-field select:focus, .profile-feedback-field textarea:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.14); }
.profile-feedback-types { gap: 0.6rem; }
.profile-feedback-types legend { margin-bottom: 0.45rem; }
.profile-feedback-types label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; cursor: pointer; }
.profile-feedback-types input { width: 1rem; height: 1rem; margin: 0; accent-color: #002147; }
.profile-feedback-message { flex: 1 0 auto; min-height: 8rem; }
.profile-feedback-status { flex: 0 0 auto; min-height: 1.1rem; margin: 0.55rem 0; color: #166534; font-size: 0.75rem; line-height: 1.4; }
.profile-feedback-actions { display: flex; flex: 0 0 auto; justify-content: flex-end; gap: 0.65rem; padding-top: 0.8rem; border-top: 1px solid #e2e8f0; }
.profile-feedback-secondary { padding: 0.65rem 1rem; border: 1px solid #cbd5e1; border-radius: 0.7rem; background: #fff; color: #334155; font: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer; }
.profile-feedback-secondary:hover { background: #f8fafc; }
.profile-settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 0.85rem; border-top: 1px solid #e2e8f0; }
.profile-credits { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.4rem 1rem; color: #64748b; font-size: 0.72rem; }
.profile-logout-area { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 0.25rem; }
.profile-logout-button { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 0.5rem; padding: 0.6rem 0.8rem; border: 1px solid #fecaca; border-radius: 0.7rem; background: #fef2f2; color: #b91c1c; font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; transition: background 160ms ease, border-color 160ms ease; }
.profile-logout-button:hover { border-color: #f87171; background: #fee2e2; }
.profile-logout-status { max-width: 18rem; color: #b91c1c; font-size: 0.68rem; text-align: right; }
.app-dark .profile-page-heading h1, .app-dark .profile-section-heading h2 { color: #f1f5f9; }
.app-dark .profile-page-heading > div > p, .app-dark .profile-section-heading p { color: #a8b6c8; }
.app-dark .profile-page-heading { border-color: #002147; background: #001a38; }
.app-dark .profile-theme-option { border-color: #123b65; background: #002147; color: #e2e8f0; }
.app-dark .profile-theme-option.is-selected { border-color: #60a5fa; color: #bfdbfe; }
.app-dark .profile-picture-preview { border-color: #334155; }
.app-dark .profile-settings-container { border-color: #002147; background: #001a38; }
.app-dark .profile-picture-panel, .app-dark .profile-theme-panel, .app-dark .profile-settings-footer { border-color: #123b65; }
.app-dark .profile-icon-blue { background: #002147; color: #78aef8; }
.app-dark .profile-picture-heading-icon { color: #fff; }
.app-dark .profile-appearance-heading-icon { color: #fff; }
.app-dark .profile-feedback-heading-icon { color: #fff; }
.app-dark .profile-icon-purple { background: #002147; color: #c4a5ff; }
.app-dark .profile-feedback-panel { border-color: #123b65; background: #002147; }
.app-dark .profile-feedback-panel .profile-primary-button { background: #fff; color: #002147; }
.app-dark .profile-feedback-panel .profile-primary-button:hover { background: #e2e8f0; }
.app-dark .profile-feedback-dialog { border-color: #123b65; background: #001a38; color: #f1f5f9; }
.app-dark .profile-feedback-heading { border-color: #123b65; }
.app-dark .profile-feedback-heading p { color: #a8b6c8; }
.app-dark .profile-feedback-close { color: #a8b6c8; }
.app-dark .profile-feedback-close:hover { background: #002147; color: #fff; }
.app-dark .profile-feedback-field { color: #dbe5f1; }
.app-dark .profile-feedback-field input:not([type="radio"]), .app-dark .profile-feedback-field select, .app-dark .profile-feedback-field textarea { border-color: #24466b; background: #002147; color: #f1f5f9; }
.app-dark .profile-grade-trigger { border-color: #24466b; background: #002147; color: #f1f5f9; }
.app-dark .profile-grade-trigger:hover { border-color: #4775a6; }
.app-dark .profile-grade-trigger i { color: #a8b6c8; }
.app-dark .profile-grade-options { border-color: #24466b; background: #001a38; }
.app-dark .profile-grade-options li { color: #dbe5f1; }
.app-dark .profile-grade-options li:hover, .app-dark .profile-grade-options li:focus { background: #123b65; color: #bfdbfe; }
.app-dark .profile-grade-options li[aria-selected="true"] { background: #123b65; color: #bfdbfe; }
.app-dark .profile-feedback-secondary { border-color: #24466b; background: #002147; color: #e2e8f0; }
.app-dark .profile-feedback-secondary:hover { background: #123b65; }
.app-dark .profile-feedback-status { color: #86efac; }
.app-dark .profile-feedback-actions { border-color: #123b65; }
.app-dark .profile-credits { color: #8595aa; }
.app-dark .profile-logout-button { border-color: #773540; background: #321e29; color: #f28b98; }
.app-dark .profile-logout-button:hover { border-color: #a94e5a; background: #40232f; }
.app-dark .profile-logout-status { color: #f28b98; }

@media (max-width: 700px) {
  .profile-settings-grid { grid-template-columns: minmax(0,1fr); }
  .profile-picture-panel { border-right: 0; }
  .profile-feedback-panel { align-items: flex-start; flex-direction: column; }
  .profile-feedback-panel .profile-primary-button { align-self: stretch; }
  .profile-settings-footer { align-items: stretch; flex-direction: column; }
  .profile-logout-area { align-items: flex-start; }
  .profile-logout-status { text-align: left; }
  .profile-credits { flex-direction: column; gap: 0.25rem; }
}

@media (max-height: 600px) {
  .profile-feedback-overlay { padding: 0.5rem; }
  .profile-feedback-dialog { height: calc(100vh - 1rem); }
}

@media (min-width: 701px) and (max-height: 700px) {
  .profile-settings-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

.profile-theme-label { margin: 1.1rem 0 -0.65rem; color: #64748b; font-size: 0.75rem; font-weight: 800; }
.profile-color-options { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0.5rem; margin-top: 0.85rem; }
.profile-color-option { display: flex; min-width: 0; flex-direction: column; align-items: center; gap: 0.35rem; padding: 0.45rem 0.2rem; border: 2px solid transparent; border-radius: 0.7rem; background: transparent; color: #334155; font: inherit; font-size: 0.68rem; font-weight: 700; cursor: pointer; }
.profile-color-option:hover { background: #f8fafc; }
.profile-color-option.is-selected { border-color: var(--portal-accent, #002147); color: var(--portal-accent-ink, #002147); }
.profile-color-option:focus-visible { outline: 2px solid var(--portal-accent, #2563eb); outline-offset: 2px; }
.profile-color-swatch { display: block; width: 1.7rem; height: 1.7rem; border: 2px solid rgba(15,23,42,0.12); border-radius: 50%; background: #002147; box-shadow: inset 0 0 0 3px #fff; }
.profile-color-default { background: #002147; }
.profile-color-pink { background: #db4b91; }
.profile-color-purple { background: #8b5cf6; }
.profile-color-orange { background: #f97316; }
.profile-color-green { background: #22a95b; }
.profile-color-cyan { background: #06a6c8; }
.profile-color-yellow { background: #e0a800; }
.profile-color-red { background: #ed4b4b; }

body[data-color-theme]:not([data-color-theme="default"]) .profile-primary-button {
  background: var(--portal-accent);
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-primary-button:hover {
  background: var(--portal-accent-hover);
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-theme-option:hover {
  border-color: var(--portal-accent-border);
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-theme-option.is-selected {
  border-color: var(--portal-accent);
  color: var(--portal-accent-ink);
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-picture-preview {
  border-color: var(--portal-accent-border);
  background: linear-gradient(135deg, var(--portal-accent-hover), var(--portal-accent));
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-picture-heading-icon,
body[data-color-theme]:not([data-color-theme="default"]) .profile-appearance-heading-icon,
body[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-heading-icon {
  color: var(--portal-accent);
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-panel {
  border-color: var(--portal-accent-border);
  background: var(--portal-accent-soft);
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-field input:focus,
body[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-field select:focus,
body[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-field textarea:focus,
body[data-color-theme]:not([data-color-theme="default"]) .profile-grade-trigger:focus,
body[data-color-theme]:not([data-color-theme="default"]) .profile-grade-trigger[aria-expanded="true"] {
  border-color: var(--portal-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--portal-accent) 18%, transparent);
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-types input {
  accent-color: var(--portal-accent);
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-grade-options li:hover,
body[data-color-theme]:not([data-color-theme="default"]) .profile-grade-options li:focus,
body[data-color-theme]:not([data-color-theme="default"]) .profile-grade-options li[aria-selected="true"] {
  background: var(--portal-accent-soft);
  color: var(--portal-accent-ink);
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-actions {
  border-color: var(--portal-accent-border);
}
body[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-secondary:hover {
  background: var(--portal-accent-soft);
}
body.app-dark .profile-color-default {
  background: #fff;
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-color-option {
  color: #dbe5f1;
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-color-option:hover {
  background: var(--portal-accent-soft);
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-color-option.is-selected,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-theme-option.is-selected {
  border-color: var(--portal-accent);
  color: var(--portal-accent-ink);
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-color-swatch {
  border-color: rgba(255,255,255,0.24);
  box-shadow: inset 0 0 0 3px #001a38;
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-theme-label {
  color: #a8b6c8;
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-picture-heading-icon,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-appearance-heading-icon,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-heading-icon {
  color: var(--portal-accent-ink);
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-panel {
  border-color: var(--portal-accent-border);
  background: var(--portal-accent-soft);
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-panel .profile-primary-button {
  border-color: var(--portal-accent);
  background: var(--portal-accent);
  color: #fff;
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-panel .profile-primary-button:hover {
  background: var(--portal-accent-hover);
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-grade-options li:hover,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-grade-options li:focus,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-grade-options li[aria-selected="true"] {
  background: var(--portal-accent-soft);
  color: var(--portal-accent-ink);
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-secondary:hover {
  background: var(--portal-accent-soft);
  color: var(--portal-accent-ink);
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-page-heading,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-settings-container,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-dialog,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-grade-options {
  border-color: var(--portal-accent-border);
  background: var(--portal-dark-surface);
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-field input:not([type="radio"]),
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-field select,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-field textarea,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-grade-trigger,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-secondary {
  border-color: var(--portal-accent-border);
  background: color-mix(in srgb, var(--portal-accent) 5%, var(--portal-dark-surface));
}
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-heading,
body.app-dark[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-actions {
  border-color: var(--portal-accent-border);
}
body:not(.app-dark)[data-color-theme]:not([data-color-theme="default"]) .profile-page-heading,
body:not(.app-dark)[data-color-theme]:not([data-color-theme="default"]) .profile-settings-container,
body:not(.app-dark)[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-dialog {
  border-color: var(--portal-accent-border);
  background: var(--portal-light-surface);
}
body:not(.app-dark)[data-color-theme]:not([data-color-theme="default"]) .profile-feedback-panel {
  background: var(--portal-light-surface-strong);
}
body:not(.app-dark)[data-color-theme]:not([data-color-theme="default"]) .profile-theme-option.is-selected {
  background: color-mix(in srgb, var(--portal-accent) 7%, #fff);
}
body:not(.app-dark)[data-color-theme]:not([data-color-theme="default"]) .profile-color-default {
  background: #002147;
}

@media (max-width: 420px) {
  .profile-color-options { gap: 0.25rem; }
  .profile-color-option { font-size: 0.62rem; }
}
