:root {
  color-scheme: light;
  --ink: #17211e;
  --muted: #60706a;
  --paper: #f5f2ea;
  --card: #fffdf8;
  --line: #d8d3c6;
  --green: #1d5c48;
  --green-soft: #dbe9e2;
  --ochre: #aa5d22;
  --ochre-soft: #f4e4d3;
  --shadow: 0 16px 40px rgba(23, 33, 30, 0.08);
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 90% 0, rgba(170, 93, 34, 0.09), transparent 30rem),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hero,
main {
  width: min(1120px, calc(100% - 36px));
  margin-inline: auto;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  padding: 64px 0 34px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--ochre);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 6vw, 5.2rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 0.94;
}

.intro {
  max-width: 650px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.hero-stat {
  min-width: 170px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.65);
  text-align: right;
}

.hero-stat strong,
.hero-stat span {
  display: block;
}

.hero-stat strong {
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.8rem;
  line-height: 1;
}

.hero-stat span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

main {
  padding: 28px 0 64px;
}

.compact-hero h1 {
  font-size: clamp(2.4rem, 5vw, 4.4rem);
}

.page-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.page-nav a {
  padding: 9px 13px;
  border-radius: 9px;
  color: var(--green);
  font-size: 0.84rem;
  font-weight: 800;
  text-decoration: none;
}

.page-nav a.active {
  background: var(--green);
  color: white;
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(135px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.search-mode-toggle {
  grid-column: 1 / -1;
  display: flex;
  gap: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f0ede5;
  width: fit-content;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 180ms ease;
}

.mode-btn.active {
  background: white;
  color: var(--green);
  border-color: var(--line);
  box-shadow: 0 2px 8px rgba(23, 33, 30, 0.08);
}

.mode-btn:hover:not(.active) {
  color: var(--ink);
}

.mode-icon {
  font-size: 1rem;
}

.search-box {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  right: 0;
  left: 0;
  max-height: 340px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: 0 18px 40px rgba(23, 33, 30, 0.16);
}

.autocomplete-list[hidden] {
  display: none;
}

.autocomplete-option {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  text-align: left;
}

.autocomplete-option:hover,
.autocomplete-option.is-active {
  background: var(--green-soft);
}

.autocomplete-option strong {
  font-size: 0.88rem;
}

.autocomplete-option span {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0;
  text-align: right;
  text-transform: none;
}

label span {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

input,
select,
button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0 12px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(29, 92, 72, 0.2);
  border-color: var(--green);
}

button {
  padding: 0 15px;
  cursor: pointer;
}

#resetButton {
  background: var(--ink);
  color: white;
}

.actions {
  display: flex;
  gap: 8px;
}

#exportButton {
  border-color: var(--green);
  color: var(--green);
  font-weight: 700;
}

.quick-search {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 18px 2px 24px;
  color: var(--muted);
  font-size: 0.88rem;
}

.quick-search button {
  min-height: 32px;
  padding: 0 12px;
  border-color: transparent;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.84rem;
  font-weight: 700;
}

.theme-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin: 0 0 24px;
  padding: 24px 26px;
  border-radius: 18px;
  background: var(--green);
  color: white;
}

.theme-summary .eyebrow {
  color: #f0c99f;
}

.theme-summary h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 500;
}

.theme-summary p:last-child {
  max-width: 660px;
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.5;
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.summary-chip-btn {
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: transparent;
  color: white;
  font-size: 0.76rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all 150ms ease;
  min-height: auto;
}

.summary-chip-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: white;
}

.result-group {
  margin-top: 30px;
}

.group-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.group-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 500;
}

.group-heading span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 310px;
  padding: 23px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  overflow: hidden;
}

.preview-link {
  display: block;
  height: 210px;
  margin: -23px -23px 20px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #ebe7dd;
}

.preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 180ms ease;
}

.preview-link:hover .preview-image {
  transform: scale(1.025);
}

.card-topline {
  display: flex;
  align-items: center;
  gap: 7px;
}

.type-badge,
.level-badge,
.page-badge {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.type-badge {
  background: var(--ochre-soft);
  color: var(--ochre);
}

.level-badge {
  background: var(--green-soft);
  color: var(--green);
}

.page-badge {
  background: #e8e4f0;
  color: #5c4b8a;
}

.confidence {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.74rem;
}

.card h2 {
  margin: 17px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 500;
  line-height: 1.15;
}

.source,
.notes {
  color: var(--muted);
  line-height: 1.45;
}

.source {
  margin: 0 0 16px;
  font-size: 0.85rem;
}

.notes {
  margin: 15px 0 22px;
  font-size: 0.87rem;
}

.copy-panel {
  margin: 0 0 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  overflow: hidden;
}

.copy-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.72rem;
  border-bottom: 1px solid var(--line);
  background: #fdfdfb;
}

