/* ============================================
   UNIFIED STYLESHEET - All Pages
   ============================================ */

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-dark: #1a1a2e;
    --color-accent: #c9a227;
    --color-accent-light: #e8d5a3;
    --color-text: #333;
    --color-text-light: #666;
    --color-bg: #faf9f7;
    --color-white: #ffffff;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
}

h1, h2, h3, h4 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    color: var(--color-dark);
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #b8922a;
}

/* Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 10px;
    background: var(--color-dark);
    color: white;
    padding: 8px;
    border-radius: 4px;
    z-index: 1000;
}

.skip-link:focus {
    top: 10px;
}

/* ============================================
   HOMEPAGE STYLES
   ============================================ */

/* Hero Section */
.hero {
    min-height: 100vh;
    background: linear-gradient(160deg, #1a1a2e 0%, #2d2d44 50%, #1a1a2e 100%);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.hero-decoration {
    position: absolute;
    width: 300px;
    height: 300px;
    border: 1px solid rgba(201, 162, 39, 0.2);
    border-radius: 50%;
}

.hero-decoration.top-left {
    top: -100px;
    left: -100px;
}

.hero-decoration.top-right {
    bottom: -150px;
    right: -150px;
    width: 400px;
    height: 400px;
}

.hero-content {
    text-align: center;
    z-index: 1;
    padding: 2rem;
}

.hero-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
}

.hero-nav a {
    color: rgba(255,255,255,0.7);
}

.hero-nav a:hover {
    color: var(--color-accent);
}

.nav-divider {
    color: rgba(255,255,255,0.3);
}

.emblem {
    margin-bottom: 2rem;
}

.emblem-circle {
    width: 120px;
    height: 120px;
    border: 2px solid var(--color-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--color-accent);
    animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.3); }
    50% { box-shadow: 0 0 0 20px rgba(201, 162, 39, 0); }
}

.hero h1 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 3.5rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    margin-bottom: 1rem;
    text-transform: uppercase;
    color: white;
}

.subtitle-line {
    width: 60px;
    height: 1px;
    background: var(--color-accent);
    margin: 1.5rem auto;
}

.tagline {
    font-size: 1.1rem;
    font-weight: 300;
    opacity: 0.8;
    font-style: italic;
    font-family: 'Cormorant Garamond', Georgia, serif;
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

/* Homepage Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 5rem 2rem;
}

.section-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

.marker-line {
    width: 40px;
    height: 1px;
    background: var(--color-accent);
}

.marker-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    color: var(--color-accent);
    font-style: italic;
}

.intro {
    text-align: center;
    margin-bottom: 4rem;
}

.intro p {
    font-size: 1.15rem;
    color: var(--color-text-light);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.9;
}

/* Feature Cards */
.features {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 5rem;
}

.feature-card {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.05);
    transition: box-shadow 0.3s;
}

.feature-card:hover {
    box-shadow: 0 4px 30px rgba(0,0,0,0.1);
}

.feature-number {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--color-accent);
    line-height: 1;
    opacity: 0.5;
}

.feature-content h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature-content p {
    color: var(--color-text-light);
    font-size: 0.95rem;
}

/* Manuscript Preview */
.manuscript-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
    margin-bottom: 5rem;
    padding: 3rem;
    background: linear-gradient(135deg, #f8f6f3 0%, var(--color-bg) 100%);
    border-radius: 12px;
    border: 1px solid #eee;
}

.preview-label {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-accent);
    margin-bottom: 0.5rem;
}

.preview-content h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.preview-subtitle {
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin-bottom: 1rem;
}

.preview-content > p {
    color: var(--color-text-light);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.preview-contents {
    list-style: none;
    margin-bottom: 2rem;
}

.preview-contents li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.preview-contents i {
    color: var(--color-accent);
    width: 20px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--color-dark);
    color: white;
    padding: 1rem 1.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    transition: background 0.3s, transform 0.2s;
}

.btn-primary:hover {
    background: #2a2a4a;
    transform: translateX(3px);
    color: white;
}

.btn-primary i {
    transition: transform 0.2s;
}

.btn-primary:hover i {
    transform: translateX(3px);
}

/* Manuscript Frame Visual */
.preview-visual {
    display: flex;
    justify-content: center;
}

.manuscript-frame {
    width: 200px;
    height: 260px;
    background: #f5f0e6;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1), inset 0 0 30px rgba(0,0,0,0.05);
    padding: 20px;
    position: relative;
}

.manuscript-frame::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid #d4cfc5;
    border-radius: 2px;
}

.frame-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.frame-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.9rem;
    color: var(--color-dark);
    margin-bottom: 1.5rem;
    letter-spacing: 0.1em;
}

.frame-circle {
    width: 80px;
    height: 80px;
    border: 2px solid var(--color-accent);
    border-radius: 50%;
    margin-bottom: 1.5rem;
    position: relative;
}

.frame-circle::before,
.frame-circle::after {
    content: '';
    position: absolute;
    border: 1px solid rgba(201, 162, 39, 0.3);
    border-radius: 50%;
}

.frame-circle::before { inset: -15px; }
.frame-circle::after { inset: -30px; }

.frame-lines {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.frame-lines span {
    height: 3px;
    background: rgba(26, 26, 46, 0.15);
    border-radius: 1px;
}

.frame-lines span:nth-child(odd) {
    width: 80%;
    margin: 0 auto;
}

/* Approach Section */
.approach {
    text-align: center;
    margin-bottom: 4rem;
}

.approach h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 2rem;
}

