/* MangaLib — compact reader UI (dark, high contrast) */
:root {
  --bg: #0a0a0c;
  --bg2: #12121a;
  --panel: #16161f;
  --line: rgba(255, 255, 255, 0.08);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.52);
  --accent: #e85d4c;
  --accent-dim: #b84436;
  --ok: #3ecf8e;
  --danger: #ff5c5c;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --space: 0.65rem;
  --header-h: 52px;
  --dock-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body.ml-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.ml-skip {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--accent);
  color: #fff;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  z-index: 100;
}
.ml-skip:focus { left: 0.5rem; }

.ml-header {
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
  height: var(--header-h);
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 12, 0.92);
  backdrop-filter: blur(10px);
  max-height: var(--header-h);
  transition: height 0.22s ease, max-height 0.22s ease, opacity 0.18s ease;
}
.ml-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.ml-brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
}
.ml-brand:hover { color: var(--accent); }

.ml-nav {
  display: flex;
  gap: 0.35rem;
  flex: 1;
  flex-wrap: wrap;
}
.ml-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
}
.ml-nav a:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.ml-btn--admin {
  border-color: rgba(240, 198, 116, 0.45);
  background: rgba(240, 198, 116, 0.14);
  color: #f0c674;
  text-decoration: none;
  flex-shrink: 0;
}
.ml-btn--admin:hover {
  background: rgba(240, 198, 116, 0.24);
  color: #fce8a6;
  border-color: rgba(240, 198, 116, 0.55);
}

.ml-header__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}
.ml-user { color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-logout { margin: 0; }
.ml-logout button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}
.ml-logout button:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }

.ml-flash-wrap {
  flex-shrink: 0;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 0.5rem 1rem 0;
}
.ml-flash {
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  margin-bottom: 0.35rem;
}
.ml-flash--error { background: rgba(255,92,92,0.12); color: #ffb4b4; border: 1px solid rgba(255,92,92,0.25); }
.ml-flash--success { background: rgba(62,207,142,0.1); color: #9cf0c9; border: 1px solid rgba(62,207,142,0.25); }
.ml-flash--warning { background: rgba(240,198,116,0.1); color: #f5e0b0; border: 1px solid rgba(240,198,116,0.25); }

.ml-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 1rem;
}
.ml-wrap--bleed { max-width: none; padding: 0; }

.ml-footer {
  flex-shrink: 0;
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 0.65rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.ml-footer__brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}
.ml-footer__muted { opacity: 0.7; }
.ml-footer__request {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
.ml-footer__request:hover {
  color: var(--accent-dim);
}

/* Footer → Request modal */
.ml-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}
.ml-modal:not([hidden]) {
  display: flex;
}
body.ml-modal-open {
  overflow: hidden;
}
.ml-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}
.ml-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(26rem, 100%);
  max-height: min(90vh, 36rem);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.ml-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}
.ml-modal__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.ml-modal__close {
  flex-shrink: 0;
  margin: 0;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.ml-modal__close:hover {
  color: var(--text);
}
.ml-modal__body {
  padding: 0.85rem 1rem 1rem;
  overflow-y: auto;
}
.ml-modal__form .ml-label > input,
.ml-modal__form .ml-label > select,
.ml-modal__form .ml-label > textarea {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}
.ml-modal__form .ml-label > textarea {
  resize: vertical;
  min-height: 5.5rem;
}
.ml-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.35rem;
}

/* Auth */
body.auth-page .ml-header { display: none; }
body.auth-page .ml-footer { justify-content: center; }
body.auth-page .ml-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
}
.ml-auth {
  display: grid;
  place-items: center;
  padding: 1.5rem;
  flex: 0 0 auto;
}
.ml-auth__panel {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.5rem;
}
.ml-auth__title { margin: 0 0 0.25rem; font-size: 1.35rem; letter-spacing: -0.03em; }
.ml-auth__sub { margin: 0 0 1rem; color: var(--muted); font-size: 0.85rem; }