.copy-button {
  min-height: 32px;
  padding: 0 10px;
  border-color: var(--green);
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 800;
}

.copy-text {
  max-height: 110px;
  margin: 0;
  padding: 13px;
  overflow-y: auto;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  user-select: text;
  transition: max-height 200ms ease;
}

.copy-panel.expanded .copy-text {
  max-height: none;
  overflow-y: visible;
}

.topic-row {
  margin-top: 11px;
}

.topic-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topic {
  display: inline-block;
  margin: 0 5px 5px 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  font-size: 0.76rem;
}

.topic.clickable-topic {
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.topic.clickable-topic:hover {
  background-color: var(--ochre-soft);
  border-color: var(--ochre);
  color: var(--ochre);
}

.topic.clickable-topic:active {
  transform: translateY(1px);
}

.card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.links a {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
}

.links a:hover {
  text-decoration: underline;
}

.review-status {
  color: var(--muted);
  font-size: 0.72rem;
  text-align: right;
}

.empty {
  padding: 48px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

/* ── Full-text search summary ────────────────────────────────────────────── */

.fulltext-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin: 0 0 24px;
  padding: 24px 26px;
  border-radius: 18px;
  background: linear-gradient(135deg, #1d5c48, #2a7a5e);
  color: white;
}

.fulltext-summary .eyebrow {
  color: #a8dcc7;
}

.fulltext-summary h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 500;
  font-style: italic;
}

.fulltext-summary p {
  max-width: 660px;
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.5;
}

/* ── Snippet highlights ──────────────────────────────────────────────────── */

.snippet {
  margin: 12px 0 18px;
  padding: 14px 16px;
  border-left: 3px solid var(--ochre);
  border-radius: 0 10px 10px 0;
  background: #fdf8f1;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.65;
}

.snippet mark {
  padding: 1px 3px;
  border-radius: 3px;
  background: #ffe066;
  color: var(--ink);
  font-weight: 700;
}

/* ── Fulltext card variant ───────────────────────────────────────────────── */

.card--fulltext {
  min-height: auto;
}

.card--fulltext .page-title {
  margin: 14px 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 1.2;
}

.card--fulltext footer {
  padding-top: 12px;
}

.progress-overview,
.job-table-panel,
.book-progress-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.progress-overview {
  padding: 22px;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--green-soft);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 200ms ease;
}

.status-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.status-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
}

.status-card strong {
  display: block;
  margin-top: 9px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.9rem;
}

.job-status {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  background: #ece9e1;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.status-validated {
  background: var(--green-soft);
  color: var(--green);
}

.status-needs_retry,
.status-failed {
  background: #f5d9d4;
  color: #8f3025;
}

.status-claimed {
  background: var(--ochre-soft);
  color: var(--ochre);
}

.book-progress {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.book-progress-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 20px;
}

.book-progress-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  font-weight: 500;
}

.book-progress-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.book-progress-card > strong {
  color: var(--green);
  font-size: 1.4rem;
}

.book-progress-card .progress-track {
  grid-column: 1 / -1;
  height: 8px;
}

.job-table-panel {
  padding: 22px;
}

.table-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.table-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  font-weight: 500;
}

.table-filters {
  display: flex;
  gap: 8px;
}

.job-table-wrap {
  overflow-x: auto;
}

.job-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.job-table th,
.job-table td {
  padding: 11px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.job-table th {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.job-table a {
  color: var(--green);
  font-weight: 800;
}

/* ── Settings Drawer ─────────────────────────────────────────────────────── */

.settings-drawer {
  grid-column: 1 / -1;
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(245, 242, 234, 0.5);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.03);
}

.settings-drawer-header {
  margin-bottom: 12px;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.settings-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.settings-grid label {
  flex: 1 1 240px;
}

.ngram-params {
  display: flex;
  gap: 16px;
  flex: 2 1 360px;
}

.ngram-params label {
  flex: 1;
}

.ngram-params label span {
  display: flex;
  justify-content: space-between;
}

.ngram-params input[type="range"] {
  height: 8px;
  -webkit-appearance: none;
  background: var(--line);
  border-radius: 999px;
  border: none;
  padding: 0;
  outline: none;
  cursor: pointer;
  margin-top: 8px;
}

.ngram-params input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 100ms ease;
}

.ngram-params input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.setting-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  user-select: none;
  margin-top: 4px;
}

