/* Synopsis Viewer V3 - Line-based Layout Styles */

:root {
    --primary-color: #0056b3;
    --secondary-color: #007bff;
    --accent-color: #ffc107;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #e74c3c;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --text-dark: #212529;
    --text-light: #666;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --print-font-size: 13px;
    --witness-font-size: 13px;
    --modal-font-size: 12.5px;
}

/* Witness Browse Loading States */
.wb-loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.wb-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.wb-error {
    text-align: center;
    padding: 3rem;
    color: var(--danger-color);
}

.wb-error-message {
    margin-bottom: 1rem;
    font-size: 1.1em;
}

.wb-retry-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.wb-retry-button:hover {
    background: var(--secondary-color);
}

.wb-instructions {
    padding: 2rem;
    text-align: center;
    color: var(--text-light);
}

.wb-instructions h3 {
    color: var(--text-dark);
    margin-bottom: 1rem;
}

.wb-instructions ul {
    list-style: none;
    margin-top: 1rem;
}

.wb-instructions li {
    margin: 0.5rem 0;
}

/* Virtual Scrolling */
.wb-virtual-container {
    min-height: 400px;
}

.wb-virtual-nav {
    position: sticky;
    bottom: 0;
    background: var(--bg-white);
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
}

.wb-virtual-nav button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    margin: 0 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.wb-virtual-nav button:hover {
    background: var(--secondary-color);
}

.wb-virtual-nav span {
    margin: 0 1rem;
    color: var(--text-light);
    font-size: 0.9em;
}

/* Progressive Loading States */
.wb-consensus-progress {
    background: var(--bg-light);
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9em;
    border-left: 3px solid var(--primary-color);
    transition: opacity 0.3s ease;
}

.wb-consensus-error {
    background: #fff3cd;
    color: #856404;
    border-left-color: var(--warning-color);
}

.wb-mini-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--border-color);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Loading state for words */
.wb-word.loading {
    background: #f8f9fa;
    color: var(--text-light);
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.wb-word.loading:hover {
    background: #e9ecef;
}

/* Smooth transition for status changes */
.wb-word {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

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

body {
    font-family: 'David', 'Times New Roman', serif;
    margin: 0;
    background-color: #f4f6f9;
    color: #212529;
    direction: rtl;
    text-align: right;
    font-size: 15px;
    line-height: 1.3;
}

.layout-body {
    background-color: #f4f6f9;
}

.content-area {
    max-width: 1900px;
    margin: 0 auto;
    padding: 1.2em 1.4em;
}

.container {
    background: var(--bg-white);
    box-shadow: var(--shadow);
    border-radius: 8px;
    padding: 0.8em 1em 1.2em;
    margin-top: 1.2em;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid #ccc;
}

.header h1 {
    color: var(--primary-color);
    font-size: 20px;
    margin: 0;
}

.header-info {
    font-size: 12px;
    color: var(--text-light);
}

/* Navigation */
.navigation {
    display: flex;
    gap: 0.5em;
    margin-bottom: 1em;
    justify-content: center;
    align-items: center;
    background: var(--bg-light);
    padding: 0.8em;
    border-radius: 5px;
}

.nav-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.5em 1em;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 12px;
}

.nav-btn:hover:not(:disabled) {
    background: #0056b3;
}

.nav-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.nav-spacer {
    flex: 1;
}

/* Settings Panel */
.settings-panel {
    display: flex;
    gap: 1em;
    align-items: center;
    background: var(--bg-light);
    padding: 0.5em 1em;
    border-radius: 5px;
    margin-bottom: 1em;
    font-size: 12px;
    flex-wrap: wrap;
}

.settings-group {
    display: flex;
    align-items: center;
    gap: 0.3em;
}

.witness-filter-group {
    align-items: flex-start;
}

.settings-group label {
    font-weight: 500;
    margin-left: 0.5em;
}

.settings-group select,
.settings-group input {
    padding: 0.4em;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    cursor: pointer;
}

.checkbox-inline input {
    width: 16px;
    height: 16px;
    padding: 0;
    margin: 0;
}

#chapterSelect {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#chapterSelect option {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.witness-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4em;
    max-width: 480px;
}

.witness-filter-item {
    display: flex;
    align-items: center;
    gap: 0.25em;
    border: 1px solid #d0d5dd;
    border-radius: 4px;
    padding: 0.2em 0.5em;
    background: #ffffff;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.witness-filter-item input[type="checkbox"] {
    margin: 0;
    accent-color: var(--secondary-color);
}

