* {
  box-sizing: border-box;
}

:root {
  --navy-950: #020617;
  --navy-900: #0f172a;
  --navy-800: #1e293b;
  --navy-700: #334155;

  --page-bg: #f1f5f9;
  --card-bg: #ffffff;
  --soft-bg: #f8fafc;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --blue-text: #1d4ed8;

  --green: #16a34a;
  --green-soft: #dcfce7;
  --green-text: #166534;

  --purple-soft: #ede9fe;
  --purple-text: #6d28d9;

  --amber-soft: #fef3c7;
  --amber-text: #92400e;

  --red: #dc2626;
  --red-dark: #991b1b;

  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --shadow-small: 0 8px 22px rgba(15, 23, 42, 0.06);

  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 12px;

  --max-width: 1180px;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  background: var(--page-bg);
  color: var(--text-main);
}

a {
  color: inherit;
}

/* PUBLIC HEADER */

.public-header {
  background: linear-gradient(135deg, var(--navy-950), var(--navy-900));
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.public-header-inner {
  width: min(var(--max-width), 92%);
  margin: 0 auto;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: white;
  text-decoration: none;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.18);
  border: 1px solid rgba(147, 197, 253, 0.3);
  color: #bfdbfe;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.public-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.public-nav a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  padding: 9px 12px;
  border-radius: 999px;
}

.public-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.public-nav .admin-link {
  background: white;
  color: var(--navy-900);
}

.public-nav .admin-link:hover {
  background: #e2e8f0;
  color: var(--navy-950);
}

/* PUBLIC PAGE */

.library-page {
  width: min(var(--max-width), 92%);
  margin: 0 auto;
  padding: 46px 0 74px;
}

.library-hero {
  max-width: 760px;
  margin-bottom: 28px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--blue-text);
  background: var(--blue-soft);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 16px;
}

.library-hero h1 {
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1;
  letter-spacing: -0.05em;
  margin: 0 0 16px;
  color: var(--text-main);
}

.library-hero p {
  max-width: 690px;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1.65;
  margin: 0;
}

.library-search-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow);
  margin: 32px 0 26px;
}

.library-search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 22px;
}

.library-search-row input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--soft-bg);
  padding: 15px 16px;
  font-size: 16px;
  color: var(--text-main);
}

.library-search-row input::placeholder {
  color: var(--text-soft);
}

.library-search-row input:focus {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  border-color: var(--blue);
  background: white;
}

.library-search-row button {
  border: none;
  border-radius: var(--radius-md);
  background: var(--navy-900);
  color: white;
  padding: 0 24px;
  font-weight: 800;
  cursor: pointer;
}

.library-search-row button:hover {
  background: var(--navy-800);
}

.filter-block {
  margin-top: 20px;
}

.filter-label {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--navy-800);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.filter-chip:hover {
  border-color: var(--border-strong);
  background: #f1f5f9;
}

.filter-chip.active {
  background: var(--navy-900);
  border-color: var(--navy-900);
  color: white;
}

.filter-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
}

.clear-link {
  color: var(--blue-text);
  font-weight: 800;
  text-decoration: none;
}

.clear-link:hover {
  text-decoration: underline;
}

.results-toolbar {
  color: var(--text-muted);
  margin: 28px 0 18px;
}

.results-toolbar p {
  margin: 0;
}

.result-section {
  margin-top: 34px;
}

.section-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.section-heading-row h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.result-count {
  background: white;
  border: 1px solid var(--border);
  color: var(--navy-800);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.quote-card-grid,
.article-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.library-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-small);
}

.quote-library-card {
  display: flex;
  flex-direction: column;
}

.quote-card-text {
  font-size: 19px;
  line-height: 1.55;
  margin: 0 0 18px;
  letter-spacing: -0.01em;
}