.setting-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
  cursor: pointer;
}

/* ── Taxonomy Catalog ────────────────────────────────────────────────────── */

.taxonomy-section {
  margin-top: 14px;
  animation: fadeIn 300ms ease-out;
}

.taxonomy-header {
  margin-bottom: 24px;
  max-width: 700px;
}

.taxonomy-header h2 {
  margin: 8px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 500;
}

.taxonomy-header p {
  color: var(--muted);
  line-height: 1.45;
}

.taxonomy-container {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  min-height: 400px;
}

.taxonomy-categories {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  height: fit-content;
}

.taxonomy-category-btn {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: all 180ms ease;
  min-height: auto;
}

.taxonomy-category-btn:hover {
  background: var(--paper);
  color: var(--ink);
}

.taxonomy-category-btn.active {
  background: var(--green-soft);
  border-color: var(--line);
  color: var(--green);
}

.taxonomy-subcategories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  align-content: start;
}

.taxonomy-sub-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 4px 12px rgba(23, 33, 30, 0.02);
  cursor: pointer;
  transition: all 220ms ease;
}

.taxonomy-sub-card:hover {
  transform: translateY(-2px);
  border-color: var(--green);
  box-shadow: 0 8px 20px rgba(23, 33, 30, 0.06);
}

.taxonomy-sub-card h4 {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.25;
}

.taxonomy-count-badge {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 800;
}

/* ── Interactive Page flip and Exercises ─────────────────────────────────── */

.page-nav-controls {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.nav-page-btn {
  min-height: 28px;
  height: 28px;
  width: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--green);
  font-weight: 800;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 150ms ease;
}

.nav-page-btn:hover:not(:disabled) {
  background: var(--green-soft);
}

.nav-page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-exercises-panel {
  margin: 14px 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.page-exercises-panel summary {
  padding: 10px 12px;
  color: var(--ochre);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
}

.page-exercises-panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.exercise-list {
  margin: 0;
  padding: 8px 12px;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
}

.page-exercise-item {
  padding: 8px;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.4;
  cursor: pointer;
  transition: background 150ms ease;
}

.page-exercise-item:hover {
  background: var(--ochre-soft);
}

.page-exercise-item strong {
  color: var(--ochre);
}

.exercise-excerpt {
  color: var(--muted);
}

/* Verbatim Text for page browse mode */
.verbatim-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--ink);
  max-height: 350px;
  overflow-y: auto;
}

/* Loading animations & states */
.card-loading {
  position: relative;
  opacity: 0.65;
  pointer-events: none;
}

.card-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border: 3px solid var(--green-soft);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

.loading-spinner {
  padding: 14px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  font-style: italic;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .search-panel {
    grid-template-columns: repeat(2, 1fr);
  }

  .search-box {
    grid-column: 1 / -1;
  }

  .actions {
    align-self: stretch;
  }

  .status-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 680px) {
  .hero {
    display: block;
    padding-top: 40px;
  }

  .hero-stat {
    margin-top: 24px;
    text-align: left;
  }

  .search-panel,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .search-box {
    grid-column: auto;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .theme-summary,
  .fulltext-summary {
    display: block;
  }

  .book-progress,
  .status-cards {
    grid-template-columns: 1fr;
  }

  .table-heading,
  .table-filters {
    display: grid;
  }

  .summary-chips {
    justify-content: flex-start;
    margin-top: 18px;
  }
}

/* ── Collapsible result group styling ───────────────────────────────────── */
.group-heading {
  cursor: pointer;
  user-select: none;
  padding: 6px 10px;
  margin-left: -10px;
  border-radius: 8px;
  transition: background 180ms ease;
}

.group-heading:hover {
  background: var(--green-soft);
}

/* Arrow toggle indicator */
.group-heading h2::after {
  content: " ▾";
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  transition: transform 200ms ease;
}

.result-group.collapsed .group-heading h2::after {
  transform: rotate(-90deg);
}

.result-group.collapsed .result-grid {
  display: none;
}

/* ── Modal Dialog Overlay & Split View ───────────────────────────────────── */
body.modal-open {
  overflow: hidden;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(23, 33, 30, 0.4);
  backdrop-filter: blur(4px);
}

.modal-container {
  position: relative;
  width: min(1500px, 98%);
  height: min(850px, calc(100vh - 48px));
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleUp 250ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.modal-header h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--green);
}

.modal-close-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 2rem;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  min-height: auto;
  transition: color 150ms ease;
}