.witness-filter-item.active {
    background: #e7f1ff;
    border-color: var(--secondary-color);
    color: var(--primary-color);
}

.stats-btn {
    background: var(--warning-color);
    color: white;
    border: none;
    padding: 0.4em 0.8em;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

/* Synopsis Container */
.synopsis-container {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    overflow: auto;
    max-height: calc(100vh - 300px);
}

/* Apparatus Table */
.apparatus-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.synopsis-line-group {
    border-bottom: 1px solid #eaeaea;
    margin-bottom: 0.6em;
}

.synopsis-line-separator {
    height: 10px;
    background: #f6f7f9;
    border: none;
}

.apparatus-row {
    border-bottom: none;
}

.apparatus-row:hover {
    background-color: #fdfdfd;
}

/* Sigla cells */
.sigla-cell {
    width: 50px;
    padding: 0.2em 0.4em;
    font-weight: bold;
    font-size: 10px;
    background-color: var(--bg-light);
    border-left: 2px solid #6c757d;
    vertical-align: top;
    text-align: center;
}

.sigla-print {
    border-left-color: var(--accent-color);
    background-color: #fffef7;
}

.sigla-witness {
    border-left-color: var(--secondary-color);
}

/* Text cells */
.text-cell {
    padding: 0.25em 0.4em;
    font-size: 13px;
    line-height: 1.4;
    vertical-align: top;
    position: relative;
}

.synopsis-grid {
    display: grid;
    gap: 0.35em;
    align-items: flex-start;
    direction: rtl;
}

.synopsis-column {
    min-height: 1.8em;
    display: flex;
    flex-direction: column;
    gap: 0.15em;
    text-align: right;
}

.print-text {
    background-color: transparent;
    font-weight: 600;
    font-size: var(--print-font-size, 13px);
}

.witness-text {
    transition: background-color 0.15s;
    font-size: var(--witness-font-size, 13px);
}

.synopsis-placeholder {
    color: #b0b5ba;
    font-style: italic;
    font-size: 0.95em;
}

.witness-word {
    display: inline-flex;
    align-items: center;
    column-gap: 0.1em;
}

.witness-text.modified {
    background-color: #e8f5e8;
    border-right: 3px solid var(--success-color);
}

/* Clickable words */
.clickable-word {
    cursor: pointer;
    padding: 1px 2px;
    margin: 0 1px;
    border-radius: 2px;
    transition: all 0.1s ease;
    display: inline-block;
}

.clickable-word:hover {
    background-color: #e3f2fd;
    box-shadow: 0 0 2px rgba(0,123,255,0.4);
}

.clickable-word.aligned {
    background: rgba(76, 175, 80, 0.18);
    border-bottom: 1px solid var(--success-color);
}

.clickable-word.partial {
    background: rgba(255, 152, 0, 0.18);
    border-bottom: 1px solid var(--warning-color);
}

.clickable-word.unaligned {
    background: rgba(231, 76, 60, 0.18);
    border-bottom: 1px solid var(--danger-color);
}

.clickable-word.status-agree,
.witness-word.status-agree {
    background: rgba(76, 175, 80, 0.22);
    border-bottom: 1px solid var(--success-color);
}

.clickable-word.status-different,
.witness-word.status-different {
    background: rgba(255, 193, 7, 0.25);
    border-bottom: 1px solid #ff9800;
}

.clickable-word.status-missing,
.witness-word.status-missing {
    background: rgba(231, 76, 60, 0.22);
    border-bottom: 1px solid #c62828;
    color: #546a7b;
}

.clickable-word.status-unmapped,
.witness-word.status-unmapped {
    background: rgba(158, 167, 176, 0.22);
    border-bottom: 1px dashed #90a4ae;
    color: #546a7b;
}

.clickable-word.highlighted {
    background: rgba(0, 123, 255, 0.28) !important;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.45);
}

.clickable-word.search-highlight {
    background: rgba(255, 255, 0, 0.6) !important;
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.8);
    animation: searchPulse 2s ease-in-out;
}

@keyframes searchPulse {
    0%, 100% {
        box-shadow: 0 0 8px rgba(255, 193, 7, 0.8);
    }
    50% {
        box-shadow: 0 0 15px rgba(255, 193, 7, 1);
    }
}

.paragraph-content.search-highlight {
    background: rgba(255, 255, 0, 0.1) !important;
    border-left: 4px solid #ffc107;
    animation: paragraphPulse 2s ease-in-out;
}

@keyframes paragraphPulse {
    0%, 100% {
        background: rgba(255, 255, 0, 0.1);
    }
    50% {
        background: rgba(255, 255, 0, 0.2);
    }
}