.approach-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.approach-item {
    padding: 1.5rem 1rem;
}

.approach-item i {
    font-size: 1.5rem;
    color: var(--color-accent);
    margin-bottom: 1rem;
}

.approach-item h3 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.approach-item p {
    font-size: 0.85rem;
    color: var(--color-text-light);
}

/* About Section (Homepage) */
.about {
    text-align: center;
    padding: 3rem 0;
    border-top: 1px solid #eee;
}

.about p {
    color: var(--color-text-light);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.about .note {
    font-size: 0.85rem;
    color: #999;
}

/* ============================================
   INNER PAGE STYLES (Manuscript, About, etc.)
   ============================================ */

/* Header */
header {
    text-align: center;
    padding: 2rem 0;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 1.5rem;
    background: white;
}

header h1 {
    font-size: 2rem;
    color: var(--color-dark);
    margin-bottom: 0.5rem;
}

header h1 i {
    color: var(--color-accent);
}

header .subtitle {
    font-size: 1rem;
    color: var(--color-text-light);
}

header .legal-notice {
    font-size: 0.8rem;
    color: #95a5a6;
    margin-top: 0.75rem;
}

header .legal-notice a {
    color: var(--color-accent);
}

/* Navigation */
nav {
    background: var(--color-dark);
    padding: 0.75rem 0;
    margin-bottom: 1.5rem;
    border-radius: 8px;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
}

nav a {
    color: #ecf0f1;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background 0.2s;
}

nav a:hover,
nav a:focus {
    background: var(--color-accent);
    color: white;
}

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

/* Main Content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

/* Folio Selector */
.folio-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.folio-nav label {
    font-weight: 600;
    color: var(--color-dark);
}

#folio-selector {
    padding: 0.6rem 1rem;
    border: 2px solid var(--color-accent);
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    min-width: 220px;
}

#folio-selector:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.2);
}

/* Viewer */
.viewer-wrapper {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.folio-iiif-image {
    width: 100%;
    height: auto;
    max-height: 85vh;
    object-fit: contain;
    display: block;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
}

.viewer-note {
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.85rem;
    margin-top: 0.6rem;
}

.viewer-note a {
    color: #2980b9;
    text-decoration: none;
}

.viewer-note a:hover {
    text-decoration: underline;
}

/* Scholarly Content */
.scholarly-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.folio-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #ecf0f1;
}

.folio-label {
    background: var(--color-accent);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.1rem;
}

.folio-type {
    background: #ecf0f1;
    color: var(--color-dark);
    padding: 0.4rem 0.8rem;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 500;
}

.scholarly-content > h3 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.6rem;
    color: var(--color-dark);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #ecf0f1;
}

/* Sections */
.intro-section,
.diagrams-section,
.table-section,
.context-section,
.bibliography {
    padding: 1.5rem;
    border-radius: 0 8px 8px 0;
    margin-bottom: 2rem;
}

.intro-section {
    background: #f0f7ff;
    border-left: 4px solid #3498db;
}

.diagrams-section {
    background: #f5f0ff;
    border-left: 4px solid #9b59b6;
}

.table-section {
    background: #fff5f5;
    border-left: 4px solid #e74c3c;
}

.context-section {
    background: #f0fff4;
    border-left: 4px solid #27ae60;
}

.bibliography {
    background: #fef9e7;
    border-left: 4px solid var(--color-accent);
}