.modal-close-btn:hover {
  color: var(--ink);
}

.modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 24px;
}

.modal-content-split {
  display: grid;
  grid-template-columns: 1fr 12px 1fr;
  gap: 0;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.modal-text-panel,
.modal-image-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  overflow: hidden;
}

.modal-text-panel h4,
.modal-image-panel h4 {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modal-text-panel .verbatim-text {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  overflow-y: auto;
  font-size: 0.94rem;
  line-height: 1.65;
  height: 100%;
  max-height: none;
}

.modal-image-panel .modal-image-wrapper {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: block;
  overflow: auto;
  position: relative;
  text-align: center;
  flex: 1;
  height: 100%;
}

.modal-image-panel img {
  display: inline-block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  vertical-align: top;
  transition: width 150ms ease-out;
}

.modal-resizer {
  grid-column: 2;
  cursor: col-resize;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
  user-select: none;
}

.modal-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background: var(--line);
  transition: background 150ms ease, width 150ms ease;
}

.modal-resizer:hover::before,
.modal-resizer.is-dragging::before {
  background: var(--ochre);
  width: 4px;
}

.modal-resizer::after {
  content: "⋮";
  position: absolute;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: bold;
  background: var(--paper);
  width: 14px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 253, 248, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  z-index: 20;
}

.zoom-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  font-size: 0.9rem;
}

.zoom-btn:hover {
  background: var(--ochre-soft);
  color: var(--ochre);
}

.zoom-level {
  font-size: 0.75rem;
  font-weight: 800;
  padding-inline: 6px;
  min-width: 44px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 900px) {
  .modal-content-split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto 1fr;
    overflow-y: auto;
  }
  .modal-resizer {
    display: none;
  }
  .modal-text-panel,
  .modal-image-panel {
    height: 350px;
  }
}

/* ── Inline Link Button ────────────────────────────────────────────────── */
.inline-link-btn {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  min-height: auto;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: color 150ms ease;
}

.inline-link-btn:hover {
  color: var(--ochre);
  text-decoration: underline;
}

/* ── Copy Panel Actions Toolbar ────────────────────────────────────────── */
.copy-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.copy-button {
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 800;
  border-radius: 6px;
  cursor: pointer;
  padding: 0 10px;
  min-height: 32px;
  transition: all 150ms ease;
  display: inline-flex;
  align-items: center;
}

.copy-button:hover {
  background: var(--green);
  color: white;
}

/* Prominent Vezi Răspuns Button */
.view-answer-btn {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--ochre);
  background: var(--ochre-soft);
  color: var(--ochre);
  font-size: 0.74rem;
  font-weight: 800;
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.view-answer-btn:hover {
  background: var(--ochre);
  color: white;
  box-shadow: 0 2px 8px rgba(170, 93, 34, 0.2);
}

/* Prominent Vezi Pagină Button */
.view-page-btn {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--green);
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 800;
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.view-page-btn:hover {
  background: var(--green);
  color: white;
  box-shadow: 0 2px 8px rgba(29, 92, 72, 0.2);
}

/* ── Expand Text Panel Button ── */
.expand-text-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  border-radius: 6px;
  cursor: pointer;
  padding: 0 10px;
  min-height: 32px;
  transition: all 150ms ease;
}

.expand-text-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-soft);
}

/* ── Glowing Answer Highlights ── */
@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(170, 93, 34, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(170, 93, 34, 0); }
  100% { box-shadow: 0 0 0 0 rgba(170, 93, 34, 0); }
}

.answer-highlight {
  display: inline-block;
  animation: pulseGlow 2s infinite ease-in-out;
}

/* ── Clickable Text Word and OCR Highlights ── */
.clickable-word {
  cursor: pointer;
  border-radius: 3px;
  transition: background-color 0.12s ease, color 0.12s ease;
  display: inline-block;
}

.clickable-word:hover {
  background-color: var(--ochre-soft);
  color: var(--ochre);
}

.clickable-word.is-active {
  background-color: var(--ochre);
  color: white;
}

.ocr-highlight-box {
  background: rgba(255, 99, 71, 0.35);
  border: 1.5px solid tomato;
  border-radius: 3px;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(255, 99, 71, 0.4);
  animation: ocrHighlightPulse 1.2s infinite alternate ease-in-out;
}

@keyframes ocrHighlightPulse {
  from {
    opacity: 0.65;
    box-shadow: 0 0 4px rgba(255, 99, 71, 0.3);
  }
  to {
    opacity: 1.0;
    box-shadow: 0 0 10px rgba(255, 99, 71, 0.6);
  }
}