.no-alignment {
    color: #999;
    font-style: italic;
    padding: 0 0.5em;
}

/* Line status indicators */
.line-edited {
    position: relative;
    border-left: 3px solid var(--accent-color) !important;
}

.line-edited::before {
    content: '✎';
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    color: var(--accent-color);
    font-weight: bold;
}

/* Line Edit Modal (V1 Style) */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1300;
    display: none;
    backdrop-filter: blur(2px);
}

.popup-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 1.5em;
    border-radius: 8px;
    width: 80vw;
    max-width: 1200px;
    max-height: 95%;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    direction: rtl;
}

.popup-content h3 {
    margin-bottom: 1em;
    color: var(--primary-color);
    font-size: 18px;
}

/* Line info section */
.line-info-section {
    background: var(--bg-light);
    padding: 0.8em;
    border-radius: 5px;
    margin-bottom: 1em;
}

.line-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5em;
    font-size: 13px;
}

/* Parallel alignment box */
.parallel-alignment-box {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 0.4em 0.6em;
    margin-bottom: 0.8em;
    font-family: 'David', 'Times New Roman', serif;
}

.parallel-row {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.1em;
    border-bottom: 1px solid #e3e6ea;
    padding-bottom: 0.1em;
}

.parallel-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.parallel-sigla {
    width: 60px;
    font-weight: bold;
    font-size: 10px;
    color: var(--primary-color);
    margin-left: 0.5em;
    flex-shrink: 0;
}

.parallel-text {
    flex: 1;
    font-size: var(--modal-font-size, 12.5px);
    line-height: 1.1;
    padding: 0 0.1em;
    background: transparent;
    border-radius: 0;
    border: 0;
}

.parallel-text.print {
    background: #fffef7;
    border: 0;
    font-weight: 500;
}

.parallel-text.manuscript {
    background: transparent;
    border: 0;
}

.parallel-loading {
    text-align: center;
    font-size: 0.9em;
    color: #666;
    padding: 0.6em 0;
}

.parallel-empty {
    color: #9aa0a6;
    font-style: italic;
}

/* Line editor section */
.line-editor-section {
    margin: 1em 0;
}