/* Tab toggle: only one of login / register visible (no JS) */
.ml-auth-tab-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.ml-auth-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.25rem;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.ml-auth-tab {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.ml-auth-tab:hover { color: var(--text); }
#ml_auth_tab_login:checked ~ .ml-auth-tabs label[for="ml_auth_tab_login"],
#ml_auth_tab_register:checked ~ .ml-auth-tabs label[for="ml_auth_tab_register"] {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}
.ml-auth-panel {
  display: none;
}
.ml-auth-panel--solo { display: block; }
#ml_auth_tab_login:checked ~ .ml-auth-panel--login,
#ml_auth_tab_register:checked ~ .ml-auth-panel--register {
  display: block;
}
#ml_auth_tab_login:checked ~ .ml-auth-panel--register,
#ml_auth_tab_register:checked ~ .ml-auth-panel--login {
  display: none;
}
.ml-auth__foot { margin-top: 1rem; font-size: 0.85rem; }
.ml-auth__forgot {
  margin: 0.65rem 0 0;
  text-align: center;
}
.ml-auth__forgot .ml-btn {
  width: 100%;
  max-width: 16rem;
}
.ml-auth-panel__heading {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.ml-form { display: flex; flex-direction: column; gap: 0.65rem; }
.ml-form > .ml-btn {
  align-self: flex-start;
}
.ml-form--row { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.ml-label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.75rem; color: var(--muted); }
.ml-label input, .ml-input, .ml-select {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.5rem 0.65rem;
  font: inherit;
}
.ml-input--grow { flex: 1; min-width: 140px; }
.ml-input--sm { max-width: 140px; }
.ml-input:focus, .ml-select:focus, .ml-label input:focus { outline: 2px solid rgba(232,93,76,0.35); border-color: rgba(232,93,76,0.5); }

/* Email fields: full line width so long addresses stay readable */
.ml-label input[type="email"],
input.ml-input[type="email"] {
  width: 100%;
  min-width: min(100%, 16rem);
  max-width: 48rem;
  box-sizing: border-box;
}
.ml-form--row > .ml-label:has(input[type="email"]) {
  flex: 1 1 22rem;
  min-width: min(100%, 18rem);
  max-width: 100%;
}
.ml-admin-create-user .ml-label:has(input[type="email"]) {
  grid-column: 1 / -1;
}
@media (min-width: 720px) {
  .ml-admin-create-user .ml-label:has(input[type="email"]) {
    grid-column: span 2;
  }
}
/* Account page: one compact column (~½ of the 48rem cap used elsewhere for email) */
.ml-profile .ml-form:not(.ml-form--row) .ml-label > input:not([type="checkbox"]),
.ml-profile .ml-form:not(.ml-form--row) .ml-label > select,
.ml-profile .ml-form:not(.ml-form--row) .ml-label > textarea {
  width: 100%;
  max-width: min(24rem, 100%);
  min-width: 0;
  box-sizing: border-box;
}
.ml-profile .ml-form:not(.ml-form--row) .ml-label > textarea {
  resize: vertical;
  min-height: 6rem;
}
.ml-profile .ml-form--row > input.ml-input[type="text"] {
  flex: 0 1 min(24rem, 100%);
  width: 100%;
  max-width: min(24rem, 100%);
  min-width: 0;
  box-sizing: border-box;
}

.ml-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  text-decoration: none;
}
.ml-btn:hover { background: rgba(255,255,255,0.08); }
.ml-btn--small { padding: 0.35rem 0.55rem; font-size: 0.75rem; }
.ml-btn--primary { background: var(--accent); border-color: transparent; color: #fff; }
.ml-btn--primary:hover { background: var(--accent-dim); }
.ml-btn--ghost { background: transparent; }
.ml-btn--success { background: rgba(62,207,142,0.2); border-color: rgba(62,207,142,0.35); color: #9cf0c9; }
.ml-btn--danger { background: rgba(255,92,92,0.15); border-color: rgba(255,92,92,0.35); color: #ffb4b4; }
.ml-btn.is-disabled { opacity: 0.35; pointer-events: none; }

.ml-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--muted); cursor: pointer; }

/* Library */
.ml-page-head { margin-bottom: 1rem; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; }
.ml-page-head h1 { margin: 0; font-size: 1.25rem; letter-spacing: -0.02em; }
.ml-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; flex: 1; min-width: 200px; }