.intro-section h4,
.diagrams-section h4,
.table-section h4,
.context-section h4,
.bibliography h4 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.intro-section h4 { color: #2980b9; }
.diagrams-section h4 { color: #8e44ad; }
.table-section h4 { color: #c0392b; }
.context-section h4 { color: #1e8449; }
.bibliography h4 { color: #9a7d0a; }

.intro-section p,
.context-section p,
.table-section > p {
    line-height: 1.8;
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
}

.intro-section ul,
.intro-section ol,
.context-section ul,
.context-section ol {
    margin: 0.75rem 0 1rem 1.5rem;
    line-height: 1.8;
    color: var(--color-text-light);
}

.context-section li,
.intro-section li {
    margin-bottom: 0.5rem;
}

/* Aligned Text Section */
.aligned-text-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.aligned-text-section h4 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: var(--color-dark);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.align-instruction {
    color: var(--color-text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    font-style: italic;
}

.aligned-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.latin-aligned-column,
.english-aligned-column {
    background: #fafafa;
    border-radius: 8px;
    overflow: hidden;
}

.latin-aligned-column {
    border: 2px solid #9b59b6;
}

.english-aligned-column {
    border: 2px solid #3498db;
}

.latin-aligned-column h5,
.english-aligned-column h5 {
    padding: 0.75rem 1rem;
    margin: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
}

.latin-aligned-column h5 {
    background: #9b59b6;
    color: white;
}

.english-aligned-column h5 {
    background: #3498db;
    color: white;
}

.aligned-line {
    display: flex;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

.aligned-line:last-child {
    border-bottom: none;
}

.aligned-line.highlighted {
    background-color: #fff3cd;
    box-shadow: inset 3px 0 0 var(--color-accent);
}

.english-aligned-column .aligned-line.highlighted {
    box-shadow: inset -3px 0 0 var(--color-accent);
}

.line-num {
    font-weight: bold;
    color: #999;
    min-width: 30px;
    font-size: 0.8rem;
    padding-right: 0.5rem;
}

.latin-aligned-column .line-text {
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
    color: var(--color-dark);
    line-height: 1.5;
}

.english-aligned-column .line-text {
    color: #444;
    line-height: 1.5;
}

.latin-aligned-column .line-text.glossary-term {
    color: #8e44ad;
    cursor: pointer;
}

.latin-aligned-column .line-text.glossary-term:hover {
    background: #f3e5f5;
}

/* Diagram Tables - Purple Latin / Blue English */
.diagrams-section table.aligned-text {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #9b59b6;
}

.diagrams-section table.aligned-text th {
    padding: 0.5rem 1rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.95rem;
    text-align: left;
    background: #9b59b6;
    color: white;
}

.diagrams-section table.aligned-text th.english-col {
    background: #3498db;
}

.diagrams-section table.aligned-text td {
    padding: 0.4rem 1rem;
    border-bottom: 1px solid #eee;
}

.diagrams-section table.aligned-text tr:last-child td {
    border-bottom: none;
}

.diagrams-section table.aligned-text td:first-child {
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
    color: #6c3483;
    border-left: 3px solid #9b59b6;
    background: #faf5fc;
}

.diagrams-section table.aligned-text td:last-child {
    color: #2874a6;
    background: #f0f7fc;
}

.diagrams-section table.aligned-text tr:hover td {
    background-color: #fff3cd;
}

.diagrams-section h5 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--color-dark);
}

/* Glossary Terms */
.glossary-term {
    color: #2980b9;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    padding: 0 2px;
    border-radius: 3px;
}

.glossary-term:hover {
    color: #1a5276;
    background: #e8f4fc;
}

/* Glossary Popup */
.glossary-popup {
    position: absolute;
    z-index: 1000;
    background: white;
    border: 1px solid var(--color-accent);
    border-radius: 8px;
    padding: 1rem;
    max-width: 380px;
    min-width: 280px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    font-size: 0.9rem;
    line-height: 1.5;
    animation: popup-fade-in 0.2s ease-out;
}

@keyframes popup-fade-in {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.glossary-popup h4 {
    color: var(--color-dark);
    margin-bottom: 0.5rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.glossary-popup p {
    color: var(--color-text-light);
    margin: 0;
}

.popup-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
}

.popup-close:hover {
    color: #e74c3c;
}

/* ── Word-level tips ────────────────────────────────────────────────────── */
.word-tip {
    cursor: help;
    text-decoration: underline dotted #9b59b6;
    text-underline-offset: 2px;
    border-radius: 2px;
    transition: background 0.15s;
}

.word-tip:hover {
    background: rgba(155, 89, 182, 0.1);
}

/* Superscript Arabic badge inline in text */
.word-ar {
    font-size: 0.65em;
    font-style: normal;
    font-weight: 600;
    color: white;
    background: #c0392b;
    border-radius: 3px;
    padding: 0 3px;
    margin-left: 1px;
    vertical-align: super;
    line-height: 1;
    letter-spacing: 0;
}

/* Word popup */
.word-popup {
    position: absolute;
    z-index: 1100;
    background: #fff;
    border: 1px solid #d5c9f0;
    border-top: 3px solid #9b59b6;
    border-radius: 8px;
    padding: 1rem 1rem 0.9rem;
    max-width: 360px;
    min-width: 240px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.14);
    font-size: 0.88rem;
    line-height: 1.5;
    animation: popup-fade-in 0.18s ease-out;
}

.word-popup-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem 0.6rem;
    margin-bottom: 0.55rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid #ede7f6;
}

.word-popup-latin {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.15em;
    font-weight: 600;
    color: #2c3e50;
}

.word-popup-gloss {
    color: #555;
    font-style: italic;
    flex: 1 1 auto;
}

.word-popup-arabic-badge {
    font-size: 0.75em;
    font-weight: 600;
    color: white;
    background: #c0392b;
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
}

.word-popup-note {
    color: #444;
    margin: 0;
    font-size: 0.87em;
    line-height: 1.55;
}

/* ── Abacus symbol tables (Fol. 064v) with hover tooltips ──────────────── */
.sym-table {
    border-collapse: collapse;
    margin: 0.75rem 0 1.5rem;
    font-size: 1.15rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
}

.sym-table th,
.sym-table td {
    border: 1px solid #c8b8a2;
    padding: 0.5rem 1rem;
    text-align: center;
    min-width: 2.8rem;
}

.sym-table th {
    background: #f5efe6;
    font-weight: 600;
    color: #5a3e1b;
}

.sym-table td:empty::after {
    content: '—';
    color: #bbb;
    font-size: 0.85rem;
}

.sym-tip {
    position: relative;
    cursor: help;
}

.sym-tip::after {
    content: attr(data-meaning);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: #fff;
    font-size: 0.76rem;
    white-space: nowrap;
    padding: 4px 9px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 200;
    font-family: 'Source Sans Pro', sans-serif;
}

.sym-tip:hover::after {
    opacity: 1;
}

.gobar-key td:first-child {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.2rem;
}

/* Glossary Hint */
.glossary-hint {
    text-align: center;
    padding: 1rem;
    background: #f0f7ff;
    border-radius: 8px;
    margin-top: 1.5rem;
}

.glossary-hint p {
    color: var(--color-text-light);
    font-size: 0.9rem;
    margin: 0;
}

/* Manuscript Diagrams */
.manuscript-diagrams {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.diagram-item {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.diagram-item p {
    margin: 0 0 0.5rem 0;
    font-weight: 600;
    color: var(--color-dark);
}

.diagram-item ul {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--color-text-light);
    line-height: 1.6;
}

.diagram-item li {
    margin-bottom: 0.25rem;
}

/* Interactive Diagrams */
.interactive-diagrams {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #ddd;
    margin-bottom: 2rem;
}

.diagram-svg-container h5 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    color: var(--color-dark);
    margin-bottom: 1rem;
    font-size: 1.2rem;
    text-align: center;
}

.cosmology-svg {
    width: 100%;
    height: auto;
    max-height: 700px;
    border-radius: 6px;
    background: #fcfcfc;
    padding: 1rem;
}

.diagram-svg-container {
    overflow-x: auto;
}

.diagram-caption {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--color-text-light);
    font-style: italic;
    text-align: center;
}

/* Tables */
.manuscript-table {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.manuscript-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: white;
    border-radius: 6px;
    overflow: hidden;
}

.manuscript-table th {
    background: var(--color-dark);
    color: white;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
}

.manuscript-table td {
    padding: 0.5rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid #eee;
}

.manuscript-table tr:nth-child(even) {
    background: #f9f9f9;
}

.manuscript-table tr:hover {
    background: #fff8e6;
}

.table-note {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--color-text-light);
    font-style: italic;
}

/* Bibliography */
.bibliography ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bibliography li {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f0e6c8;
    line-height: 1.6;
    color: var(--color-text-light);
}

.bibliography li:last-child {
    border-bottom: none;
}

.bibliography li strong {
    color: var(--color-dark);
}

/* Notes Section */
.notes-section {
    background: #fffbf0;
    border-left: 4px solid var(--color-accent);
    padding: 1.5rem;
    border-radius: 0 8px 8px 0;
    margin-bottom: 2rem;
}

.notes-section h4 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: #9a7d0a;
    margin-bottom: 1rem;
}

.notes-section p {
    line-height: 1.8;
    color: var(--color-text-light);
    margin-bottom: 1rem;
}

.notes-section ul,
.notes-section ol {
    margin: 0.75rem 0 1rem 1.5rem;
    color: var(--color-text-light);
}

.notes-section li {
    margin-bottom: 0.5rem;
}

/* Note styling for translation progress */
p.note {
    background: #f0f7ff;
    border-left: 4px solid #4a90e2;
    padding: 1rem;
    border-radius: 0 6px 6px 0;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    color: #333;
}

p.note strong {
    color: #2c5282;
}

/* Annotations Section */
.annotations-section,
.metadata-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.annotations-section h3,
.metadata-section h3 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: var(--color-dark);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #ecf0f1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#annotation-list {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    min-height: 80px;
}

