:root {
  color-scheme: light;
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #1f1a14;
  --muted: #666666;
  --purple: #7b3fbf;
  --purple-dark: #5f2f97;
  --purple-soft: #f4ecfb;
  --border: #e4d8f2;
  --shadow: 0 10px 30px rgba(91, 44, 143, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans TC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--purple);
  color: #fff;
  border: none;
}

.btn.ghost {
  border: 1px solid var(--border);
  color: var(--ink);
  background: #fff;
}

.btn.danger {
  background: #b33a3a;
  color: #fff;
  border: none;
}

.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.85rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-title {
  margin: 4px 0 0;
  font-size: 1.6rem;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--purple);
}

.library-page {
  background: #fff;
  font-family: "Noto Sans TC", system-ui, sans-serif;
  color: #2a2430;
}

.library-header {
  border-bottom: 1px solid #eee6f5;
}

.library-banner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.library-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.library-logo-img {
  display: block;
  width: auto;
  max-width: 220px;
  max-height: 72px;
  height: auto;
  object-fit: contain;
}

.library-logo-mark {
  font-family: "Noto Serif TC", "Noto Sans TC", serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #6b2fa0;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.library-logo-sub {
  font-size: 0.78rem;
  color: #8a6aa8;
  letter-spacing: 0.12em;
}

.library-header-ad {
  min-width: 0;
}

.library-main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.catalog-status {
  color: #888;
  text-align: center;
  padding: 48px 0;
}

.library-section {
  margin-bottom: 28px;
}

.library-section-title {
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  font-family: "Noto Serif TC", "Noto Sans TC", serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #6b2fa0;
  text-align: left;
}

.library-section-title::before,
.library-section-title::after {
  content: "";
  width: 3px;
  height: 1.1em;
  background: #c45c5c;
  border-radius: 2px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
}

.library-card {
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 24px rgba(40, 20, 60, 0.08);
  min-height: 100%;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.library-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(40, 20, 60, 0.12);
}

.library-cover {
  aspect-ratio: 3 / 4;
  background: #f4eef8;
  overflow: hidden;
}

.library-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.library-cover-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #999;
  font-size: 0.9rem;
}

.library-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 14px 14px 16px;
}

.library-card-title {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: #2a2430;
}

.library-desc {
  flex: 1;
  margin: 0 0 12px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #777;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 3.9em;
}

.library-desc.empty {
  color: #bbb;
  font-style: italic;
}

.library-meta {
  display: flex;
  gap: 14px;
  font-size: 0.8rem;
  color: #999;
}

.library-empty {
  grid-column: 1 / -1;
  padding: 24px;
  text-align: center;
  color: #999;
  border: 1px dashed #e5d8f0;
  border-radius: 12px;
}

.ad-banner {
  display: block;
  max-width: 1240px;
  width: 100%;
  margin: 8px auto 36px;
  border-radius: 6px;
  overflow: hidden;
  background: #f6f2fa;
  aspect-ratio: 1240 / 290;
}

.ad-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ad-banner.is-link {
  cursor: pointer;
}

.ad-banner:focus-visible {
  outline: 2px solid #6b2fa0;
  outline-offset: 3px;
}

.library-footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  text-align: center;
  color: #888;
  font-size: 0.85rem;
  line-height: 1.8;
  border-top: 1px solid #eee6f5;
}

.library-footer a {
  color: #6b2fa0;
  text-decoration: none;
}

.library-footer a:hover {
  text-decoration: underline;
}

.password-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
  box-shadow: 0 24px 60px rgba(67, 42, 18, 0.18);
}

.password-dialog::backdrop {
  background: rgba(31, 26, 20, 0.45);
}

.password-dialog-inner {
  padding: 24px;
}

.password-dialog-inner h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: #5a2788;
}

.password-dialog-hint {
  margin: 0 0 18px;
  color: #777;
  font-size: 0.92rem;
  line-height: 1.6;
}

.password-field {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.password-field span {
  font-size: 0.88rem;
  font-weight: 600;
}

.password-field input {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
}

.password-error {
  margin: 0 0 12px;
  color: #b33a3a;
  font-size: 0.88rem;
}

.password-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 1024px) {
  .library-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .library-banner {
    grid-template-columns: 1fr;
  }

  .library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .library-section-title {
    font-size: 1.15rem;
  }
}

@media (max-width: 480px) {
  .library-grid {
    grid-template-columns: 1fr;
  }
}

