/* ── Variables ────────────────────────────────────────────────────────────── */

:root {
  --bg:        #111;
  --surface:   #1c1c1c;
  --sidebar:   #161616;
  --text:      #ddd;
  --text-dim:  #7a7a7a;
  --accent:    #6b8fd9;
  --accent-ink: #0d1220;
  --border:    #2a2a2a;
  --shadow:    rgba(0, 0, 0, 0.3);
  --sidebar-w: 220px;
}

:root[data-theme="light"] {
  --bg:       #f2f2f7;
  --surface:  #fff;
  --sidebar:  #fafafa;
  --text:     #1c1c1e;
  --text-dim: #74747c;
  --accent:   #4568c4;
  --accent-ink: #fff;
  --border:   #e2e2e8;
  --shadow:   rgba(30, 30, 45, 0.08);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.15s, color 0.15s;
}
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.3; cursor: default; }
input[type="search"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  padding: 0.4rem 0.7rem;
  width: 100%;
}
input[type="search"]:focus { border-color: var(--accent); }

/* ── Library page layout ──────────────────────────────────────────────────── */

body.page-library { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 300;
  transition: transform 0.22s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0.9rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
}
.logo:hover { text-decoration: none; opacity: 0.8; }
.sidebar-close {
  border: none;
  font-size: 1.1rem;
  padding: 0.1rem 0.4rem;
  display: none; /* hidden on desktop */
}


.sidebar-nav { flex: 1; padding: 0.5rem 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 0;
  padding: 0.55rem 0.9rem;
  font-size: 0.88rem;
  color: var(--text);
  background: transparent;
  transition: background 0.12s;
}
.nav-item:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text); border-color: transparent; }
.nav-item.active { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-weight: 600; }

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  padding: 0.9rem 0.9rem 0.3rem;
  text-transform: uppercase;
}

.series-list { display: flex; flex-direction: column; }
.series-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 0;
  padding: 0.5rem 0.9rem 0.5rem 1.3rem;
  font-size: 0.85rem;
  color: var(--text);
  background: transparent;
  gap: 0.5rem;
  transition: background 0.12s;
}
.series-item:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text); border-color: transparent; }
.series-item.active { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-weight: 600; }
.series-count { font-size: 0.72rem; color: var(--text-dim); flex-shrink: 0; }

.nav-loading { font-size: 0.8rem; color: var(--text-dim); padding: 0.5rem 1.3rem; }

.library-groups { display: flex; flex-direction: column; }
.library-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 0;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  transition: background 0.12s;
}
.library-group-header:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.library-group-arrow { font-size: 0.7rem; color: var(--text-dim); width: 0.8em; flex-shrink: 0; }
.library-group-series { display: flex; flex-direction: column; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 0.6rem 0.5rem;
  flex-shrink: 0;
}
.footer-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  border: none;
  border-radius: 6px;
}

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 290;
}
.sidebar-overlay.visible { display: block; }

/* Main content */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}
.main-header.header-hidden { transform: translateY(-100%); }
.hamburger { border: none; font-size: 1.2rem; padding: 0.2rem 0.4rem; display: none; }
.breadcrumb { display: flex; align-items: center; gap: 0.4rem; }
.breadcrumb-back {
  border: none; background: none; padding: 0;
  font-size: 0.88rem; color: var(--accent); cursor: pointer;
}
.breadcrumb-back:hover { text-decoration: underline; color: var(--accent); border-color: transparent; }
.breadcrumb-sep { color: var(--text-dim); font-size: 0.88rem; }
.view-title { font-size: 1rem; font-weight: 600; }
.header-theme-switcher { margin-left: auto; flex-shrink: 0; }
.logout-btn.header-logout-btn { margin-left: 0.6rem; flex-shrink: 0; }
.cover-placeholder { width: 100%; aspect-ratio: 2/3; background: var(--border); }

/* Filter bar (search + genre chips) */
.filter-bar {
  padding: 0.75rem 1.25rem 0.6rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.search-row input[type="search"] {
  flex: 1;
  max-width: 480px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
}
#btn-search {
  padding: 0.45rem 1.1rem;
  font-size: 0.88rem;
  border-color: var(--accent);
  color: var(--accent);
  flex-shrink: 0;
}
#btn-search:hover { background: var(--accent); color: var(--accent-ink); }
.genre-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 1.6rem;
}
.genre-label {
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  flex-shrink: 0;
}
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.tag-chips-empty {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
}
.tag-chip {
  padding: 0.25rem 0.75rem;
  font-size: 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Books grid */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1.25rem;
  padding: 1.5rem;
}
.book-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 1px 2px var(--shadow);
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.book-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px var(--shadow); }
.book-card a { display: block; color: inherit; }
.book-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: var(--border);
}
.book-card { position: relative; }
.book-card-link { display: block; text-decoration: none; }
.book-card-link:hover { text-decoration: none; }

