.mley-account {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-body);
  color: var(--text-color);
  font: var(--text-body)/1.5 var(--font-ui);
}

.mley-account-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .25rem 1rem;
  padding: .5rem clamp(1rem, 4vw, 3rem);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.mley-account-header a { display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; }
.mley-account-header a:first-child { color: var(--text-color); font-weight: 700; text-decoration: none; }
.mley-account-header span { padding: .12rem .4rem; border-radius: .4rem; background: var(--surface-accent); color: var(--accent-color); }

.mley-account-card {
  box-sizing: border-box;
  width: min(27rem, calc(100% - 2rem));
  margin: clamp(1rem, 6vw, 4rem) auto;
  padding: clamp(1rem, 5vw, 2rem);
  border: 1px solid var(--border-color);
  border-radius: .85rem;
  background: var(--bg-surface);
  overflow-wrap: anywhere;
}

.mley-account-kicker { margin: 0; font-weight: 650; color: var(--accent-color); }
.mley-account-card h1 { margin: .25rem 0 1rem; line-height: 1.12; }
.mley-account-intro, .mley-account-help { color: var(--text-muted); }
.mley-account-field { display: grid; gap: .35rem; margin-block: 1rem; }
.mley-account-field label { font-weight: 650; }
.mley-account-help { font-size: var(--text-small); }
.mley-account-help ul, .mley-account-error ul { margin: 0; padding-inline-start: 1.2rem; }
.mley-account-error { border-radius: .4rem; padding: .6rem .75rem; background: var(--chip-danger-bg); color: var(--chip-danger-text); }

.mley-account :where(input:not([type=hidden]), button) {
  box-sizing: border-box;
  min-width: 0;
  min-height: 44px;
  padding: .55rem .75rem;
  border: 1px solid var(--border-strong);
  border-radius: .5rem;
  background: var(--bg-surface);
  color: var(--text-color);
  font: inherit;
}

.mley-account button {
  border-color: var(--accent-color);
  background: var(--surface-accent);
  color: var(--accent-color);
  font-weight: 700;
  cursor: pointer;
}

.mley-account button:hover { background: var(--bg-surface-3); }
.mley-account :is(a, button, input):focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.mley-account-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem 1rem; }
.mley-account-actions a { display: inline-flex; align-items: center; min-height: 44px; }

.mley-account-card > form + .mley-account-actions { margin-block-start: .75rem; }

.mley-account-card--login h1 { text-align: center; margin: 0 0 1.25rem; }
.mley-login-providers {
  margin-top: .75rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
}
.mley-login-providers > :only-child { grid-column: 1 / -1; }
.mley-login-providers button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
}
.mley-login-providers svg { display: block; flex: none; }
.mley-login-providers button:disabled {
  border-color: var(--border-color);
  background: var(--surface-muted);
  color: var(--text-muted);
  cursor: default;
}
.mley-login-preview {
  margin: .45rem 0 0;
  color: var(--text-muted);
  font-size: var(--text-small);
  text-align: center;
}
.mley-account-card--login .mley-account-field { margin-block: .65rem; }
.mley-account button.mley-login-submit {
  width: 100%;
  margin-top: .25rem;
  background: var(--accent-color);
  color: var(--bg-surface);
}
.mley-account button.mley-login-submit:hover { filter: brightness(.92); }
.mley-login-links { justify-content: space-between; gap: 0 .75rem; }

/* Match institution mentions without attaching the reader's popover behavior. */
.mley-account a {
  color: var(--institution-mention-color);
  text-decoration: underline dotted currentColor 1px;
  text-underline-offset: .18em;
  text-decoration-skip-ink: auto;
}
@media (hover: hover) {
  .mley-account a:hover {
    color: var(--institution-mention-hover);
    text-decoration-style: solid;
  }
}
.mley-account a:focus-visible {
  outline-color: var(--institution-mention-color);
  border-radius: 2px;
}

.mley-login-password { display: grid; gap: .25rem; }
.mley-account button.mley-login-reveal {
  justify-self: end;
  padding-inline: .25rem;
  border-color: transparent;
  background: transparent;
  font-size: var(--text-small);
}
.mley-account button.mley-login-reveal:hover { text-decoration: underline; }
.mley-account button.mley-login-submit:disabled {
  background: var(--surface-muted);
  color: var(--text-muted);
  border-color: var(--border-color);
  cursor: wait;
  filter: none;
}

