:root {
  --color-brand-emerald-dark: #0D5C3F;
  --color-brand-emerald: #127151;
  --color-brand-emerald-light: #1A8A67;
  --color-brand-gold: #D4AF37;
  --color-brand-gold-light: #FFD700;
  --color-brand-gold-dark: #C5A80C;
  --color-danger: #8B2E2E;

  --page-bg: #f9f7f0;
  --page-bg-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23d4af37' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
  --surface-base: #FFF8E7;
  --surface-elevated: #ffffff;
  --surface-muted: #f8f9fa;
  --surface-soft: rgba(212, 175, 55, 0.1);
  --text-primary: #2B2B2B;
  --text-heading: #4A2C0F;
  --text-secondary: #6A4521;
  --text-tertiary: #8B6D47;
  --text-muted-theme: rgba(74, 44, 15, 0.7);
  --border-soft: rgba(74, 44, 15, 0.1);
  --border-strong: rgba(74, 44, 15, 0.2);
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.08);
  --link-color: var(--color-brand-emerald);
  --link-hover-color: var(--color-brand-emerald-dark);

  --emerald-dark: var(--color-brand-emerald-dark);
  --emerald: var(--color-brand-emerald);
  --emerald-light: var(--color-brand-emerald-light);
  --gold: var(--color-brand-gold);
  --gold-light: var(--color-brand-gold-light);
  --gold-dark: var(--color-brand-gold-dark);
  --cream: var(--surface-base);
  --brown-dark: var(--text-heading);
  --brown-medium: var(--text-secondary);
  --brown-light: var(--text-tertiary);
  --red-accent: var(--color-danger);
  --text-dark: var(--text-primary);
}

body[data-theme='dark'] {
  --color-brand-emerald-dark: #0b6b51;
  --color-brand-emerald: #1da97a;
  --color-brand-emerald-light: #42c99a;
  --color-brand-gold: #d1aa47;
  --color-brand-gold-light: #f2ce73;
  --color-brand-gold-dark: #a98733;
  --color-danger: #cf6679;

  --page-bg: #12181d;
  --page-bg-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23d1aa47' fill-opacity='0.045' fill-rule='evenodd'/%3E%3C/svg%3E");
  --surface-base: #1b2328;
  --surface-elevated: #243039;
  --surface-muted: #2d3943;
  --surface-soft: rgba(209, 170, 71, 0.12);
  --text-primary: #e5ebf0;
  --text-heading: #f6f1e8;
  --text-secondary: #cfdae3;
  --text-tertiary: #a9bac7;
  --text-muted-theme: rgba(207, 218, 227, 0.74);
  --border-soft: rgba(207, 218, 227, 0.12);
  --border-strong: rgba(207, 218, 227, 0.2);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.28);
  --link-color: #6fd7b2;
  --link-hover-color: #9de7cd;
}

html {
  color-scheme: light;
}

body[data-theme='dark'] {
  color-scheme: dark;
}

body[data-theme='dark'] .card,
body[data-theme='dark'] .library-card,
body[data-theme='dark'] .top-book-card,
body[data-theme='dark'] .modal-content,
body[data-theme='dark'] .dropdown-menu,
body[data-theme='dark'] .list-group-item,
body[data-theme='dark'] .page-link {
  background-color: var(--surface-base) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-soft) !important;
}

body[data-theme='dark'] .card-header,
body[data-theme='dark'] .card-footer,
body[data-theme='dark'] .card-header.bg-light,
body[data-theme='dark'] .modal-header,
body[data-theme='dark'] .modal-footer {
  background-color: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-soft) !important;
}

body[data-theme='dark'] .form-control,
body[data-theme='dark'] .form-select,
body[data-theme='dark'] textarea,
body[data-theme='dark'] .input-group-text {
  background-color: var(--surface-elevated) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
}

body[data-theme='dark'] .form-control:focus,
body[data-theme='dark'] .form-select:focus,
body[data-theme='dark'] textarea:focus {
  background-color: var(--surface-elevated) !important;
  color: var(--text-primary) !important;
  border-color: var(--gold-dark) !important;
}

body[data-theme='dark'] .form-control::placeholder,
body[data-theme='dark'] textarea::placeholder {
  color: var(--text-muted-theme) !important;
}

body[data-theme='dark'] .text-brown-dark {
  color: var(--text-primary) !important;
}

body[data-theme='dark'] .form-label,
body[data-theme='dark'] .form-check-label,
body[data-theme='dark'] .input-group:focus-within .input-group-text,
body[data-theme='dark'] .preferences-page .btn-outline-secondary:hover {
  color: var(--text-primary) !important;
}