.line-editor-textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.8em;
    font-size: 25px;
    font-family: 'David', 'Times New Roman', serif;
    border: 2px solid #ced4da;
    border-radius: 5px;
    text-align: right;
    direction: rtl;
    resize: vertical;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.line-editor-textarea:focus {
    outline: 0;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Image styling */
.line-image {
    max-width: 100%;
    max-height: 360px;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: zoom-in;
}

.line-image.zoomed {
    cursor: zoom-out;
    max-height: none;
    max-width: none;
}

.image-container {
    text-align: center;
    margin: 0.5em 0;
    background: #f8f9fa;
    padding: 0.3em;
    border-radius: 3px;
}

.image-loading-message {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 0.4em;
}

/* Modal actions */
.modal-actions {
    display: flex;
    gap: 0.5em;
    justify-content: flex-end;
    margin-top: 1.5em;
    flex-wrap: wrap;
}

.btn {
    padding: 0.5em 1em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 0.2em;
    font-size: 12px;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-warning {
    background-color: #ffc107;
    color: #333;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Auto-save indicator */
.auto-save-indicator {
    position: absolute;
    top: 1em;
    left: 1em;
    background: var(--success-color);
    color: white;
    padding: 0.3em 0.6em;
    border-radius: 3px;
    font-size: 11px;
    animation: fadeInOut 2s infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Image overlay */
.image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    padding: 1.5em;
}

.overlay-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

.overlay-content img {
    max-width: 100%;
    max-height: 90vh;
    cursor: zoom-in;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.overlay-highlight {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    border-radius: 4px;
}

.overlay-close {
    position: absolute;
    top: -10px;
    left: -10px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    font-size: 22px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1300;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-btn:hover {
    background: rgba(255,255,255,0.1);
}

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Edit Form */
.edit-form {
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.original-text {
    display: inline-block;
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    font-family: monospace;
    direction: rtl;
}

.edit-input,
.edit-textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    direction: rtl;
}

.edit-input:focus,
.edit-textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.3);
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-start;
    margin-top: 1rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--success-color);
    color: white;
}

.btn-primary:hover {
    background: #45a049;
}

.btn-secondary {
    background: var(--warning-color);
    color: white;
}

.btn-secondary:hover {
    background: #e68900;
}

.btn-cancel {
    background: var(--danger-color);
    color: white;
}

.btn-cancel:hover {
    background: #c62828;
}

/* Image Preview */
.image-preview {
    border-top: 1px solid #dee2e6;
    padding-top: 1rem;
    text-align: center;
}

.image-preview canvas,
.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

/* Search Results */
.search-result {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.search-result:hover {
    background: var(--bg-light);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result-type {
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.search-result-text {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.search-result-context {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.4;
}

.search-result-location {
    font-size: 0.8rem;
    color: var(--secondary-color);
    font-weight: 600;
    margin-top: 0.25rem;
}

/* Statistics */
.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-light);
}

.stat-value {
    font-weight: 600;
    color: var(--primary-color);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.loading-spinner {
    text-align: center;
    color: var(--primary-color);
}

.loading-spinner i {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.loading-spinner p {
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0.5em;
    }

    .settings-panel {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .settings-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.2rem;
    }

    .apparatus-table {
        font-size: 11px;
    }

    .text-cell {
        padding: 0.15em 0.3em;
    }

    .modal-content {
        width: 95%;
        margin: 2% auto;
    }

    .form-actions {
        flex-direction: column;
    }
}

/* Layout additions */
.layout-body {
    background-color: #f4f6f9;
}

.main-header {
    background-color: #11324d;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    position: sticky;
    top: 0;
    z-index: 1200;
}

.main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1900px;
    margin: 0 auto;
    padding: 0.6em 1.4em;
}

.nav-brand {
    font-size: 1.1rem;
    font-weight: 600;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.2em;
    margin: 0;
    padding: 0;
}

.nav-item a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-weight: 500;
    padding: 0.3em 0.65em;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.nav-item a:hover,
.nav-item a.active {
    background-color: rgba(255,255,255,0.18);
}

.content-area {
    max-width: 1900px;
    margin: 0 auto;
    padding: 1.2em 1.4em;
}

.page-container {
    background: var(--bg-white);
    box-shadow: var(--shadow);
    border-radius: 8px;
    padding: 1.5em;
}

.page-container h1 {
    margin-top: 0;
    margin-bottom: 0.4em;
}

.page-subtitle {
    color: #546a7b;
    margin-bottom: 1.5em;
}

.placeholder-box {
    border: 1px dashed #b7c2cc;
    padding: 2em;
    text-align: center;
    color: #6c7a89;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 0.6em;
    align-items: center;
    font-size: 1rem;
}

.placeholder-box i {
    font-size: 1.6rem;
    color: var(--secondary-color);
}

.settings-page .settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

.settings-section {
    background: #f8fbff;
    border: 1px solid #e0e8f0;
    border-radius: 6px;
    padding: 1em 1.2em;
}

.settings-section h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: auto minmax(120px, 180px);
    gap: 0.6em 1em;
    align-items: center;
}

.settings-form input[type="number"],
.settings-form input[type="text"] {
    padding: 0.4em 0.6em;
    border-radius: 4px;
    border: 1px solid #ced6dd;
    font-size: 0.95rem;
}

.settings-form input[readonly] {
    background: #f1f4f8;
}

.settings-actions {
    display: flex;
    gap: 0.6em;
}

.settings-status {
    margin-top: 0.8em;
    min-height: 1.2em;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.settings-status[data-status="success"] {
    color: var(--success-color);
}

.settings-status[data-status="info"] {
    color: var(--secondary-color);
}

.modal-file-hint {
    font-size: 0.8em;
    color: #888;
    font-weight: normal;
}

.screen-reader-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.search-group {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.search-input {
    min-width: 180px;
    padding: 0.35em 0.45em;
    border: 1px solid #ced6dd;
    border-radius: 4px;
    font-size: 0.95rem;
}

.overlay-content img.zoomed {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
}

/* Witness browse page */
.witness-browse-page .wb-controls {
    display: flex;
    align-items: center;
    gap: 1em;
    margin-bottom: 1.2em;
}

.wb-controls select {
    min-width: 160px;
    padding: 0.35em 0.6em;
    border-radius: 4px;
    border: 1px solid #ced6dd;
    font-size: 0.95rem;
}

.wb-legend {
    display: flex;
    gap: 0.75em;
    font-size: 0.85rem;
    color: #4a5a68;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
}

.wb-content {
    display: flex;
    flex-direction: column;
    gap: .1em;
}

.wb-section {
    background: #fdfdfd;
    border: 1px solid #edf1f5;
    border-radius: 6px;
    padding: 1em;
}

.wb-section-title {
    margin: 0 0 0.8em 0;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.wb-paragraph {
    margin-bottom: 0.4em;
    line-height: 1.3;
}

.wb-page {
    border: 1px solid #e3e7ec;
    border-radius: 6px;
    padding: 0.8em 1em;
    background: #fff;
}

.wb-page-header {
    font-weight: 600;
    margin-bottom: 0.6em;
    color: var(--secondary-color);
}

.wb-line {
    margin-bottom: 0.05em;
    line-height: 1.2;
}

.wb-word {
    display: inline-block;
    padding: 0.08em 0.25em;
    margin: 0;
    border-radius: 0;
    transition: background-color 0.2s ease;
    font-size: var(--witness-font-size, 13px);
}

.wb-word.status-agree {
    background: rgba(76, 175, 80, 0.22);
}

.wb-word.status-different {
    background: rgba(255, 193, 7, 0.25);
}

.wb-word.status-missing {
    background: rgba(231, 76, 60, 0.22);
}

.wb-word.status-unmapped {
    background: rgba(158, 167, 176, 0.22);
}

.wb-word + .wb-word {
    margin-left: 0;
}

.wb-word:hover {
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}

.wb-loading,
.wb-error {
    text-align: center;
    padding: 2em;
    color: #6c7a89;
}

.wb-error {
    color: #c0392b;
    font-weight: 600;
}

.wb-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.wb-modal.visible {
    display: flex;
}

.wb-modal-dialog {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 720px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.2em 1.4em;
    position: relative;
}

.wb-close {
    position: absolute;
    top: 12px;
    left: 12px;
    border: none;
    background: rgba(0,0,0,0.4);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
}

.wb-modal-body h2 {
    margin-top: 0;
    color: var(--primary-color);
    margin-bottom: 0.8em;
}

.wb-modal-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25em;
    margin-bottom: 1em;
    background: #f6f9fc;
    padding: 0.6em;
    border-radius: 6px;
}

.wb-modal-line .wb-word {
    cursor: default;
}

.wb-comparison-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4em;
}

.wb-comparison-label {
    font-weight: 600;
    margin-left: 0.4em;
    color: #2c3e50;
}

.wb-comparison-value {
    color: #3d4f5c;
}
.legend-item::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: rgba(76, 175, 80, 0.22);
}

.legend-item.status-different::before {
    background: rgba(255, 193, 7, 0.25);
}

.legend-item.status-missing::before {
    background: rgba(231, 76, 60, 0.22);
}

.main-nav.nav-wrap .nav-links {
    flex-wrap: wrap;
}

/* Collapsible Paragraph Styles */
.paragraph-header {
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
}

.paragraph-header-cell {
    padding: 0 !important;
}

.paragraph-toggle {
    width: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: none;
    padding: 8px 12px;
    text-align: right;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.paragraph-toggle:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    color: #343a40;
}

.toggle-icon {
    font-size: 0.8rem;
    margin-left: 8px;
    transition: transform 0.2s ease;
}

.paragraph-content {
    transition: all 0.3s ease;
}

/* Title paragraphs get special styling */
.paragraph-header:has(.paragraph-toggle:contains('כותרת')) {
    background: #e3f2fd;
    border-top-color: #2196f3;
}

.paragraph-header:has(.paragraph-toggle:contains('כותרת')) .paragraph-toggle {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
    font-weight: 700;
}

.paragraph-header:has(.paragraph-toggle:contains('כותרת')) .paragraph-toggle:hover {
    background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
}

/* Enhanced Synopsis - Unaligned Segments */
.unaligned-paragraph-header {
    background: #fff3cd;
    border-top: 2px solid #ffc107;
}

.unaligned-paragraph-header .paragraph-toggle {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    font-weight: 700;
    font-style: italic;
}

.unaligned-paragraph-header .paragraph-toggle:hover {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
}

/* Unaligned words styling */
.unaligned-word {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 3px;
    padding: 1px 3px;
    margin: 0 1px;
    color: #856404;
    font-style: italic;
    transition: all 0.2s ease;
}

.unaligned-word:hover {
    background: #ffeaa7;
    border-color: #e0a800;
    cursor: pointer;
}

.unaligned-word:before {
    content: "🔗";
    font-size: 0.7em;
    margin-left: 2px;
    opacity: 0.7;
}

/* Alignment Page Layout Styles */
.alignment-tool {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    background: var(--bg-white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.alignment-topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
}

.topbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.topbar-group.selector-group {
    flex: 1;
}

.topbar-label {
    font-weight: 600;
    color: var(--text-dark);
}

.topbar-select {
    min-width: 140px;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-light);
}

.stage-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.alignment-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.alignment-sidebar {
    width: 320px;
    background: var(--bg-light);
    padding: 1rem;
    overflow-y: auto;
    border-inline-end: 1px solid var(--border-color);
}

.alignment-header h1 {
    color: var(--primary-color);
    margin: 0 0 0.5rem 0;
    font-size: 1.4rem;
}

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

.alignment-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alignment-summary {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    line-height: 1.4;
    font-size: 0.9rem;
}

.alignment-summary .summary-row + .summary-row {
    margin-top: 0.35rem;
}

.control-label {
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--text-dark);
}

.control-select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-white);
}