.ml-empty { color: var(--muted); text-align: center; padding: 2rem; }

.ml-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.65rem;
}
@media (min-width: 640px) {
  .ml-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 0.85rem; }
}

.ml-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ml-card__fav {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 2;
  margin: 0;
}
.ml-card__fav button {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.ml-card__cover {
  display: block;
  aspect-ratio: 3/4;
  background: var(--bg2);
}
.ml-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ml-card__ph {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 0.7rem;
}
.ml-card__meta { padding: 0.45rem 0.5rem 0.55rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.ml-card__title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ml-card__title a { color: inherit; text-decoration: none; }
.ml-card__title a:hover { color: var(--accent); }

.ml-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  font-size: 0.8125rem;
}
.ml-pager__disabled { color: var(--muted); opacity: 0.4; }
.ml-pager__info { color: var(--muted); }

/* Manga detail */
.ml-detail__hero {
  display: grid;
  grid-template-columns: minmax(0, 120px) minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: start;
}
@media (min-width: 480px) {
  .ml-detail__hero { grid-template-columns: minmax(0, 160px) minmax(0, 1fr); }
}
@media (min-width: 720px) {
  .ml-detail__hero { grid-template-columns: minmax(0, 200px) minmax(0, 1fr); }
}
.ml-detail__cover {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg2);
  align-self: start;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.ml-detail__cover img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: min(48vh, 440px);
  object-fit: contain;
  object-position: top center;
}
.ml-detail__info {
  min-width: 0;
}
.ml-detail__info h1 { margin: 0 0 0.5rem; font-size: 1.2rem; letter-spacing: -0.02em; }
.ml-detail__desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre-line;
  max-width: 52ch;
  word-break: break-word;
}
.ml-detail__stats {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}
.ml-badge {
  display: inline-block;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
}
.ml-badge--ok { background: rgba(62,207,142,0.15); color: #9cf0c9; }
.ml-muted { color: var(--muted); }
.ml-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  padding: 0;
  text-decoration: underline;
}
.ml-inline-form { display: inline; margin: 0; }

.ml-chlist {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.ml-chlist__row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}
.ml-chlist__row:last-child { border-bottom: 0; }
.ml-chlist__row:hover { background: rgba(255,255,255,0.03); }
.ml-chlist__link { color: var(--text); text-decoration: none; font-weight: 500; }
.ml-chlist__link:hover { color: var(--accent); }
.ml-chlist__state { font-size: 0.7rem; color: var(--muted); }
.ml-chlist__state.is-read { color: var(--ok); }

.ml-back { margin-top: 1rem; }
.ml-back a { color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.ml-back a:hover { color: var(--accent); }

/* Reader */
.ml-reader { padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px)); }
.ml-reader__bar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: rgba(10,10,12,0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 0.38rem 0.65rem 0.45rem;
  transition: transform 0.22s ease, top 0.22s ease;
  will-change: transform;
}
.ml-reader__back {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 0.15rem;
}
.ml-reader__back:hover { color: var(--accent); }
.ml-reader__title { margin: 0; font-size: 0.88rem; font-weight: 600; line-height: 1.25; }
.ml-reader__nav { margin-top: 0.3rem; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.ml-reader__prog {
  margin-top: 0.35rem;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow: hidden;
}
.ml-reader__prog span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.06s linear;
}

.ml-reader__pages {
  max-width: 860px;
  margin: 0 auto;
  padding: 0.5rem 0.65rem 1rem;
}
.ml-reader__fig { margin: 0 0 0.5rem; }
.ml-reader__fig img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.ml-reader__dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 0.45rem 0.65rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(10,10,12,0.98), rgba(10,10,12,0.88));
  border-top: 1px solid var(--line);
}
.ml-reader__dock-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  justify-content: space-between;
}
.ml-reader__pct { font-size: 0.72rem; color: var(--muted); margin-left: auto; }