body[data-theme='dark'] input:-webkit-autofill,
body[data-theme='dark'] input:-webkit-autofill:hover,
body[data-theme='dark'] input:-webkit-autofill:focus,
body[data-theme='dark'] textarea:-webkit-autofill,
body[data-theme='dark'] select:-webkit-autofill {
  -webkit-text-fill-color: var(--text-primary) !important;
  transition: background-color 9999s ease-out 0s;
  box-shadow: 0 0 0 1000px var(--surface-elevated) inset !important;
}

body[data-theme='dark'] .table,
body[data-theme='dark'] .table td,
body[data-theme='dark'] .table th {
  color: var(--text-primary);
}

body[data-theme='dark'] .table-light,
body[data-theme='dark'] .table-light > :not(caption) > * > * {
  --bs-table-bg: var(--surface-muted);
  --bs-table-color: var(--text-primary);
  --bs-table-border-color: var(--border-soft);
  color: var(--text-primary) !important;
}

body[data-theme='dark'] .table thead th,
body[data-theme='dark'] .table thead td,
body[data-theme='dark'] .library-table th {
  background-color: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-soft) !important;
}

body[data-theme='dark'] .bg-light,
body[data-theme='dark'] .table-light,
body[data-theme='dark'] .table-light th,
body[data-theme='dark'] .table-light td,
body[data-theme='dark'] .card-header.bg-light,
body[data-theme='dark'] .modal-footer.bg-light {
  color: #ffffff !important;
}

body[data-theme='dark'] .badge.bg-light {
  color: #ffffff !important;
}

body[data-theme='dark'] code,
body[data-theme='dark'] pre,
body[data-theme='dark'] kbd,
body[data-theme='dark'] samp,
body[data-theme='dark'] .developer-dashboard-page code,
body[data-theme='dark'] .developer-dashboard-page pre,
body[data-theme='dark'] .debug-pre {
  background-color: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-soft) !important;
}

body {
  background-color: var(--page-bg) !important;
  background-image: var(--page-bg-pattern) !important;
  color: var(--text-dark);
  transition: background-color 0.25s ease, color 0.25s ease;
}

a {
  color: var(--link-color);
}

a:hover {
  color: var(--link-hover-color);
}

.text-muted {
  color: var(--text-muted-theme) !important;
}

.bg-light,
.table-light,
.table-light th,
.table-light td,
.card-header.bg-light,
.modal-footer.bg-light {
  background-color: var(--surface-muted) !important;
  color: var(--brown-dark) !important;
}

.bg-white {
  background-color: var(--surface-elevated) !important;
}

.card,
.dropdown-menu,
.modal-content,
.list-group-item,
.page-link,
.top-book-card {
  background-color: var(--surface-base);
  color: var(--brown-dark);
  border-color: var(--border-soft) !important;
}

.dropdown-divider,
hr {
  border-color: var(--border-soft);
}

.dropdown-item,
.dropdown-item-text,
.page-link,
.list-group-item {
  color: var(--brown-dark);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: rgba(26, 138, 103, 0.12);
  color: var(--brown-dark);
}

body[data-theme='dark'] .dropdown-item,
body[data-theme='dark'] .dropdown-item-text {
  color: var(--text-primary) !important;
}

body[data-theme='dark'] .dropdown-item:hover,
body[data-theme='dark'] .dropdown-item:focus {
  color: #ffffff !important;
  background-color: rgba(111, 215, 178, 0.22);
}

.form-control,
.form-select,
.form-check-input,
.input-group-text,
textarea {
  background-color: var(--surface-elevated);
  color: var(--brown-dark);
  border-color: var(--border-strong);
}

.form-control::placeholder,
textarea::placeholder {
  color: var(--text-muted-theme);
}

.form-control:focus,
.form-select:focus,
textarea:focus {
  background-color: var(--surface-elevated);
  color: var(--brown-dark);
  border-color: var(--gold-dark);
}

.alert-success {
  background-color: rgba(29, 169, 122, 0.16);
  color: var(--text-primary);
  border-color: rgba(29, 169, 122, 0.28);
}

.alert-danger {
  background-color: rgba(207, 102, 121, 0.16);
  color: var(--text-primary);
  border-color: rgba(207, 102, 121, 0.28);
}

.alert-warning {
  background-color: rgba(209, 170, 71, 0.16);
  color: var(--brown-dark);
  border-color: rgba(209, 170, 71, 0.28);
}

.badge.bg-light {
  background-color: var(--surface-muted) !important;
  color: var(--brown-dark) !important;
}

.table {
  color: var(--brown-dark);
}

.table > :not(caption) > * > * {
  border-bottom-color: var(--border-soft);
}