.book-tag-btn {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  background: rgba(0,0,0,.45);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.book-card:hover .book-tag-btn { opacity: 1; }

.tag-editor-popup {
  position: fixed;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  width: 220px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.tag-editor-title {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-editor-list { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.55rem; min-height: 1.2rem; }
.tag-editor-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  border-radius: 99px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
}
.tag-rm {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.7;
}
.tag-rm:hover { opacity: 1; }
.tag-editor-add { display: flex; gap: 0.4rem; }
.tag-editor-input {
  flex: 1;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  min-width: 0;
}
.tag-editor-save {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.book-info { padding: 0.6rem 0.7rem; }
.book-title {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author { font-size: 0.72rem; color: var(--text-dim); margin-top: 0.2rem; }
.book-series { font-size: 0.7rem; color: var(--accent); margin-top: 0.15rem; }

.empty-msg { padding: 4rem; text-align: center; color: var(--text-dim); font-size: 0.95rem; }

/* ── Reader page ──────────────────────────────────────────────────────────── */

body.page-reader { display: flex; flex-direction: column; min-height: 100vh; }

.app-chrome,
.app-chrome * {
  writing-mode: horizontal-tb !important;
  text-orientation: mixed !important;
  direction: ltr !important;
  font-family: system-ui, sans-serif !important;
  color: var(--text) !important;
}
.app-chrome a, .app-chrome a:visited { color: var(--accent) !important; }

.reader-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  transition: transform 0.25s ease;
}
.reader-nav.header-hidden { transform: translateY(-100%); }

/* HTML-library content is never theme-aware — pin the (now-transparent)
   chrome's text/buttons to the light palette always, since the book's own
   background is virtually always light regardless of the site-wide theme. */
body.html-reader-chrome .reader-nav,
body.html-reader-chrome .reader-bottom-nav {
  --text:       #1c1c1e;
  --text-dim:   #74747c;
  --accent:     #4568c4;
  --accent-ink: #fff;
  --border:     #e2e2e8;
}
.nav-home { flex-shrink: 0; font-size: 0.85rem; }
.nav-title { flex: 1; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-info { flex-shrink: 0; font-size: 0.8rem; color: var(--text-dim); }
.nav-buttons { display: flex; gap: 0.4rem; flex-shrink: 0; }
.nav-buttons button { padding: 0.35rem 0.9rem; }
.nav-buttons button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

#reader-content { flex: 1; }

/* Fixed-layout (manga) mode */
body.fixed-layout-mode {
  overflow: hidden;
}
body.fixed-layout-mode .reader-bottom-nav {
  display: none;
}

#reader-content.hltr,
#reader-content.h-ltr {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  line-height: 1.85;
}

#reader-content.vrtl,
#reader-content.v-rtl {
  height: calc(100vh - 44px);
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1.5rem 2rem;
}

/* Text-level reading bookmark */
mark.reading-mark {
  background: rgba(255, 130, 170, 0.38);
  color: inherit;
  border-radius: 2px;
  cursor: pointer;
}

/* Bookmark remove popup */
.bm-popup {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.bm-popup button {
  padding: 0.3rem 0.75rem;
  background: #c0404a;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
  white-space: nowrap;
}
.bm-popup button:hover { background: #a03038; }

.reader-bottom-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.reader-bottom-nav button { padding: 0.35rem 0.9rem; }
.reader-bottom-nav span { font-size: 0.8rem; color: var(--text-dim); }

/* ── TOC panel ────────────────────────────────────────────────────────────── */

.toc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 290;
}
.toc-overlay.visible { display: block; }

.toc-panel {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: right 0.25s ease;
}
.toc-panel.open { right: 0; }

.toc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.toc-panel-title { font-size: 0.9rem; font-weight: 600; }
.toc-close {
  border: none;
  font-size: 1rem;
  padding: 0.1rem 0.4rem;
}

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}
.toc-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.84rem;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.1s;
}
.toc-item:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  border-color: transparent;
}
.toc-item:disabled { color: var(--text-dim); cursor: default; }

/* ── Book progress overlay ────────────────────────────────────────────────── */

.book-card.in-progress img { opacity: 0.72; }
.book-progress-bar-wrap { padding: 0 0.7rem 0.5rem; }
.book-progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.book-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.book-progress-pct {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
  text-align: right;
}

/* ── Login page ───────────────────────────────────────────────────────────── */