.alignment-stage-selector h3 {
    color: var(--text-dark);
    margin: 1.5rem 0 1rem 0;
    font-size: 1rem;
}

.stage-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stage-button {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.stage-button:hover {
    border-color: var(--secondary-color);
    background: #f0f7ff;
}

.stage-button.active {
    border-color: var(--secondary-color);
    background: #e3f2fd;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.1);
}

.stage-number {
    background: var(--secondary-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
}

.stage-title {
    font-weight: 600;
    color: var(--text-dark);
}

.stage-desc {
    font-size: 0.8rem;
    color: var(--text-light);
}

.stage-controls {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-white);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.stage-controls.active {
    display: block;
}

.stage-controls h4 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
    font-size: 1rem;
}

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

.alignment-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alignment-actions.compact {
    flex-direction: row;
    flex-wrap: wrap;
}

.action-button {
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.action-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.action-button:not(:disabled):hover {
    transform: translateY(-1px);
}

.action-button.primary {
    background: var(--secondary-color);
    color: white;
}

.action-button.secondary {
    background: var(--warning-color);
    color: white;
}

.alignment-save {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.notes-field {
    width: 100%;
    min-height: 60px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
    margin-bottom: 1rem;
    font-family: inherit;
}

.alignment-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.alignment-panels {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.panel-header {
    padding: 0.8rem 1rem;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
    margin: 0 0 0.3rem 0;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.panel-header p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-light);
}

.panel-body {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    font-family: 'David', 'Times New Roman', serif;
}

.line-splitting-view {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: none;
    background: var(--bg-white);
}

.line-splitting-view[hidden] {
    display: none !important;
}

.line-splitting-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    padding: 0.4rem;
    margin-bottom: 1px;
    border: none;
    border-top: 1px solid #e0e0e0;
    border-radius: 0;
    background: #fcfcfc;
    box-shadow: none;
    cursor: pointer;
}

.line-splitting-row.active {
    background: #f5faff;
    border-top-color: #1976d2;
    border-bottom: 1px solid #1976d2;
}

.line-splitting-row.pending {
    background: #fff7e6;
    border-top-color: #f57c00;
}

.line-splitting-row .line-column {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2em;
    direction: rtl;
    min-height: 2rem;
}

.line-splitting-row .line-column.manuscript {
    background: #fafafa;
    border-radius: 6px;
    padding: 0.6rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.line-splitting-row .line-column.print {
    background: #fffef7;
    border-radius: 6px;
    padding: 0.6rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.line-splitting-view .no-data {
    padding: 0.5rem;
    text-align: center;
}

.print-context {
    font-size: var(--print-font-size, 13px);
    line-height: 1.4;
}

.manuscript-lines {
    font-size: var(--witness-font-size, 13px);
    line-height: 1.4;
}

/* Print and manuscript text styling for alignment page */
.alignment-tool .print-paragraph {
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.4rem;
}

.alignment-tool .print-paragraph:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.alignment-tool .print-paragraph-header {
    display: none;
}

.alignment-tool .print-paragraph-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2em;
    line-height: 1.4;
    direction: rtl;
}

.alignment-tool .print-word {
    display: inline-block;
    padding: 1px 2px;
    border-radius: 2px;
    transition: all 0.1s ease;
    cursor: default;
    font-size: var(--print-font-size, 13px);
}

.alignment-tool .print-word.on-page {
    background-color: #e3f2fd;
    border: 1px solid #90caf9;
}

.alignment-tool .manuscript-line {
    margin-bottom: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    background: #fafafa;
}

.alignment-tool .manuscript-line-header {
    display: none;
}

.alignment-tool .manuscript-line-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15em;
    line-height: 1.3;
    direction: rtl;
    min-height: 1.5em;
}

.alignment-tool .manuscript-line.active-line {
    border-color: #1976d2;
    box-shadow: 0 0 0 1px rgba(25, 118, 210, 0.2);
}

.alignment-tool .manuscript-line.active-line .manuscript-line-header {
    color: #0d47a1;
}

.alignment-tool .print-word.line-boundary-start,
.alignment-tool .print-word.line-boundary-end {
    border: 2px solid #1976d2;
}

.alignment-tool .print-word.line-boundary-start {
    background-color: rgba(25, 118, 210, 0.12);
}

.alignment-tool .print-word.line-boundary-end {
    background-color: rgba(25, 118, 210, 0.08);
}

.alignment-tool .print-word.line-boundary-active {
    background-color: rgba(25, 118, 210, 0.15);
    border-color: rgba(25, 118, 210, 0.4);
}

.alignment-tool .manuscript-word {
    display: inline-block;
    padding: 1px 2px;
    border-radius: 2px;
    transition: all 0.1s ease;
    font-size: var(--witness-font-size, 13px);
    cursor: default;
}

.alignment-tool .manuscript-word.selected-for-edit {
    background-color: #fff8e1;
    border: 1px solid #ffb74d;
}

.alignment-tool .manuscript-word.manual-linked {
    background-color: #e6f4ea;
    border: 1px solid #2e7d32;
}

.alignment-tool .manuscript-word.manual-link-pending-removal {
    background-color: #ffebee;
    border: 1px dashed #d32f2f;
}

.alignment-tool .manuscript-word.line-move-pending {
    box-shadow: inset 0 -2px 0 0 #673ab7;
}

.alignment-tool .manuscript-word.link-source {
    outline: 2px solid #1976d2;
    outline-offset: 2px;
}

.alignment-tool .manuscript-word.selected {
    background-color: #fff3e0;
    border: 1px solid #ff9800;
}

.alignment-tool .manuscript-word.moved {
    background-color: #f3e5f5;
    border: 1px solid #9c27b0;
}

.alignment-tool .manuscript-word.linked {
    background-color: #e8f5e8;
    border: 1px solid #4caf50;
}

.alignment-tool .print-word.manual-linked {
    background-color: #e6f4ea;
    border: 1px solid #2e7d32;
}

.alignment-tool .print-word.link-target {
    box-shadow: inset 0 -2px 0 0 #1976d2;
}

.alignment-tool .print-word.selected-start,
.alignment-tool .print-word.selected-end {
    border: 1px solid #1976d2;
}

.alignment-tool .change-log {
    margin: 0.75rem 0 0;
    padding: 0.75rem;
    border-radius: 6px;
    background-color: #fafafa;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary-color);
    min-height: 2rem;
}

.alignment-tool .change-log:empty {
    display: none;
}

.alignment-tool .change-log ul {
    margin: 0;
    padding-inline-start: 1.1rem;
}

.alignment-tool .line-bounds-summary {
    margin-top: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    background-color: #f5f9ff;
    border: 1px solid rgba(25, 118, 210, 0.25);
    font-size: 0.85rem;
    color: var(--text-secondary-color);
}

.alignment-tool .line-bounds-summary:empty {
    display: none;
}

.alignment-tool .line-bounds-summary .summary-row {
    margin-bottom: 0.35rem;
}

.alignment-tool .line-bounds-summary .summary-row:last-child {
    margin-bottom: 0;
}

.alignment-tool .line-bounds-summary .summary-row.baseline {
    color: var(--text-light);
    font-size: 0.78rem;
}

.alignment-tool .line-bounds-summary .summary-row.pending {
    color: #ef6c00;
    font-weight: 600;
}

/* Line-by-line alignment view for word stage */
.line-by-line-alignment {
    display: none;
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.line-by-line-alignment[hidden] {
    display: none !important;
}

.line-by-line-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alignment-line-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-white);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.manuscript-line-section {
    background: transparent;
}

.print-words-section {
    background: transparent;
}

.manuscript-words-container,
.print-words-container {
    padding: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3em;
    min-height: 3rem;
    direction: rtl;
}

.alignment-line-row .manuscript-word,
.alignment-line-row .print-word {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: var(--witness-font-size, 13px);
    border: 1px solid transparent;
    background: none;
    appearance: none;
}

.alignment-line-row .manuscript-word:hover,
.alignment-line-row .print-word:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.alignment-line-row .manuscript-word.has-alignment {
    background: #e8f5e8;
    border-color: #4caf50;
    color: #2e7d32;
}

.alignment-line-row .manuscript-word.no-alignment {
    background: #ffebee;
    border-color: #ef5350;
    color: #c62828;
}

.alignment-line-row .manuscript-word.selected {
    background: #2196f3;
    color: white;
    border-color: #1976d2;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.alignment-line-row .print-word {
    background: #fff3e0;
    border-color: #ffb74d;
    color: #ef6c00;
}

.alignment-line-row .print-word.is-linked {
    background: #e1f5fe;
    border-color: #29b6f6;
    color: #0277bd;
}

.alignment-line-row .print-word.target-highlight {
    background: #4caf50;
    color: white;
    border-color: #388e3c;
    animation: target-pulse 0.6s ease;
}

@keyframes target-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(76, 175, 80, 0.1);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

.no-data {
    text-align: center;
    color: var(--text-light);
    padding: 3rem;
    font-style: italic;
}

.status-message {
    margin-top: 0.5rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.status-message[data-status="success"] {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message[data-status="error"] {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-message[data-status="info"] {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.status-message[data-status="warning"] {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Interactive Word Alignment Styles - Only for alignment page */
.alignment-tool .manuscript-word.is-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 3px;
    padding: 1px 3px;
}

.alignment-tool .manuscript-word.is-clickable:hover {
    background-color: #e3f2fd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.alignment-tool .manuscript-word.selected-word {
    background-color: #2196f3 !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.alignment-tool .manuscript-word.draggable-word {
    user-select: none;
}

.alignment-tool .manuscript-word.draggable-word:hover {
    cursor: grab;
}

.alignment-tool .manuscript-word.draggable-word:active {
    cursor: grabbing;
}

.alignment-tool .manuscript-word.drop-target {
    background-color: #fff3e0 !important;
    border: 2px dashed #ff9800;
    animation: pulse-drop-target 1.5s infinite;
}

@keyframes pulse-drop-target {
    0% {
        border-color: #ff9800;
        background-color: #fff3e0;
    }
    50% {
        border-color: #f57c00;
        background-color: #ffecb3;
    }
    100% {
        border-color: #ff9800;
        background-color: #fff3e0;
    }
}

.alignment-tool .parallel-row.edit-mode .manuscript-word {
    margin: 2px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
}

.alignment-tool .parallel-row.edit-mode .print-word {
    background-color: #f5f5f5;
    border-bottom: 2px solid #4caf50;
    font-weight: 500;
}

.alignment-modified-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ff9800;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9em;
    z-index: 1000;
    animation: fade-in 0.3s ease;
}

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

/* Stage-Specific Mode Styles - Only for alignment page */
.alignment-tool .parallel-row.boundaries-mode .print-word {
    cursor: pointer;
    transition: all 0.2s ease;
}

.alignment-tool .parallel-row.boundaries-mode .print-word:hover {
    background-color: #fff3e0;
    border: 1px solid #ff9800;
    border-radius: 3px;
}

.alignment-tool .parallel-row.boundaries-mode .manuscript-word {
    opacity: 0.7;
    pointer-events: none;
}

.alignment-tool .parallel-row.lines-mode .print-word {
    opacity: 0.8;
    background-color: #f9f9f9;
}

.alignment-tool .parallel-row.lines-mode .manuscript-word.is-clickable {
    border: 1px solid #e0e0e0;
    background-color: #fff;
}

.alignment-tool .parallel-row.words-mode .print-word {
    cursor: pointer;
    border-bottom: 2px solid #4caf50;
}

.alignment-tool .parallel-row.words-mode .print-word:hover {
    background-color: #e8f5e8;
}

.alignment-tool .parallel-row.words-mode .manuscript-word.is-clickable {
    border: 1px solid #2196f3;
}

/* Stage completion indicators - Only for alignment page */
.alignment-tool .stage-button.completed::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 4px;
    background: #4caf50;
    color: white;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Word split tooltip for stage 2 */
.word-split-tooltip {
    position: absolute;
    background: white;
    border: 2px solid var(--secondary-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 0.4rem;
    z-index: 1500;
    display: none;
}

.word-split-tooltip.visible {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.word-split-tooltip button {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.2s;
}

.word-split-tooltip button:hover {
    background: var(--primary-color);
}

.word-split-tooltip button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Highlight word when tooltip is open (selected word) */
.line-splitting-row .print-word.split-target {
    background: #fff3e0 !important;
    border: 2px solid var(--warning-color) !important;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.4);
    position: relative;
}

/* Make print words more obviously clickable in stage 2 */
.alignment-tool[data-stage="lines"] .line-splitting-row .print-word {
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.alignment-tool[data-stage="lines"] .line-splitting-row .print-word:hover:not(.split-target) {
    background: #f5f5f5 !important;
    transform: translateY(-1px);
}