.mley-account-module {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
  width: min(64rem, calc(100% - 2rem));
  margin: clamp(1rem, 4vw, 3rem) auto;
}
.mley-account-module .mley-account-card { width: 100%; margin: 0; }
.mley-account-sidebar {
  display: grid;
  gap: .25rem;
  padding: .75rem;
  border: 1px solid var(--border-color);
  border-radius: .85rem;
  background: var(--bg-surface);
}
.mley-account-sidebar .mley-account-kicker { padding: .25rem .65rem; }
.mley-account-sidebar a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 .65rem;
  border-radius: .5rem;
}
.mley-account-module a[aria-current="page"] {
  background: var(--surface-accent);
  font-weight: 700;
  text-decoration-style: solid;
}
.mley-profile-avatar {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: var(--surface-accent);
  color: var(--accent-color);
  font-weight: 700;
}
.mley-profile-details { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.mley-profile-details dt, .mley-profile-details small { color: var(--text-muted); }
.mley-profile-details dd { margin: 0; }
.mley-account-feedback {
  padding: .6rem .8rem;
  border-radius: .5rem;
  color: var(--chip-success-text);
  background: var(--chip-success-bg);
}
.mley-library-list { list-style: none; padding: 0; }
.mley-library-list li {
  display: grid;
  gap: .25rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border-color);
}
.mley-library-list small { color: var(--text-muted); }
.mley-library-filter { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem; }
.mley-library-filter label { grid-column: 1 / -1; font-weight: 650; }
.mley-account-remove { margin-block: .85rem; }
.mley-account-remove summary { cursor: pointer; }
.mley-account-module input[type="checkbox"] { min-height: auto; accent-color: var(--accent-color); }
.mley-account-module input[type="color"] { width: 4rem; }
.mley-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .mley-account-module { grid-template-columns: minmax(0, 1fr); }
  .mley-account-sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mley-account-sidebar .mley-account-kicker { grid-column: 1 / -1; }
}

.mley-module-heading, .mley-security-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem 1rem;
}
.mley-module-heading h2, .mley-security-row h2 { margin: 0; font-size: var(--text-section); }
.mley-module-heading > a, .mley-library-back { display: inline-flex; align-items: center; min-height: 44px; }
.mley-profile-heading h1 { margin: 0; }
.mley-profile-details {
  padding: .75rem 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--border-color);
  border-radius: .65rem;
}
.mley-module-section, .mley-security-row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}
.mley-module-section h2 { margin: 0 0 .75rem; font-size: var(--text-section); }
.mley-compendium-list { list-style: none; margin: .25rem 0 0; padding: 0; }
.mley-compendium-list li + li { margin-top: .4rem; }
.mley-account .mley-compendium-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: .6rem;
  min-height: 44px;
  padding: .45rem .65rem;
  border: 1px solid var(--border-color);
  border-radius: .55rem;
  background: var(--surface-muted);
  text-decoration: none;
}
.mley-account .mley-compendium-row:hover { border-color: var(--institution-mention-hover); }
.mley-compendium-dot {
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--compendium-color);
}
.mley-compendium-name {
  font-weight: 650;
  text-decoration: underline dotted;
  text-underline-offset: .18em;
}
.mley-compendium-row:hover .mley-compendium-name { text-decoration-style: solid; }
.mley-library-count {
  display: inline-block;
  padding: .12rem .4rem;
  border-radius: .4rem;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: var(--text-caption);
}
.mley-module-section .mley-account-actions a { gap: .3rem; padding-inline: .4rem; border-radius: .45rem; }

.mley-compendium-picker { max-width: 24rem; }
.mley-compendium-picker [hidden] { display: none; }
.mley-account .mley-compendium-picker .mley-folder-custom-color input[type="color"] { width: 100%; }
@media (max-width: 360px) {
  .mley-compendium-picker .mley-folder-colors__grid { gap: .25rem; }
}

.mley-login-providers form { margin: 0; }
.mley-login-providers form button { width: 100%; }