body.page-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-wrap {
  width: 100%;
  max-width: 360px;
  padding: 2rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 1rem;
  box-shadow: 0 8px 28px var(--shadow);
}
.login-logo {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.login-tab {
  flex: 1;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0.55rem;
  font-size: 0.88rem;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.login-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.login-form { display: flex; flex-direction: column; gap: 0.75rem; }
.login-field { display: flex; flex-direction: column; gap: 0.3rem; }
.login-field label { font-size: 0.8rem; color: var(--text-dim); }
.login-field input {
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.login-field input:focus { border-color: var(--accent); }
.login-submit {
  margin-top: 0.25rem;
  padding: 0.6rem;
  font-size: 0.9rem;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 6px;
  font-weight: 600;
}
.login-submit:hover { opacity: 0.9; color: var(--accent-ink); }
.login-error {
  font-size: 0.82rem;
  color: #e07070;
  margin: 0;
}

/* ── Settings page ────────────────────────────────────────────────────────── */

body.page-settings { max-width: 1080px; margin: 0 auto; padding: 0 1.5rem 3rem; }

.settings-page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.back-link { font-size: 0.88rem; color: var(--accent); }
.settings-page-title { font-size: 1.1rem; font-weight: 700; }

.settings-layout { display: flex; align-items: flex-start; gap: 2.5rem; }

.settings-nav {
  flex: 0 0 170px;
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.settings-nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.settings-nav-link:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--text); }
.settings-nav-link.active {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font-weight: 600;
}

.settings-page-main { flex: 1; min-width: 0; }

.settings-section {
  display: none;
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  /* no fill — nested rows/cards already use --surface to stand out against
     the page background; filling this too would make them blend in */
}
.settings-section.active { display: block; }
.settings-section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 720px) {
  .settings-layout { flex-direction: column; gap: 1rem; }
  .settings-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px var(--shadow);
}
.settings-row-label { font-size: 0.9rem; }

.theme-switcher { display: flex; gap: 0.4rem; }
.theme-opt { padding: 0.35rem 0.9rem; font-size: 0.85rem; border-radius: 6px; }
.theme-opt.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.settings-libraries { display: flex; flex-direction: column; gap: 0.75rem; }

.library-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: var(--surface);
  box-shadow: 0 1px 2px var(--shadow);
}
.library-card-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.2rem; }
.library-card-path { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.7rem; word-break: break-all; }
.library-card-footer { display: flex; align-items: center; justify-content: space-between; }
.library-card-count { font-size: 0.8rem; color: var(--text-dim); }
.sync-btn { padding: 0.35rem 1rem; font-size: 0.82rem; }
.job-delete-btn {
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  margin-left: auto;
  color: #e07070;
  border-color: color-mix(in srgb, #e07070 40%, transparent);
}
.job-delete-btn:hover:not(:disabled) { background: color-mix(in srgb, #e07070 12%, transparent); }

.job-current-volume {
  font-size: 0.78rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.job-status-pending { color: var(--text-dim); }
.job-status-running { color: var(--accent); font-weight: 600; }
.job-status-done     { color: #4caf7d; font-weight: 600; }
.job-status-failed   { color: #e07070; font-weight: 600; }

.upload-progress-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.6rem;
}
.upload-progress-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease-out;
}
.upload-progress-fill.indeterminate {
  width: 40% !important;
  animation: upload-indeterminate 1.1s ease-in-out infinite;
}
@keyframes upload-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
.upload-progress-label { font-size: 0.78rem; color: var(--text-dim); white-space: nowrap; }

.settings-page-header {
  position: relative;
}
.logout-btn {
  margin-left: auto;
  padding: 0.35rem 0.9rem;
  font-size: 0.82rem;
  color: #e07070;
  border-color: #e07070;
}
.logout-btn:hover { background: #e07070; color: #fff; border-color: #e07070; }

.settings-users { display: flex; flex-direction: column; gap: 0.5rem; }
.user-row { gap: 0.75rem; }
.user-info { display: flex; align-items: center; gap: 0.5rem; flex: 1; }
.user-name { font-size: 0.9rem; font-weight: 500; }
.user-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  text-transform: uppercase;
}
.user-badge-you { background: transparent; color: var(--text-dim); }
.user-actions { display: flex; gap: 0.4rem; }
.user-del-btn { padding: 0.3rem 0.7rem; font-size: 0.8rem; color: #e07070; border-color: #e07070; }
.user-del-btn:hover { background: #e07070; color: #fff; }

.user-create-form { align-items: center; }
.user-input {
  flex: 1;
  min-width: 120px;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.user-input:focus { border-color: var(--accent); }
.user-admin-label { font-size: 0.83rem; display: flex; align-items: center; gap: 0.3rem; }

.user-pwd-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  flex-wrap: wrap;
}
.user-pwd-btn, .user-admin-toggle { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* Sidebar footer link styled as button */
.footer-link {
  display: block;
  text-align: left;
  color: var(--text);
  text-decoration: none;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.15s, color 0.15s;
}
.footer-link:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ── Mobile ───────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .main-wrap { margin-left: 0; }
  .hamburger { display: block; }
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.9rem; padding: 1rem; }
}
