: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;
}

.library-header {
  border-bottom: 1px solid #eadcf7;
}

.library-banner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px;
}

.library-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.library-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 8px;
  background: linear-gradient(135deg, #8b4fd0, #6a34ad);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.library-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 72px;
}

.library-title {
  margin: 0 0 28px;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--purple);
}

.catalog-status {
  color: var(--muted);
  text-align: center;
  padding: 48px 0;
}

.library-section {
  margin-bottom: 40px;
}

.library-section-title {
  margin: 0 0 18px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--purple);
}

.library-section-title span {
  color: var(--purple-dark);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
}

.library-card {
  display: flex;
  flex-direction: column;
  border: 1px solid #eadcf7;
  border-radius: 14px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
  min-height: 100%;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.library-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(91, 44, 143, 0.12);
}

.library-cover {
  aspect-ratio: 3 / 4;
  background: #f7f2fc;
  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: var(--muted);
  font-size: 0.9rem;
}

.library-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 14px 14px 16px;
}

.library-card-title {
  margin: 0 0 10px;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.4;
}

.library-desc {
  flex: 1;
  margin: 0 0 14px;
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 5.2em;
}

.library-desc.empty {
  color: #b7b7b7;
  font-style: italic;
}

.library-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid #eadcf7;
  margin: 0 -14px -16px;
}

.library-meta span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.library-meta span + span {
  border-left: 1px solid #eadcf7;
}

.library-empty {
  grid-column: 1 / -1;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #eadcf7;
  border-radius: 12px;
}

.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: var(--purple-dark);
}

.password-dialog-hint {
  margin: 0 0 18px;
  color: var(--muted);
  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-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .library-title {
    font-size: 1.6rem;
  }
}

@media (max-width: 480px) {
  .library-grid {
    grid-template-columns: 1fr;
  }
}