.quote-card-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.muted-text {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 14px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.tag-pill {
  display: inline-flex;
  background: var(--blue-soft);
  color: var(--blue-text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.tag-pill:nth-child(5n + 1) {
  background: var(--blue-soft);
  color: var(--blue-text);
}

.tag-pill:nth-child(5n + 2) {
  background: var(--green-soft);
  color: var(--green-text);
}

.tag-pill:nth-child(5n + 3) {
  background: var(--purple-soft);
  color: var(--purple-text);
}

.tag-pill:nth-child(5n + 4) {
  background: var(--amber-soft);
  color: var(--amber-text);
}

.tag-pill:nth-child(5n + 5) {
  background: #e2e8f0;
  color: var(--navy-700);
}

.blue-pill {
  background: var(--blue-soft);
  color: var(--blue-text);
}

.source-line {
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.45;
  margin-top: auto;
}

.source-title {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
  margin: 8px 0 0;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.dark-button,
.light-button {
  border: none;
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dark-button {
  background: var(--navy-900);
  color: white;
}

.dark-button:hover {
  background: var(--navy-800);
}

.light-button {
  background: #f1f5f9;
  color: var(--navy-800);
  border: 1px solid var(--border);
}

.light-button:hover {
  background: #e2e8f0;
}

.link-button {
  color: var(--blue-text);
}

.article-library-card h3 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
}

.article-source {
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0 0 12px;
}

.summary-preview {
  color: var(--text-main);
  line-height: 1.6;
  margin: 16px 0;
}

.article-details {
  margin-top: 16px;
}

.article-details summary {
  display: inline-flex;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--navy-800);
  padding: 10px 13px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.article-details summary:hover {
  background: #f1f5f9;
}

.article-details[open] summary {
  background: var(--navy-900);
  border-color: var(--navy-900);
  color: white;
}

.details-content {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.article-section {
  margin-top: 18px;
}

.article-section h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.article-section p {
  line-height: 1.55;
  color: var(--text-main);
}

.doi-link {
  display: inline-block;
  color: var(--blue-text);
  font-weight: 800;
  text-decoration: none;
  margin-top: 12px;
}

.doi-link:hover {
  text-decoration: underline;
}

.mini-quote {
  background: var(--soft-bg);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 12px;
}

.mini-quote p {
  margin-top: 0;
}

.empty-card {
  color: var(--text-muted);
}

/* ADMIN PAGES */

.site-header {
  background: var(--navy-900);
  color: white;
  padding: 42px 24px;
}

.header-inner,
.page,
.site-footer {
  width: min(1100px, 92%);
  margin: 0 auto;
}

.site-header h1 {
  color: white;
  margin: 0;
  font-size: 38px;
  letter-spacing: -0.03em;
}

.subtitle {
  color: #cbd5e1;
  margin-top: 10px;
  font-size: 17px;
}

.page {
  padding: 32px 0;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-small);
  margin-bottom: 22px;
}

.admin-form {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.form-group {
  display: grid;
  gap: 7px;
}

.form-group label {
  font-weight: 800;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 15px;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

.form-group textarea {
  resize: vertical;
}

.field-help {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.primary-button {
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  background: var(--navy-900);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:hover {
  background: var(--navy-800);
}

.secondary-link {
  color: var(--blue-text);
  font-weight: 800;
  text-decoration: none;
}

.secondary-link:hover {
  text-decoration: underline;
}

.copy-button {
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  background: var(--navy-900);
  color: white;
  font-weight: 800;
  cursor: pointer;
  margin-top: 10px;
}

.copy-button:hover {
  background: var(--navy-800);
}

.error-message {
  background: #fee2e2;
  color: var(--red-dark);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-weight: 800;
}

.success-message {
  background: var(--green-soft);
  color: var(--green-text);
  border: 1px solid #86efac;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-weight: 800;
  margin-bottom: 18px;
}

.admin-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.admin-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--soft-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.admin-list-meta {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.small-button {
  display: inline-block;
  background: var(--navy-900);
  color: white;
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.small-button:hover {
  background: var(--navy-800);
}

.danger-button {
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  background: var(--red-dark);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.danger-button:hover {
  background: #7f1d1d;
}

.quote-box {
  background: var(--soft-bg);
  border-left: 4px solid var(--blue);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-top: 14px;
}

.quote-text {
  margin-top: 0;
  font-size: 16px;
  line-height: 1.55;
}

.quote-page,
.quote-note {
  color: var(--text-muted);
  font-size: 14px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.tag {
  background: var(--blue-soft);
  color: var(--blue-text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.quote-tag {
  background: var(--green-soft);
  color: var(--green-text);
}

.site-footer {
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px 0 40px;
}

/* RESPONSIVE */

@media (max-width: 1000px) {
  .quote-card-grid,
  .article-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .public-header-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 0;
  }

  .public-nav {
    gap: 6px;
  }

  .library-page {
    padding-top: 34px;
  }

  .library-search-row {
    grid-template-columns: 1fr;
  }

  .library-search-row button {
    padding: 14px 18px;
  }

  .filter-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .quote-card-grid,
  .article-card-grid {
    grid-template-columns: 1fr;
  }

  .section-heading-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-list-item {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Modern search tabs inside search card */
.library-search-card {
  padding: 28px;
}

.library-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  margin-bottom: 18px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
}

.library-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 10px 18px;
  border-radius: 999px;
  color: #64748b;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  transition: 0.2s ease;
}

.library-tab:hover {
  color: #0f172a;
  background: #ffffff;
}

.library-tab.active {
  color: #ffffff;
  background: #0f172a;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

.filter-panel {
  margin-top: 18px;
  border-top: 1px solid #e2e8f0;
  padding-top: 16px;
}

.filter-panel summary {
  cursor: pointer;
  width: fit-content;
  color: #0f172a;
  font-size: 14px;
  font-weight: 800;
}

.filter-panel summary:hover {
  color: #2563eb;
}

.filter-panel-content {
  margin-top: 18px;
}

/* Search card spacing refinements */
.library-search-card {
  padding: 24px;
}

.library-search-card .library-tabs {
  margin-bottom: 16px;
}

.library-search-row input:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.08);
}

.library-search-row button {
  min-width: 96px;
}

/* Cleaner collapsible filter control */
.filter-panel {
  margin-top: 16px;
  padding-top: 16px;
}

.filter-panel summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #0f172a;
}

.filter-panel summary::-webkit-details-marker {
  display: none;
}

.filter-panel summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #0f172a;
  color: #ffffff;
  font-size: 13px;
  line-height: 1;
}

.filter-panel[open] summary::before {
  content: "−";
}

.filter-panel summary:hover {
  background: #ffffff;
  border-color: #cbd5e1;
}

/* Slightly tighter hero spacing */
.library-hero {
  padding-bottom: 26px;
}

.library-hero h1 {
  max-width: 780px;
}

.library-hero p {
  max-width: 720px;
}

/* Tighter dashboard spacing */
.library-page {
  padding-top: 48px;
}

.library-hero {
  padding-bottom: 18px;
}

.library-hero h1 {
  margin-bottom: 12px;
}

.library-search-card {
  padding: 22px;
}

.library-search-card .library-tabs {
  margin-bottom: 14px;
}

.library-search-row {
  gap: 12px;
}

.filter-panel {
  margin-top: 14px;
  padding-top: 14px;
}

.results-toolbar {
  margin-top: 24px;
}

.result-section {
  margin-top: 20px;
}

.section-heading-row {
  margin-bottom: 14px;
}

/* Quote cards: slightly more compact and dashboard-like */
.quote-card-grid {
  gap: 18px;
}

.library-card {
  border-radius: 18px;
}

.quote-library-card {
  min-height: auto;
  padding: 22px;
}

.quote-card-text {
  font-size: 18px;
  line-height: 1.55;
}

.quote-card-meta,
.muted-text,
.source-line,
.source-title {
  font-size: 13px;
}

.card-actions {
  margin-top: 18px;
}

/* Quote card dashboard polish */
.quote-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.quote-library-card {
  display: flex;
  flex-direction: column;
  min-height: 360px;
  padding: 24px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.06);
}

.quote-library-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.1);
}

.quote-card-text {
  margin: 0 0 16px;
  color: #0f172a;
  font-size: 18px;
  line-height: 1.55;
  font-weight: 650;
}

.quote-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}

.quote-card-meta span {
  padding: 5px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

.quote-library-card .muted-text {
  margin: 0 0 16px;
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
}

.quote-library-card .tag-row {
  margin-top: 2px;
  margin-bottom: 18px;
}

.source-line {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
  color: #0f172a;
  font-size: 13px;
}

.source-title {
  margin: 6px 0 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
}

.quote-library-card .card-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}

.quote-library-card .card-actions button {
  flex: 1;
}

@media (max-width: 900px) {
  .quote-card-grid {
    grid-template-columns: 1fr;
  }
}

/* Responsive article grid: 1, 2, or more articles */
.article-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
  align-items: stretch;
}

.article-library-card {
  max-width: none;
}

@media (min-width: 1200px) {
  .article-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .article-card-grid {
    grid-template-columns: 1fr;
  }
}

/* Modern footer */
.site-footer {
  max-width: 1180px;
  margin: 56px auto 0;
  padding: 26px 24px 34px;
  color: #64748b;
}

.site-footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-top: 22px;
  border-top: 1px solid #e2e8f0;
}

.site-footer p {
  margin: 0;
  color: #0f172a;
  font-weight: 800;
}

.site-footer span {
  font-size: 14px;
}

@media (max-width: 700px) {
  .site-footer-inner {
    flex-direction: column;
  }
}

/* Open filter panel polish */
.filter-panel-content {
  margin-top: 18px;
  padding: 18px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.filter-panel-content .filter-block {
  margin: 0;
}

.filter-panel-content .filter-block + .filter-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.filter-label {
  margin-bottom: 10px;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chip-row {
  gap: 8px;
}

.filter-chip {
  transition: 0.2s ease;
}

.filter-chip:hover {
  transform: translateY(-1px);
  border-color: #cbd5e1;
}

/* Softer filter and chip styling */
.filter-panel summary {
  font-weight: 650;
  color: #334155;
}

.filter-panel summary::before {
  background: #334155;
  color: #ffffff;
}

.filter-label {
  color: #64748b;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.filter-chip {
  color: #334155;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  font-weight: 600;
  box-shadow: none;
}

.filter-chip:hover {
  color: #0f172a;
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: none;
}

.filter-chip.active {
  color: #0f172a;
  background: #e2e8f0;
  border-color: #cbd5e1;
  box-shadow: none;
}

.filter-panel-content .filter-chip.active {
  background: #dbeafe;
  border-color: #bfdbfe;
  color: #1e3a8a;
}

/* Softer tabs too, but still clear */
.library-tab {
  font-weight: 650;
}

.library-tab.active {
  color: #ffffff;
  background: #1e293b;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.14);
}

/* Softer main search tabs */
.library-tabs {
  background: #f1f5f9;
}

.library-tab {
  color: #475569;
  font-weight: 600;
}

.library-tab.active {
  color: #0f172a;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.library-tab:hover {
  color: #0f172a;
}

/* Final balanced main tab state */
.library-tab.active {
  color: #ffffff;
  background: #334155;
  border: 1px solid #334155;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.library-tab:not(.active) {
  color: #64748b;
}

/* Match search button with selected main tabs */
.library-search-row button {
  background: #334155;
  border-color: #334155;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.library-search-row button:hover {
  background: #1e293b;
  border-color: #1e293b;
}

/* Softer clear filters link */
.clear-link {
  color: #475569;
  font-weight: 600;
  text-decoration: none;
}

.clear-link:hover {
  color: #0f172a;
  text-decoration: underline;
}

/* Match main action buttons with the softer slate style */
.dark-button {
  background: #334155;
  border-color: #334155;
  color: #ffffff;
}

.dark-button:hover {
  background: #1e293b;
  border-color: #1e293b;
}

.quote-library-card .card-actions .dark-button,
.article-library-card .card-actions .dark-button {
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

/* Article expanded details polish */
.article-details[open] {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}

.article-details[open] summary {
  margin-bottom: 18px;
  background: #334155;
  border-color: #334155;
  color: #ffffff;
}

.details-content {
  display: grid;
  gap: 14px;
}

.article-section {
  padding: 16px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.article-section h4 {
  margin: 0 0 8px;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.article-section p {
  margin: 0;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.65;
}

.doi-link {
  display: inline-flex;
  width: fit-content;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.doi-link:hover {
  background: #dbeafe;
}

.mini-quote {
  margin-top: 12px;
  padding: 14px;
  border-left: 4px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
}

.mini-quote p {
  margin: 0 0 12px;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.6;
}

.mini-quote .light-button {
  padding: 8px 12px;
  font-size: 13px;
}

/* Softer saved quotes inside article details */
.article-section .mini-quote {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #cbd5e1;
  box-shadow: none;
}

.article-section .mini-quote + .mini-quote {
  margin-top: 12px;
}

.mini-quote .light-button {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #334155;
  font-weight: 600;
}

.mini-quote .light-button:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* Softer consistent View details button */
.article-details summary,
.article-details[open] summary {
  cursor: pointer;
  width: fit-content;
  margin-bottom: 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 14px;
  font-weight: 650;
  list-style: none;
  box-shadow: none;
}

.article-details[open] summary {
  margin-bottom: 18px;
}

.article-details summary:hover,
.article-details[open] summary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

/* Buttons shown only inside expanded article details */
.details-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  margin-bottom: 4px;
}

.details-actions .dark-button,
.details-actions .light-button {
  min-width: 100px;
}

/* Public article detail page */
.article-detail-page {
  max-width: 980px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 18px;
  color: #475569;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.back-link:hover {
  color: #0f172a;
  text-decoration: underline;
}

.article-detail-card {
  padding: 34px;
  border-radius: 22px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

.article-detail-header {
  margin-bottom: 22px;
}

.detail-label {
  margin: 0 0 10px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.article-detail-card h1 {
  margin: 0 0 12px;
  color: #0f172a;
  font-size: 34px;
  line-height: 1.15;
}

.article-detail-actions {
  display: flex;
  gap: 10px;
  margin: 22px 0;
  padding: 18px 0;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.article-detail-card .article-section {
  margin-top: 18px;
}

.article-detail-quotes {
  display: grid;
  gap: 14px;
}

.article-detail-quotes .mini-quote {
  margin-top: 0;
}

@media (max-width: 700px) {
  .article-detail-card {
    padding: 24px;
  }

  .article-detail-card h1 {
    font-size: 28px;
  }

  .article-detail-actions {
    flex-direction: column;
  }
}

/* Article detail page final polish */
.article-detail-page {
  max-width: 980px;
  padding-top: 48px;
}

.article-detail-card {
  max-width: 920px;
  margin: 0 auto;
}

.article-detail-actions {
  align-items: center;
}

.article-detail-actions .dark-button,
.article-detail-actions .light-button {
  min-width: 110px;
}

.article-detail-card .article-section {
  background: #f8fafc;
}

.article-detail-card .article-section p {
  max-width: 760px;
}

.article-detail-quotes .mini-quote {
  padding: 18px;
  border-radius: 16px;
  background: #ffffff;
}

.article-detail-quotes .mini-quote p:first-child {
  font-size: 15px;
  line-height: 1.6;
}

.article-detail-quotes .mini-quote .tag-row {
  margin-top: 10px;
  margin-bottom: 12px;
}

.article-detail-quotes .mini-quote .light-button {
  margin-top: 4px;
}

/* Two-column article workspace */
.article-detail-page {
  max-width: 1120px;
}

.article-detail-card {
  max-width: 1080px;
}

.article-workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.article-quote-panel,
.article-info-panel {
  min-width: 0;
}

.article-quote-panel {
  position: sticky;
  top: 100px;
  max-height: calc(100vh - 130px);
  overflow: hidden;
  padding: 18px;
  border-radius: 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading .detail-label {
  margin: 0;
}

.panel-heading span {
  color: #64748b;
  font-size: 13px;
  font-weight: 650;
}

.quote-scroll-list {
  max-height: calc(100vh - 210px);
  overflow-y: auto;
  padding-right: 6px;
}

.quote-scroll-list::-webkit-scrollbar {
  width: 8px;
}

.quote-scroll-list::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 999px;
}

.quote-scroll-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.article-side-quote {
  margin-top: 0;
  margin-bottom: 14px;
  padding: 16px;
  border-radius: 16px;
  background: #ffffff;
}

.article-side-quote:last-child {
  margin-bottom: 0;
}

.article-side-quote p:first-child {
  font-size: 14px;
  line-height: 1.6;
}

.article-side-quote .tag-row {
  margin-top: 10px;
  margin-bottom: 12px;
}

.article-info-panel {
  display: grid;
  gap: 16px;
}

.article-info-panel .article-section {
  margin-top: 0;
}

@media (max-width: 950px) {
  .article-workspace {
    grid-template-columns: 1fr;
  }

  .article-quote-panel {
    position: static;
    max-height: none;
  }

  .quote-scroll-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

/* Rebalance article detail layout */
.article-detail-page {
  max-width: 1180px;
}

.article-detail-card {
  max-width: 1120px;
}

.article-workspace {
  grid-template-columns: minmax(0, 1.25fr) 390px;
  gap: 24px;
}

.article-info-panel .article-section {
  padding: 18px;
}

.article-info-panel .article-section p {
  max-width: none;
}

.article-quote-panel {
  padding: 18px;
}

.article-side-quote {
  padding: 18px;
}

@media (max-width: 1050px) {
  .article-workspace {
    grid-template-columns: 1fr;
  }
}

/* Final article page width balance */
.article-detail-page {
  max-width: 1240px;
}

.article-detail-card {
  max-width: 1180px;
}

.article-workspace {
  grid-template-columns: minmax(0, 1.35fr) 430px;
}

@media (max-width: 1100px) {
  .article-workspace {
    grid-template-columns: 1fr;
  }
}

/* Wider article detail workspace */
.article-detail-page {
  max-width: 1360px;
}

.article-detail-card {
  max-width: 1280px;
}

.article-workspace {
  grid-template-columns: minmax(0, 1.15fr) 500px;
  gap: 28px;
}

.article-quote-panel {
  max-height: calc(100vh - 120px);
}

.quote-scroll-list {
  max-height: calc(100vh - 200px);
}

.article-side-quote p:first-child {
  font-size: 15px;
  line-height: 1.65;
}

@media (max-width: 1200px) {
  .article-workspace {
    grid-template-columns: minmax(0, 1fr) 420px;
  }
}

@media (max-width: 1000px) {
  .article-workspace {
    grid-template-columns: 1fr;
  }
}

/* Prevent long text from overflowing cards */
.library-card,
.article-library-card,
.quote-library-card,
.article-section,
.mini-quote {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.summary-preview,
.quote-card-text,
.article-source,
.source-title,
.article-section p,
.mini-quote p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Strong overflow protection for long unbroken test text */
.article-detail-card,
.article-workspace,
.article-info-panel,
.article-quote-panel,
.article-section,
.summary-preview,
.library-card {
  min-width: 0;
  max-width: 100%;
}

.article-section,
.article-section p,
.summary-preview,
.article-detail-card,
.article-detail-card p,
.article-detail-card h1,
.article-side-quote,
.article-side-quote p,
.mini-quote,
.mini-quote p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.article-section {
  overflow: hidden;
}

/* Emergency protection for extreme test text with no spaces */
.article-detail-card * {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.article-workspace {
  width: 100%;
  overflow: hidden;
}

.article-info-panel,
.article-quote-panel {
  min-width: 0;
  max-width: 100%;
}

.article-section {
  width: 100%;
  overflow: hidden;
}

.article-section p {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* Admin dashboard polish */
.site-header {
  background: linear-gradient(135deg, var(--navy-950), var(--navy-900));
  padding: 46px 24px 54px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.site-header .header-inner {
  width: min(1100px, 92%);
}

.site-header h1 {
  font-size: clamp(34px, 4vw, 46px);
  line-height: 1;
}

.site-header .subtitle {
  max-width: 620px;
  color: #cbd5e1;
  line-height: 1.6;
}

.page {
  width: min(1100px, 92%);
  margin-top: -26px;
  padding-bottom: 72px;
}

.page > .card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.page > .card + .card {
  margin-top: 24px;
}

.card h2 {
  margin-top: 0;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.card > p {
  color: var(--text-muted);
  line-height: 1.6;
}

/* Admin saved articles list */
.admin-list {
  gap: 12px;
}

.admin-list-item {
  background: var(--soft-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.admin-list-item strong {
  font-size: 15px;
}

.admin-list-meta {
  color: var(--text-muted);
  line-height: 1.5;
}

/* Admin actions */
.admin-actions {
  align-items: center;
}

.small-button {
  background: var(--navy-700);
  border: 1px solid var(--navy-700);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 13px;
}

.small-button:hover {
  background: var(--navy-800);
  border-color: var(--navy-800);
}

/* Admin forms */
.admin-form {
  gap: 20px;
}

.form-group {
  gap: 8px;
}

.form-group label {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 750;
}

.form-group input,
.form-group textarea,
.form-group select {
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text-main);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.08);
}

.field-help {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Admin bottom button row */
.button-row {
  padding-top: 8px;
}

.primary-button {
  background: var(--navy-700);
  border: 1px solid var(--navy-700);
  border-radius: 12px;
  padding: 11px 16px;
}

.primary-button:hover {
  background: var(--navy-800);
  border-color: var(--navy-800);
}

.secondary-link {
  color: var(--blue-text);
  font-weight: 750;
}

/* Admin quote boxes */
.quote-box {
  background: var(--soft-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: 16px;
  padding: 18px;
}

.quote-box + .quote-box {
  margin-top: 14px;
}

.danger-button {
  background: var(--red-dark);
  border-radius: 12px;
}

.success-message {
  border-radius: 14px;
  box-shadow: var(--shadow-small);
}

/* Admin top navigation */
.admin-top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.admin-top-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  border-radius: 999px;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.admin-top-nav a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

/* Softer admin inline action links */
.card .secondary-link,
.card a.secondary-link,
.card > a,
.card form + a {
  color: #475569;
  font-weight: 650;
}

.card .secondary-link:hover,
.card a.secondary-link:hover,
.card > a:hover,
.card form + a:hover {
  color: #0f172a;
}

/* Cleaner manage-article card actions */
.admin-article-summary-card .tag-row {
  margin-bottom: 18px;
}

.admin-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.admin-card-actions form {
  margin: 0;
}

.admin-card-actions .small-button,
.admin-card-actions .danger-button {
  min-height: 42px;
}

/* Shared admin navigation */
.admin-top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.admin-top-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.admin-top-nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Make admin action rows less messy */
.admin-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.admin-card-actions form {
  margin: 0;
}

/* Admin dashboard search */
.admin-search-form {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  margin: 18px 0 20px;
}

.admin-search-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 15px;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

.admin-search-form input:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.08);
}

.admin-search-form .primary-button {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .admin-search-form {
    grid-template-columns: 1fr;
  }
}

/* Keep admin dashboard usable when there are many articles */
.admin-list {
  max-height: 360px;
  overflow-y: auto;
  padding-right: 6px;
}

.admin-list::-webkit-scrollbar {
  width: 8px;
}

.admin-list::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 999px;
}

.admin-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.admin-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Admin overview statistics */
.admin-stats-card {
  margin-bottom: 22px;
}

.admin-stats-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.admin-stats-header h2 {
  margin: 0 0 6px;
}

.admin-stats-header p {
  margin: 0;
  color: var(--text-muted);
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.admin-stat-box {
  padding: 18px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.admin-stat-label {
  display: block;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.admin-stat-box strong {
  display: block;
  color: #0f172a;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.04em;
}

@media (max-width: 1000px) {
  .admin-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .admin-stats-grid {
    grid-template-columns: 1fr;
  }
}