.annotation-item {
    padding: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 0.5rem;
}

.annotation-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.annotation-item strong {
    color: var(--color-dark);
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

#add-annotation textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    margin-bottom: 0.75rem;
}

#add-annotation textarea:focus {
    border-color: var(--color-accent);
    outline: none;
}

#add-annotation button {
    padding: 0.6rem 1.2rem;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

#add-annotation button:hover {
    background: #b8922a;
}

#clear-annotations-btn {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 0.4rem 0.8rem;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

#clear-annotations-btn:hover {
    background: #c0392b;
}

.metadata-section p {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

/* Integration Banner */
.integration {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem 2rem;
    border-radius: 12px;
    color: white;
    text-align: center;
}

.integration h3 {
    color: white;
    margin-bottom: 0.75rem;
}

.integration a {
    color: #ffd700;
    font-weight: 600;
}

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

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: #999;
    font-size: 0.85rem;
    border-top: 1px solid #eee;
    margin-top: 2rem;
}

footer a {
    color: var(--color-accent);
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

@media (max-width: 900px) {
    .hero h1 {
        font-size: 2.5rem;
    }
    
    .manuscript-preview {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .preview-visual {
        order: -1;
    }
    
    .approach-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .aligned-columns {
        grid-template-columns: 1fr;
    }

    .aligned-columns-header,
    .aligned-row {
        grid-template-columns: 1fr;
    }

    .latin-cell {
        border-right: none;
        border-bottom: 1px solid #e0d8ea;
    }
    
    nav ul {
        gap: 0.75rem;
    }
    
    .folio-nav {
        flex-direction: column;
    }
    
    #folio-selector {
        width: 100%;
    }
    
    .manuscript-diagrams {
        grid-template-columns: 1fr;
    }
    
    .cosmology-svg text {
        font-size: 10px;
    }
}

@media (max-width: 600px) {
    .hero h1 {
        font-size: 1.8rem;
        letter-spacing: 0.1em;
    }
    
    .approach-grid {
        grid-template-columns: 1fr;
    }
    
    .emblem-circle {
        width: 90px;
        height: 90px;
        font-size: 2rem;
    }
    
    .feature-card {
        flex-direction: column;
        gap: 1rem;
    }
    
    .container {
        padding: 3rem 1rem;
    }
    
    .scholarly-content {
        padding: 1.25rem;
    }
    
    .cosmology-svg text {
        font-size: 8px;
    }
}

/* ============================================================
   INTERACTIVE FEATURES (interactive.js)
   ============================================================ */

/* ── Cross-folio search ──────────────────────────────────── */
.sim-search-wrap {
    max-width: 900px;
    margin: 0 auto 1.1rem;
    padding: 0 1rem;
    position: relative;
}

.sim-search-bar {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid #d0c9b8;
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sim-search-bar:focus-within {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(201,162,39,0.14);
}

.sim-search-bar i { color: #bbb; font-size: 0.85rem; flex-shrink: 0; }

#sim-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.88rem;
    color: #333;
    background: transparent;
}

.sim-search-clear {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: #bbb;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.sim-search-clear:hover { color: #555; }

.sim-search-results {
    position: absolute;
    top: calc(100% + 2px);
    left: 1rem;
    right: 1rem;
    background: #fff;
    border: 1px solid #e4ddd0;
    border-radius: 8px;
    max-height: 360px;
    overflow-y: auto;
    box-shadow: 0 8px 28px rgba(0,0,0,0.12);
    padding: 0.8rem 0.9rem;
    z-index: 500;
    font-size: 0.82rem;
}

.sim-search-count {
    color: #999;
    margin-bottom: 0.55rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid #f0e8d8;
    font-size: 0.78rem;
}

.sim-search-empty {
    color: #999;
    text-align: center;
    padding: 0.4rem 0;
    font-size: 0.82rem;
}

.sim-search-group { margin-bottom: 0.85rem; }

.sim-search-folio-head {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.88rem;
    margin-bottom: 0.25rem;
}

.sim-search-folio-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-accent);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.sim-search-folio-btn:hover { color: #1a1a2e; text-decoration: underline; }
.sim-search-folio-btn i { font-size: 0.78rem; }

.sim-search-line {
    display: grid;
    grid-template-columns: 3.6rem 1fr 1fr;
    gap: 0.35rem;
    padding: 0.18rem 0;
    border-bottom: 1px solid #f8f4ee;
    align-items: baseline;
}
.sim-search-line:last-child { border-bottom: none; }

.sim-search-id   { color: #bbb; font-family: monospace; font-size: 0.72rem; }
.sim-search-lat  { color: #333; }
.sim-search-eng  { color: #777; font-style: italic; }

.sim-search-results mark {
    background: rgba(201,162,39,0.28);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* ── Concept animation button bar ──────────────────────────── */
.ca-buttons-bar {
    margin: 0 0 1.4rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #24243e 100%);
    border-radius: 8px;
    padding: 1rem 1.15rem 1rem;
    border: 1px solid rgba(201,162,39,0.22);
}

.ca-bar-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: var(--color-accent);
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.7rem;
}

.ca-bar-hint {
    margin-left: auto;
    font-weight: 400;
    font-style: italic;
    font-size: 0.78rem;
    color: rgba(201,162,39,0.6);
}

.ca-bar-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.ca-trigger-btn {
    display: flex;
    align-items: center;
    gap: 0.38rem;
    padding: 0.42rem 0.9rem;
    background: rgba(255,255,255,0.055);
    border: 1px solid rgba(201,162,39,0.28);
    border-radius: 6px;
    color: #e8d5a3;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.ca-trigger-btn:hover,
.ca-trigger-btn:focus-visible {
    background: rgba(201,162,39,0.18);
    border-color: var(--color-accent);
    color: #fff;
    outline: none;
}

.ca-btn-icon { font-size: 1.1rem; line-height: 1; }

/* ── Concept animation modal ────────────────────────────────── */
.ca-modal {
    position: fixed;
    inset: 0;
    background: rgba(8,8,20,0.82);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(2px);
}

.ca-modal-inner {
    background: #faf9f7;
    border-radius: 10px;
    max-width: 700px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.ca-modal-header {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1.15rem 1.2rem 0.8rem;
    border-bottom: 1px solid #ece4d4;
    flex-shrink: 0;
}

.ca-modal-icon { font-size: 2rem; line-height: 1; flex-shrink: 0; }

.ca-modal-titles { flex: 1; min-width: 0; }

.ca-modal-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.28rem;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0 0 0.12rem;
}

.ca-modal-sub {
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
    margin: 0;
}

.ca-modal-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: #bbb;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}
.ca-modal-close:hover { color: #333; }

.ca-modal-body {
    padding: 1rem 1.2rem;
    flex: 1;
    overflow-y: auto;
}

.ca-svg {
    width: 100%;
    height: auto;
    display: block;
}

.ca-modal-nav {
    padding: 0.7rem 1.2rem 1.1rem;
    border-top: 1px solid #ece4d4;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    flex-shrink: 0;
}

.ca-nav-btn {
    padding: 0.32rem 0.72rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 0.83rem;
    color: #666;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.ca-nav-btn.active {
    background: #1a1a2e;
    color: var(--color-accent);
    border-color: #1a1a2e;
}

.ca-nav-btn:hover:not(.active),
.ca-nav-btn:focus-visible:not(.active) {
    border-color: var(--color-accent);
    color: #1a1a2e;
    outline: none;
}

/* ── Concept animation steps & replay ──────────────────────── */
@keyframes stepIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ca-steps {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.85rem 0 1rem;
    border-top: 1px solid #ece4d4;
    margin-top: 0.25rem;
}

.ca-step {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    font-size: 0.84rem;
    line-height: 1.5;
    color: #444;
    opacity: 0;
    animation: stepIn 0.45s ease both;
}

.ca-step-num {
    flex-shrink: 0;
    width: 1.4rem;
    height: 1.4rem;
    background: var(--color-accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    margin-top: 0.1rem;
}

.ca-replay-btn {
    padding: 0.28rem 0.85rem;
    background: transparent;
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    white-space: nowrap;
    align-self: flex-start;
    transition: background 0.18s, color 0.18s;
    flex-shrink: 0;
}

.ca-replay-btn:hover {
    background: var(--color-accent);
    color: #fff;
}

/* ── Folio image zoom ───────────────────────────────────────── */
.folio-zoomable {
    cursor: zoom-in;
    transition: opacity 0.15s;
}
.folio-zoomable:hover { opacity: 0.95; }

.viewer-wrapper { position: relative; }

.zoom-hint {
    position: absolute;
    bottom: 0.6rem;
    right: 0.6rem;
    background: rgba(26,26,46,0.78);
    color: rgba(201,162,39,0.9);
    font-size: 0.75rem;
    padding: 0.28rem 0.6rem;
    border-radius: 4px;
    pointer-events: none;
    font-family: 'Source Sans Pro', sans-serif;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.zoom-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(3px);
}

.zoom-modal-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    max-width: 95vw;
    max-height: 95vh;
}

.zoom-close {
    position: absolute;
    top: -2.6rem;
    right: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 2.2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
}
.zoom-close:hover { color: #fff; }

.zoom-img {
    max-width: 100%;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 3px;
    display: block;
    box-shadow: 0 4px 30px rgba(0,0,0,0.6);
}

.zoom-caption {
    color: rgba(255,255,255,0.5);
    font-size: 0.76rem;
    font-style: italic;
    text-align: center;
}

/* ── Responsive adjustments ─────────────────────────────────── */
@media (max-width: 600px) {
    .ca-bar-hint { display: none; }
    .ca-trigger-btn { font-size: 0.82rem; padding: 0.38rem 0.7rem; }
    .ca-modal-title { font-size: 1.1rem; }
    .sim-search-line { grid-template-columns: 3rem 1fr; }
    .sim-search-eng { display: none; }
    .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
    .gallery-item { font-size: 0.75rem; }
}

/* ── Folio gallery ──────────────────────────────────────────── */
.gallery-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.38rem 0.8rem;
    background: rgba(201, 162, 39, 0.1);
    border: 1px solid rgba(201, 162, 39, 0.35);
    border-radius: 6px;
    color: var(--color-accent);
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.84rem;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s;
    white-space: nowrap;
}
.gallery-open-btn:hover {
    background: rgba(201, 162, 39, 0.22);
    border-color: var(--color-accent);
}

.gallery-modal {
    position: fixed;
    inset: 0;
    background: rgba(8, 8, 20, 0.85);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(3px);
}

.gallery-inner {
    background: #1a1a2e;
    border-radius: 10px;
    max-width: 860px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
    border: 1px solid rgba(201, 162, 39, 0.2);
}

.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(201, 162, 39, 0.18);
    flex-shrink: 0;
}

.gallery-header h3 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.gallery-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: rgba(255,255,255,0.5);
    line-height: 1;
    padding: 0;
    transition: color 0.15s;
}
.gallery-close:hover { color: #fff; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.7rem;
    padding: 1rem 1.25rem 1.25rem;
    overflow-y: auto;
}

.gallery-item {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.18s, background 0.18s, transform 0.15s;
    text-align: left;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: rgba(255,255,255,0.85);
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.78rem;
}

.gallery-item:hover {
    border-color: var(--color-accent);
    background: rgba(201, 162, 39, 0.1);
    transform: translateY(-2px);
}

.gallery-item.current {
    border-color: var(--color-accent);
    background: rgba(201, 162, 39, 0.12);
}

.gallery-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    background: #0d0d1e;
    overflow: hidden;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s;
    opacity: 0;
}

.gallery-thumb img.loaded,
.gallery-thumb img[complete] {
    opacity: 1;
}

.gallery-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(201, 162, 39, 0.3);
    font-size: 1.5rem;
}

.gallery-current-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: var(--color-accent);
    color: #1a1a2e;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.gallery-label {
    padding: 0.45rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.gallery-label strong {
    color: var(--color-accent);
    font-size: 0.82rem;
}

.gallery-type {
    color: rgba(255,255,255,0.4);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.gallery-title-text {
    color: rgba(255,255,255,0.7);
    font-size: 0.72rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Folio arrow navigation ─────────────────────────────────── */
.folio-arrow-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(201, 162, 39, 0.08);
    border: 1px solid rgba(201, 162, 39, 0.28);
    border-radius: 5px;
    color: var(--color-accent);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    flex-shrink: 0;
}

.folio-arrow-btn:hover:not(:disabled) {
    background: rgba(201, 162, 39, 0.22);
    border-color: var(--color-accent);
}

.folio-arrow-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

/* Nav toast notification */
.nav-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(26, 26, 46, 0.92);
    color: var(--color-accent);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.55rem 1.2rem;
    border-radius: 30px;
    border: 1px solid rgba(201, 162, 39, 0.3);
    box-shadow: 0 4px 20px rgba(0,0,0,0.35);
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    z-index: 1500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

.nav-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Parchment reading mode ─────────────────────────────────── */
.parchment-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0.5rem auto 0.75rem;
    padding: 0.4rem 1rem;
    background: transparent;
    border: 1px solid #d0c4a8;
    border-radius: 6px;
    color: #8a7a5a;
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.18s;
}

.parchment-toggle-btn:hover {
    border-color: #b9a870;
    color: #5a4a2a;
    background: rgba(180, 150, 80, 0.07);
}

.parchment-toggle-btn.active {
    border-color: #c9a870;
    background: rgba(201, 168, 100, 0.1);
    color: #6a4a1a;
}

/* Parchment mode global styles */
body.parchment-mode .viewer-wrapper,
body.parchment-mode .annotations-section,
body.parchment-mode .metadata-section,
body.parchment-mode .integration {
    display: none;
}

body.parchment-mode .scholarly-content {
    background: #f8f4e8;
    background-image:
        radial-gradient(ellipse at 20% 30%, rgba(180,150,80,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 70%, rgba(160,130,60,0.05) 0%, transparent 60%);
    border: 1px solid #d8c898;
    border-radius: 4px;
    box-shadow:
        inset 0 0 80px rgba(180,150,80,0.07),
        0 2px 12px rgba(0,0,0,0.06);
    color: #2a1f0e;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.06rem;
    line-height: 1.95;
}

body.parchment-mode .scholarly-content h3 {
    color: #6a2a0a;
    font-size: 1.5rem;
    border-bottom: 1px solid #d0b870;
    padding-bottom: 0.4rem;
    margin-bottom: 1rem;
}

body.parchment-mode .scholarly-content h4 {
    color: #5a3a1a;
    font-size: 1.15rem;
    margin-top: 1.4rem;
}

body.parchment-mode .aligned-columns {
    border: 1px solid #d8c898;
    border-radius: 4px;
    overflow: hidden;
}

body.parchment-mode .latin-aligned-column,
body.parchment-mode .english-aligned-column,
body.parchment-mode .latin-cell,
body.parchment-mode .english-cell {
    background: transparent;
}

body.parchment-mode .aligned-line:hover,
body.parchment-mode .aligned-line.highlighted {
    background: rgba(180, 140, 60, 0.18);
}

body.parchment-mode .folio-label,
body.parchment-mode .folio-type {
    background: rgba(106, 42, 10, 0.12);
    color: #6a2a0a;
    border-color: #d0a870;
}

body.parchment-mode .sim-search-wrap {
    display: none;
}

/* ── Copy buttons on Latin lines ────────────────────────────── */
.latin-aligned-column .aligned-line {
    position: relative;
}

.copy-line-btn {
    position: absolute;
    right: 0.2rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0.2rem 0.3rem;
    cursor: pointer;
    color: #ccc;
    font-size: 0.72rem;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    border-radius: 3px;
    line-height: 1;
}

.latin-aligned-column .aligned-line:hover .copy-line-btn {
    opacity: 1;
}

.copy-line-btn:hover {
    color: var(--color-accent);
    background: rgba(201, 162, 39, 0.1);
}

.copy-line-btn.copied {
    color: #5a9a5a;
    opacity: 1;
}

/* Section break separator in aligned text columns */
.aligned-section-break {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin: 0.75em 0;
    color: #888;
    font-size: 0.78em;
    font-style: italic;
    letter-spacing: 0.03em;
}
.aligned-section-break::before,
.aligned-section-break::after {
    content: '';
    flex: 1;
    border-top: 1px dashed #ccc;
}
.aligned-section-break span {
    white-space: nowrap;
}

/* ── Row-based aligned text renderer ────────────────────────────── */
.aligned-rows-wrapper {
    border: 1px solid #e0d8ea;
    border-radius: 8px;
    overflow: hidden;
}

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

.aligned-columns-header .latin-aligned-column,
.aligned-columns-header .english-aligned-column {
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: none;
}

.aligned-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid #eee;
}

.aligned-row:last-child {
    border-bottom: none;
}

.latin-cell,
.english-cell {
    background: #fafafa;
    display: flex;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    position: relative;
}

.latin-cell {
    border-right: 1px solid #e0d8ea;
}

.latin-cell .line-text {
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
    color: var(--color-dark);
    line-height: 1.5;
}

.english-cell .line-text {
    color: #444;
    line-height: 1.5;
}

.latin-cell .line-text.glossary-term {
    color: #8e44ad;
    cursor: pointer;
}

.latin-cell .line-text.glossary-term:hover {
    background: #f3e5f5;
}

.latin-cell.aligned-line.highlighted {
    background-color: #fff3cd;
    box-shadow: inset 3px 0 0 var(--color-accent);
}

.english-cell.aligned-line.highlighted {
    background-color: #fff3cd;
    box-shadow: inset -3px 0 0 var(--color-accent);
}

.latin-cell.aligned-line:hover .copy-line-btn {
    opacity: 1;
}

/* Apparatus note (collapsible, below translation in English cell) */
.line-apparatus {
    width: 100%;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: var(--color-text-light);
}

.line-apparatus summary {
    cursor: pointer;
    color: #7a5520;
    font-style: italic;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.1rem 0.4rem;
    border: 1px solid #d4b896;
    border-radius: 3px;
    background: #fdf6ee;
    font-size: 0.75rem;
    transition: background 0.15s;
}

.line-apparatus summary:hover {
    background: #f5e8d5;
}

.line-apparatus[open] summary {
    margin-bottom: 0.4rem;
}

.line-apparatus > :not(summary) {
    padding: 0.5rem 0.6rem;
    background: #fdf6ee;
    border-left: 2px solid #b07d2e;
    border-radius: 0 4px 4px 0;
    line-height: 1.6;
}

/* Latin mode toggle: expanded vs MS abbreviated */
.aligned-text-header-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.aligned-text-header-row h4 {
    margin: 0;
}

.latin-mode-toggle {
    font-size: 0.78rem;
    font-family: 'Source Sans Pro', sans-serif;
    padding: 0.25rem 0.7rem;
    border: 1px solid #b89fcc;
    border-radius: 4px;
    background: #f5f0fa;
    color: #5a3a7a;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.latin-mode-toggle:hover {
    background: #ede0f5;
    color: #3a1a5a;
}

.latin-mode-toggle[aria-pressed="true"] {
    background: #5a3a7a;
    color: #fff;
    border-color: #5a3a7a;
}

/* Abbreviated word in expanded view — clickable, shows MS form on click */
.was-abbrev {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: #9b59b6;
    text-underline-offset: 2px;
    cursor: pointer;
    color: inherit;
}

.was-abbrev:hover {
    background: #f3e5f5;
    border-radius: 2px;
}

.was-abbrev-uncertain {
    text-decoration-color: #e67e22;
}

/* Default: show expanded, hide MS form */
.latin-ms {
    display: none;
}

.latin-expanded {
    display: inline;
}

/* MS mode: flip visibility */
.ms-mode .latin-ms {
    display: inline;
}

.ms-mode .latin-expanded {
    display: none;
}

/* Full-width HTML block (e.g. star table) within aligned rows */
.aligned-html-block {
    padding: 1rem 1.25rem;
    background: #f8f5ff;
    border-top: 2px solid #c9a0dc;
    border-bottom: 2px solid #c9a0dc;
}

.ms-table-caption {
    font-size: 0.82rem;
    color: #666;
    margin: 0 0 0.75rem 0;
    line-height: 1.5;
}

/* Star table within aligned-html-block */
.ms-star-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
}

.ms-star-table th {
    background: #7d3c98;
    color: white;
    padding: 0.45rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid #6c3483;
    letter-spacing: 0.02em;
}

.ms-star-table td {
    padding: 0.3rem 0.75rem;
    border: 1px solid #e0d0f0;
    vertical-align: middle;
}

.ms-star-table tbody tr:nth-child(even) td {
    background: #fdf8ff;
}

.ms-star-table tbody tr:nth-child(odd) td {
    background: white;
}

.ms-star-table tr.zone-header td {
    background: #ede0f8;
    color: #5b2c6f;
    font-style: italic;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.2rem 0.75rem;
    letter-spacing: 0.03em;
    border-color: #cca8e8;
}

/* ── Abacus Demonstration Table (Fol. 41v) ──────────────────────── */
.abacus-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
    font-size: 0.95rem;
    margin: 0.75rem 0;
}

.abacus-table th.abacus-col-head {
    background: #8b0000;
    color: white;
    text-align: center;
    padding: 0.5rem 0.75rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border: 2px solid #600000;
    line-height: 1.3;
}

.abacus-table th.abacus-col-head .colhead-sub {
    display: block;
    font-size: 0.62rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    opacity: 0.9;
    font-style: italic;
    margin-top: 2px;
}

.abacus-table td {
    text-align: center;
    padding: 0.35rem 0.75rem;
    border: 1px solid #c9a0dc;
    font-size: 1.05rem;
    color: #2c0052;
    font-weight: 600;
    min-width: 60px;
}

.abacus-table tbody tr:nth-child(even) td {
    background: #fdf8ff;
}

.abacus-table tbody tr:nth-child(odd) td {
    background: white;
}

.abacus-table td.abacus-empty {
    color: #bbb;
    font-weight: 400;
    font-size: 0.9rem;
    background: #f9f9f9 !important;
}

/* Blank separator rows in abacus table */
.abacus-table tr.abacus-separator td {
    background: #f3eaff !important;
    border-color: #e0d0f0;
    padding: 0.15rem;
    height: 6px;
}

/* Caption */
.abacus-table caption {
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.78rem;
    color: #888;
    text-align: left;
    padding: 0 0 0.4rem 0;
    font-style: italic;
}

/* Intro / note paragraphs around the abacus table */
.table-intro, .table-note {
    font-size: 0.82rem;
    color: #555;
    line-height: 1.55;
    margin: 0.4rem 0;
}
.table-note { font-style: italic; }

/* ── Paleography Section ──────────────────────────────────────────── */
.paleography-section {
    background: #fdf6ee;
    border-left: 4px solid #b07d2e;
    padding: 1.5rem;
    border-radius: 0 8px 8px 0;
    margin-bottom: 2rem;
}

.paleography-section h4 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: #7a5520;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.paleography-section p,
.paleography-section li {
    line-height: 1.8;
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
}

.paleography-section ul {
    margin: 0.5rem 0 1rem 1.5rem;
}

/* ── Explanations block (context, notes, diagrams, bibliography) ─── */
.explanations-section {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--color-border, #d4c5a9);
}

/* ── Paleography / Abbreviation Tables (in notes section) ────────── */
.paleography-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0.5rem 0 1rem 0;
    font-family: 'Source Sans Pro', sans-serif;
}

.paleography-table th {
    background: #2c3e50;
    color: white;
    padding: 0.4rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    border: 1px solid #1a252f;
    letter-spacing: 0.02em;
}

.paleography-table td {
    padding: 0.35rem 0.75rem;
    border: 1px solid #ddd;
    vertical-align: top;
}

.paleography-table tbody tr:nth-child(even) td {
    background: #f7f9fb;
}

.paleography-table tbody tr:nth-child(odd) td {
    background: white;
}

.paleography-table td:first-child {
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
    color: #6c3483;
    font-weight: 600;
}