body.ml-immersive .ml-header,
body.ml-immersive .ml-footer,
body.ml-immersive .ml-reader__bar {
  display: none !important;
}
body.ml-immersive .ml-reader { padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px)); }
body.ml-immersive { --header-h: 0px; }

/* Reader: collapse site header while scrolling down (chapter bar stays) */
body.ml-reader-hide-chrome:not(.ml-immersive) .ml-header {
  height: 0;
  max-height: 0;
  min-height: 0;
  opacity: 0;
  overflow: hidden;
  border-bottom-color: transparent;
  pointer-events: none;
}
body.ml-reader-hide-chrome:not(.ml-immersive) .ml-reader__bar {
  top: 0;
}

/* Profile & admin */
.ml-profile h1, .ml-admin h1 { margin: 0 0 0.35rem; font-size: 1.2rem; }
.ml-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.85rem;
}
.ml-panel h2 { margin: 0 0 0.65rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.ml-panel--danger { border-color: rgba(255,92,92,0.25); }
.ml-h3 { margin: 1rem 0 0.5rem; font-size: 0.8rem; color: var(--muted); }

.ml-profile__avatar img, .ml-profile__placeholder {
  width: 88px;
  height: 88px;
  border-radius: 999px;
  border: 1px solid var(--line);
  object-fit: cover;
}
.ml-profile__placeholder { background: var(--bg2); }

.ml-admin__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.85rem; }
.ml-statbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.ml-stat {
  flex: 1;
  min-width: 72px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem;
  text-align: center;
}
.ml-stat__v { display: block; font-weight: 700; font-size: 1rem; }
.ml-stat__k { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.ml-admin-overview-snapshot {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.5rem;
}
@media (min-width: 720px) {
  .ml-admin-overview-snapshot {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.ml-admin-overview-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
}
.ml-admin-overview-card__h {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.ml-table-wrap { overflow-x: auto; margin: 0 -0.25rem; }
.ml-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.ml-table th, .ml-table td { padding: 0.45rem 0.35rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.ml-table th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.05em; }
.ml-table th.ml-numeric, .ml-table td.ml-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.ml-table__actions { min-width: 220px; }
.ml-table__actions--wide { min-width: 0; max-width: 22rem; vertical-align: top; }
.ml-inline-row { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; margin-right: 0.35rem; margin-bottom: 0.25rem; }
.ml-user-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: stretch;
}
.ml-user-actions__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.ml-admin-create-user {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
  align-items: end;
  gap: 0.65rem 0.85rem;
  width: 100%;
  justify-items: stretch;
}
.ml-admin-create-user .ml-label--inline { margin: 0; }
.ml-admin-create-user .ml-btn {
  grid-column: 1 / -1;
  justify-self: start;
}
@media (min-width: 720px) {
  .ml-admin-create-user .ml-btn {
    grid-column: auto;
    align-self: end;
    justify-self: start;
  }
}
.ml-table-wrap--library { overflow-x: auto; }
.ml-tag {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  font-size: 0.7rem;
}

.ml-backuplist { list-style: none; margin: 0; padding: 0; }
.ml-backuplist li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
}
.ml-backuplist li:last-child { border-bottom: 0; }

/* Admin tabs (CSS-only, same pattern as auth) */
.ml-admin-tab-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.ml-admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.25rem;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.ml-admin-tab {
  flex: 1;
  min-width: 5rem;
  text-align: center;
  padding: 0.45rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.ml-admin-tab:hover { color: var(--text); }
#ml_admin_tab_overview:checked ~ .ml-admin-tabs label[for="ml_admin_tab_overview"],
#ml_admin_tab_users:checked ~ .ml-admin-tabs label[for="ml_admin_tab_users"],
#ml_admin_tab_settings:checked ~ .ml-admin-tabs label[for="ml_admin_tab_settings"],
#ml_admin_tab_backup:checked ~ .ml-admin-tabs label[for="ml_admin_tab_backup"],
#ml_admin_tab_library:checked ~ .ml-admin-tabs label[for="ml_admin_tab_library"],
#ml_admin_tab_requests:checked ~ .ml-admin-tabs label[for="ml_admin_tab_requests"],
#ml_admin_tab_system:checked ~ .ml-admin-tabs label[for="ml_admin_tab_system"] {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
.ml-admin-panel { display: none; }
#ml_admin_tab_overview:checked ~ .ml-admin-panel--overview,
#ml_admin_tab_users:checked ~ .ml-admin-panel--users,
#ml_admin_tab_settings:checked ~ .ml-admin-panel--settings,
#ml_admin_tab_backup:checked ~ .ml-admin-panel--backup,
#ml_admin_tab_library:checked ~ .ml-admin-panel--library,
#ml_admin_tab_requests:checked ~ .ml-admin-panel--requests,
#ml_admin_tab_system:checked ~ .ml-admin-panel--system {
  display: block;
}
.ml-hp-field {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.ml-admin-request-msg-cell {
  vertical-align: top;
  max-width: 22rem;
}
.ml-admin-req-view {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.2rem 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.12em;
  white-space: pre-wrap;
  word-break: break-word;
}
.ml-admin-req-view:hover {
  color: var(--accent);
}
.ml-admin-req-actions-th { min-width: 5.5rem; }
.ml-admin-req-actions-td { white-space: nowrap; vertical-align: top; }
.ml-admin-req-view-pre {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.75rem;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: min(50vh, 24rem);
  overflow: auto;
}
.ml-admin-req-view-meta { margin-bottom: 0; }

.ml-announce {
  flex-shrink: 0;
  background: rgba(120, 160, 255, 0.1);
  border-bottom: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--text);
}
.ml-announce__inner {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  line-height: 1.45;
}
.ml-sys-dl {
  display: grid;
  grid-template-columns: minmax(8rem, 11rem) 1fr;
  gap: 0.35rem 1rem;
  font-size: 0.8rem;
  margin: 0;
}
.ml-sys-dl dt { color: var(--muted); margin: 0; }
.ml-sys-dl dd { margin: 0; word-break: break-word; }
.ml-sys-ext { font-size: 0.72rem; color: var(--muted); line-height: 1.45; }
.ml-tag--totp {
  margin-left: 0.25rem;
  background: rgba(100, 200, 150, 0.12);
  border-color: rgba(100, 200, 150, 0.35);
}
.ml-totp-qr { max-width: 220px; margin: 0.5rem 0; }
.ml-totp-qr__img {
  display: block;
  width: 200px;
  height: 200px;
  max-width: 100%;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  box-sizing: content-box;
}
.ml-totp-qr__svgwrap { max-width: 220px; }
.ml-totp-qr__svgwrap svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}
.ml-totp-qr svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}
.ml-totp-secret { font-size: 0.78rem; }
.ml-panel--muted { border-style: dashed; opacity: 0.95; }
.ml-panel__subh {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.ml-code--break {
  display: inline-block;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ml-admin-alert {
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--line);
}
.ml-admin-alert--low {
  background: rgba(240, 198, 116, 0.08);
  border-color: rgba(240, 198, 116, 0.28);
  color: #f5e0b0;
}
.ml-admin-alert--critical {
  background: rgba(255, 92, 92, 0.08);
  border-color: rgba(255, 92, 92, 0.25);
  color: #ffb4b4;
}
.ml-admin-alert--warn {
  background: rgba(255, 180, 96, 0.08);
  border-color: rgba(255, 180, 96, 0.28);
  color: #f0dcc8;
}
.ml-admin-preq-list {
  margin: 0.4rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.8rem;
  line-height: 1.45;
}
.ml-admin-preq-list li { margin-bottom: 0.25rem; }
.ml-admin-preq-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.ml-admin-preq-badge--ok {
  color: #9dcda8;
  border-color: rgba(120, 200, 140, 0.35);
  background: rgba(120, 200, 140, 0.08);
}
.ml-admin-preq-badge--warn {
  color: #f0dcc8;
  border-color: rgba(255, 180, 96, 0.35);
  background: rgba(255, 180, 96, 0.08);
}
.ml-admin-preq-badge--error {
  color: #ffb4b4;
  border-color: rgba(255, 92, 92, 0.35);
  background: rgba(255, 92, 92, 0.08);
}
.ml-admin-preq-tr--error td { background: rgba(255, 92, 92, 0.05); }
.ml-admin-preq-tr--warn td { background: rgba(255, 180, 96, 0.05); }
.ml-admin-summary {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.55;
}
.ml-admin-summary li { margin-bottom: 0.35rem; }
.ml-admin-summary li:last-child { margin-bottom: 0; }
.ml-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
}
.ml-warn { color: #ffb4b4; }
.ml-usercell {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.ml-usercell__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.ml-usercell__email {
  font-size: 0.72rem;
  word-break: break-all;
}
.ml-usercell__email--dt {
  font-size: 0.8rem;
  line-height: 1.35;
  word-break: break-all;
}
.ml-usercell__avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.ml-usercell__avatar--ph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg2);
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
}
.ml-tag--admin {
  background: rgba(240, 198, 116, 0.12);
  color: #f0c674;
}
.ml-tag--auditor {
  background: rgba(140, 180, 255, 0.1);
  color: #b8cffc;
  border: 1px solid rgba(140, 180, 255, 0.28);
}
.ml-label--inline {
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.ml-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  margin: 0 0 0.85rem;
}
.ml-legend {
  padding: 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
.ml-table--compact { font-size: 0.72rem; }
.ml-table--compact th, .ml-table--compact td { padding: 0.3rem 0.25rem; }
.ml-admin-log-wrap { max-height: 14rem; overflow: auto; }
.ml-admin-log-details { max-width: 18rem; word-break: break-word; font-family: ui-monospace, monospace; font-size: 0.68rem; color: var(--muted); }
.ml-tag--danger {
  background: rgba(255, 92, 92, 0.12);
  color: #ffb4b4;
  border: 1px solid rgba(255, 92, 92, 0.28);
}
.ml-admin-filter-hint { margin: 0 0 0.35rem; font-size: 0.72rem; }
.ml-admin-orphan-filter {
  width: 100%;
  max-width: 320px;
  margin-bottom: 0.65rem;
}
.ml-admin-library-orphan.is-hidden { display: none; }
.ml-table-wrap--library { margin-bottom: 0.5rem; }
.ml-dt-library-wrap { margin-top: 0.35rem; }
.ml-dt-log-wrap { margin-top: 0.35rem; overflow-x: auto; }

/* DataTables — admin users (dark, compact) */
.ml-dt-users-wrap {
  margin-top: 0.35rem;
  overflow: visible !important;
  overflow-x: visible !important;
}
.ml-dt-users-wrap .dataTables_wrapper,
.ml-dt-users-wrap .dataTables_scroll,
.ml-dt-users-wrap .dataTables_scrollBody,
.ml-dt-users-wrap .dataTables_scrollHead {
  overflow: visible !important;
}
.admin-page .dataTables_wrapper { color: var(--text); font-size: 0.78rem; }
.admin-page .dataTables_wrapper .dataTables_length,
.admin-page .dataTables_wrapper .dataTables_filter,
.admin-page .dataTables_wrapper .dataTables_info,
.admin-page .dataTables_wrapper .dataTables_paginate {
  color: var(--muted);
  padding: 0.35rem 0;
}
.admin-page .dataTables_wrapper label { color: var(--muted); font-size: 0.75rem; }
.admin-page .dataTables_wrapper select,
.admin-page .dataTables_wrapper input[type="search"] {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.35rem 0.5rem;
  font: inherit;
  margin: 0 0.25rem;
}
.admin-page .dataTables_wrapper table.dataTable {
  border-collapse: collapse !important;
  background: transparent;
  overflow: visible !important;
}
.admin-page .ml-dt-users-wrap table.dataTable tbody {
  overflow: visible !important;
}
.admin-page .dataTables_wrapper table.dataTable thead th {
  background: var(--bg2);
  color: var(--muted);
  border-bottom: 1px solid var(--line) !important;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-page .dataTables_wrapper table.dataTable tbody td {
  border-bottom: 1px solid var(--line) !important;
  vertical-align: top;
  padding: 0.4rem 0.35rem !important;
}
.admin-page .dataTables_wrapper table.dataTable.stripe tbody tr.odd,
.admin-page .dataTables_wrapper table.dataTable.display tbody tr.odd {
  background-color: rgba(255, 255, 255, 0.02) !important;
}
.admin-page .dataTables_wrapper table.dataTable tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
}
.admin-page .dataTables_wrapper .dataTables_paginate .paginate_button {
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border-radius: var(--radius) !important;
}
.admin-page .dataTables_wrapper .dataTables_paginate .paginate_button.current,
.admin-page .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: rgba(232, 93, 76, 0.2) !important;
  border-color: rgba(232, 93, 76, 0.45) !important;
  color: var(--text) !important;
}
.admin-page .dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
  opacity: 0.35;
}
.ml-dt-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.25rem; }
.ml-dt-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.35rem; }
.ml-dt-th-actions { min-width: 7rem; }
.ml-dt-actions-td {
  white-space: nowrap;
  overflow: visible !important;
  position: relative;
  vertical-align: top;
}
.ml-dt-actions-col {
  overflow: visible !important;
}
.ml-dt-actions {
  position: relative;
  z-index: 1;
}
.ml-dt-actions[open] {
  z-index: 200;
}
.ml-dt-actions__summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.ml-dt-actions__summary::-webkit-details-marker { display: none; }
.ml-dt-actions__panel {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 300;
  margin-top: 0.35rem;
  width: min(24rem, calc(100vw - 1.25rem));
  min-width: 18rem;
  max-width: calc(100vw - 1rem);
  padding: 0.85rem 0.95rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
}
.ml-dt-actions__panel .ml-user-actions__row {
  flex-direction: column;
  align-items: stretch;
  margin: 0 0 0.55rem;
  gap: 0.45rem;
}
.ml-dt-actions__panel .ml-user-actions__row:last-child { margin-bottom: 0; }
.ml-dt-actions__panel .ml-btn {
  width: 100%;
  justify-content: center;
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
}
.ml-dt-actions__panel .ml-input {
  padding: 0.55rem 0.75rem;
  font-size: 0.84rem;
}
.ml-input--dt-pass {
  width: 100%;
  max-width: none;
  min-width: 0;
  box-sizing: border-box;
}
.ml-admin-orphan-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  font-size: 0.8rem;
}
.ml-admin-orphan-list li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--line);
}
.ml-admin-orphan-list li:last-child { border-bottom: 0; }
.ml-backup-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}
.ml-backuplist li { align-items: flex-start; }
.ml-backup-name { font-weight: 600; min-width: 0; word-break: break-all; }

/* Error pages (404 / 405) */
.ml-error-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
}
.ml-error-top__brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.ml-error-top__brand:hover { color: var(--accent); }
.ml-error-top__nav {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
}
.ml-error-top__nav a { color: var(--muted); }
.ml-error-top__nav a:hover { color: var(--accent); }
.ml-error-page {
  max-width: 28rem;
  margin: 2rem auto 3rem;
}
.ml-error-page__code {
  margin: 0 0 0.25rem;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  line-height: 1;
}
.ml-error-page__title {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  font-weight: 600;
}
.ml-error-page__lead { margin: 0 0 0.75rem; line-height: 1.5; }
.ml-error-page__path { margin: 0 0 1rem; font-size: 0.8125rem; }
.ml-error-page__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.ml-error-page__details { margin-top: 1rem; font-size: 0.8rem; color: var(--muted); }
.ml-error-page__details summary { cursor: pointer; color: var(--text); }
.ml-error-page__trace {
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.75rem;
  max-height: 40vh;
  overflow: auto;
  font-size: 0.72rem;
  line-height: 1.35;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
}
