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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.4;
    color: #333;
    background: #f5f5f5;
    font-size: 14px;
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 15px;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

header {
    background: #fff;
    padding: 12px 15px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    position: relative;
    flex-shrink: 0;
}

h1 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 20px;
    padding-right: 250px;
}

h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ecf0f1;
    font-size: 16px;
    flex-shrink: 0;
}

h3 {
    color: #34495e;
    font-size: 13px;
    margin-bottom: 6px;
}

.header-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
    align-items: center;
}

/* Filter dropdown anchored to the Filters button */
.filter-controls {
    position: relative;
}

.filter-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 340px;
    max-width: 420px;
    background: #fff;
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    padding: 12px;
    display: none;
    z-index: 1200;
}

.filter-controls.open .filter-panel {
    display: block;
}

.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.filter-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #334155;
}

.filter-close-btn {
    border: 0;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    padding: 3px;
    border-radius: 4px;
}

.filter-close-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.filter-section {
    margin-bottom: 10px;
}

.filter-label {
    display: block;
    font-weight: 600;
    font-size: 12px;
    color: #475569;
    margin-bottom: 6px;
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    color: #334155;
    cursor: pointer;
}

.filter-checkbox-label input {
    margin: 0;
}

.filter-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.filter-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.filter-toggle-slider {
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: #cbd5e1;
    position: relative;
    transition: background 0.2s ease;
}

.filter-toggle-slider::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.filter-toggle input:checked + .filter-toggle-slider {
    background: #3182ce;
}

.filter-toggle input:checked + .filter-toggle-slider::after {
    transform: translateX(16px);
}

.filter-panel-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 760px) {
    .filter-panel {
        left: 0;
        right: auto;
        width: min(92vw, 420px);
        min-width: 0;
    }
}

.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 6px 30px 6px 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: #3498db;
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    display: none;
    user-select: none;
}

.search-clear:hover {
    color: #555;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 8px;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #eee;
}

.pagination-info {
    color: #7f8c8d;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    min-width: 60px;
    text-align: center;
}

@media (max-width: 600px) {
    .pagination {
        border: none;
        background: transparent;
        padding: 0;
    }
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

/* Icon container used throughout the UI (feather icons) */
.btn .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    transform: translateY(2px);
}

.btn .btn-icon svg {
    width: 100%;
    height: 100%;
    color: inherit; /* feather uses stroke=currentColor */
}

.btn .btn-icon svg [stroke] {
    stroke: currentColor;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #d35400;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

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

.btn-info:hover {
    background: #138496;
}

/* Button Group for Data Management */
.btn-group {
    display: inline-flex;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(23, 162, 184, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(23, 162, 184, 0.2);
}

.data-management-group {
    margin-left: 8px;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

@media (min-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }
}

.panel {
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.panel > h2 {
    flex-shrink: 0;
}

.panel-header {
    flex-shrink: 0;
}

#entry-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.entry-section {
    margin-bottom: 12px;
}

.concept-card {
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    background: #f7fafc;
}

.concept-card-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.concept-card-header .concept-label {
    font-size: 14px;
    font-weight: 700;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    line-height: 1;
    padding-top: 0.15em;
}

.concept-card-header .entry-headword {
    font-size: 22px;
    font-weight: 800;
    color: #1f3a2e;
    margin-bottom: 0;
    cursor: pointer;
    line-height: 1;
}

.concept-card-header .entry-status-controls {
    margin-left: auto;
}

.concept-three-columns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0;
}

.concept-three-columns > .entry-section {
    margin-bottom: 0;
    padding: 0 12px;
    border-right: 1px solid #e2e8f0;
}

.concept-three-columns > .entry-section:first-child {
    padding-left: 0;
}

.concept-three-columns > .entry-section:last-child {
    border-right: none;
    padding-right: 0;
}

@media (max-width: 900px) {
    .concept-three-columns {
        grid-template-columns: 1fr;
    }
    .concept-three-columns > .entry-section {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding: 8px 0;
    }
    .concept-three-columns > .entry-section:last-child {
        border-bottom: none;
    }
}

/* Uncertain match indicator */
.aat-uncertain-indicator {
    font-weight: bold;
    color: #e53e3e;
    font-size: 14px;
    line-height: 1;
    margin-right: 1px;
}

.aat-type-tag.aat-type-uncertain {
    border-style: double;
    border-width: 3px;
    position: relative;
}

/* Suggested (unconfirmed) AAT concept — awaiting review */
.aat-type-tag.aat-type-suggested {
    border-style: dashed;
    border-color: #d69e2e;
    background: #fffbeb;
    color: #92400e;
}
.aat-suggested-indicator {
    font-size: 12px;
    line-height: 1;
    margin-right: 2px;
}
.aat-type-accept-btn {
    cursor: pointer;
    font-weight: bold;
    color: #2f855a;
    margin-left: 4px;
    padding: 0 3px;
    border-radius: 3px;
}
.aat-type-accept-btn:hover {
    background: #c6f6d5;
}

/* Close Match button in concept picker */
.aat-picker-close-btn {
    background: #d6bcfa !important;
    color: #1a202c !important;
    border-color: #805ad5 !important;
}

.aat-picker-close-btn:hover:not(:disabled) {
    background: #b794f4 !important;
}

.aat-picker-close-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Broader Match button in AAT picker */
.aat-picker-broader-btn {
    background: #f6ad55 !important;
    color: #1a202c !important;
    border-color: #dd6b20 !important;
}

.aat-picker-broader-btn:hover:not(:disabled) {
    background: #ed8936 !important;
}

.aat-picker-broader-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Uncertain toggle switch in AAT picker */
.aat-picker-uncertain-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    margin-right: auto;
    user-select: none;
}

.aat-picker-uncertain-checkbox {
    display: none;
}

.aat-picker-uncertain-slider {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    background: #cbd5e0;
    border-radius: 10px;
    transition: background 0.2s;
}

.aat-picker-uncertain-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.aat-picker-uncertain-checkbox:checked + .aat-picker-uncertain-slider {
    background: #e53e3e;
}

.aat-picker-uncertain-checkbox:checked + .aat-picker-uncertain-slider::after {
    transform: translateX(16px);
}

.aat-picker-uncertain-label {
    font-size: 0.82rem;
    color: #718096;
    transition: color 0.2s;
}

.aat-picker-uncertain-checkbox:checked ~ .aat-picker-uncertain-label {
    color: #e53e3e;
    font-weight: 600;
}

/* Wikidata type tag */
.aat-type-tag.aat-type-wikidata {
    background: #bee3f8;
    border-color: #3182ce;
    color: #1a365d;
}

.aat-type-tag.aat-type-wikidata .remove {
    color: #2a4365;
}

.aat-type-tag.aat-type-wikidata .aat-type-id {
    color: #2b6cb0;
}

.aat-type-tag.aat-type-wikidata .aat-type-id:hover {
    text-decoration: underline;
}

.aat-wd-indicator {
    font-weight: 700;
    color: #2b6cb0;
    font-size: 12px;
    line-height: 1;
    background: #ebf8ff;
    border: 1px solid #90cdf4;
    border-radius: 3px;
    padding: 1px 4px;
}

/* Source toggle tabs in concept picker */
.aat-picker-source-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 10px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    overflow: hidden;
    width: fit-content;
    min-height: 25px;
}

.aat-source-btn {
    padding: 5px 16px;
    border: none;
    background: #f7fafc;
    color: #4a5568;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.aat-source-btn:not(:last-child) {
    border-right: 1px solid #cbd5e0;
}

.aat-source-btn.active {
    background: #4299e1;
    color: #fff;
}

.aat-source-btn:hover:not(.active) {
    background: #edf2f7;
}

/* AAT Mapping Tags (Category Editor) */
.aat-mapping-tag {
    background: #ecc94b;
    color: #1a202c;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #b7791f;
}

.aat-mapping-tag .aat-mapping-id {
    font-size: 11px;
    opacity: 0.55;
    font-family: monospace;
}

.aat-mapping-tag .remove {
    cursor: pointer;
    font-weight: bold;
    margin-left: 2px;
    color: #744210;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.aat-mapping-tag .remove:hover {
    opacity: 1;
}

.category-tag.derived {
    cursor: default;
}

.derived-categories-note {
    font-size: 11px;
    color: #2980b9;
    font-weight: normal;
    font-style: italic;
}

/* AAT Tree Picker Modal */
.aat-picker-content {
    max-width: 920px;
    width: min(96vw, 920px);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Action row in Concept Picker: allow wrapping so controls never clip */
#aat-picker-modal .aat-picker-content > div:last-child {
    flex-wrap: wrap;
    row-gap: 8px;
}

#aat-picker-modal .aat-picker-uncertain-toggle {
    flex-shrink: 0;
}

.aat-picker-content h3 {
    margin-bottom: 12px;
    flex-shrink: 0;
}

.aat-picker-context {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid #d69e2e;
    font-size: 13px;
    color: #4a5568;
    margin-bottom: 10px;
    flex-shrink: 0;
    line-height: 1.5;
}

.aat-picker-context strong {
    color: #2d3748;
}

.aat-picker-status {
    background: #ebf8ff;
    color: #2b6cb0;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.aat-picker-search-box {
    position: relative;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.aat-picker-search {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: 2px solid #cbd5e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.aat-picker-search:focus {
    outline: none;
    border-color: #d69e2e;
    box-shadow: 0 0 0 3px rgba(214, 158, 46, 0.15);
}

.aat-picker-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    user-select: none;
}

.aat-picker-search-clear:hover {
    color: #555;
}

.aat-search-results {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 10px;
    flex-shrink: 1;
}

.aat-search-results:not(:empty) {
    min-height: 300px;
}

.aat-search-results:empty {
    display: none;
}

.aat-search-result {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s ease;
}

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

.aat-search-result:hover {
    background: #f7fafc;
}

.aat-search-result.selected {
    background: #fefcbf;
    border-left: 3px solid #d69e2e;
}

.aat-search-result-label {
    font-weight: 600;
    font-size: 13px;
    color: #2d3748;
}

.aat-search-result-path {
    font-size: 11px;
    color: #718096;
    margin-top: 2px;
}

.aat-search-empty {
    padding: 16px;
    text-align: center;
    color: #a0aec0;
    font-size: 13px;
    font-style: italic;
}

.aat-tree {
    flex: 1;
    min-height: 220px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px;
    background: #fafbfc;
    margin-bottom: 10px;
}

.aat-tree-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0 18px;
}

.aat-tree > .aat-tree-list {
    padding-left: 0;
}

.aat-tree-node {
    margin: 0;
    padding: 0;
}

.aat-tree-row {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 1px 4px;
    border-radius: 3px;
    transition: background 0.15s ease;
    cursor: default;
    line-height: 1.3;
}

.aat-tree-row:hover {
    background: #edf2f7;
}

.aat-tree-row.selected {
    background: #fefcbf;
}

.aat-tree-row.highlighted {
    background: #fefcbf;
    outline: 2px solid #d69e2e;
    outline-offset: -1px;
}

.aat-tree-row.selected.highlighted {
    background: #fefcbf;
    outline: 2px solid #d69e2e;
}

.aat-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 11px;
    color: #718096;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

.aat-tree-toggle:hover {
    color: #2d3748;
}

.aat-tree-checkbox {
    cursor: pointer;
    width: 14px;
    height: 14px;
    margin: 0;
    flex-shrink: 0;
    accent-color: #d69e2e;
}

.aat-tree-label {
    font-size: 12px;
    color: #2d3748;
    cursor: pointer;
    user-select: none;
    padding: 0 3px;
    border-radius: 3px;
    transition: color 0.15s ease;
}

.aat-tree-label:hover {
    color: #b7791f;
}

.aat-tree-row.selected .aat-tree-label {
    color: #744210;
    font-weight: 600;
}

.aat-selected-display {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 12px;
    min-height: 40px;
    flex-shrink: 0;
}

.aat-selected-none {
    color: #a0aec0;
    font-size: 13px;
}

.aat-selected-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 13px;
}

.aat-selected-item strong {
    color: #2d3748;
}

.aat-selected-id {
    font-size: 11px;
    color: #b7791f;
    font-family: monospace;
}

.aat-selected-path {
    font-size: 11px;
    color: #718096;
    margin-top: 2px;
}

.aat-selected-remove {
    cursor: pointer;
    color: #e53e3e;
    font-weight: bold;
    font-size: 16px;
    line-height: 1;
    margin-left: 4px;
    transition: color 0.15s ease;
}

.aat-selected-remove:hover {
    color: #c53030;
}

/* Custom Scope Note Tooltip */
.aat-scope-tooltip {
    display: none;
    position: fixed;
    z-index: 2000;
    max-width: 380px;
    padding: 8px 12px;
    background: #1a202c;
    color: #e2e8f0;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* AAT Note Panel (inline in picker) */
.aat-note-panel {
    background: #fffbeb;
    border: 1px solid #d69e2e;
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 8px;
    flex-shrink: 0;
}

.aat-note-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #744210;
    margin-bottom: 6px;
}

.aat-note-textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #d69e2e;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    min-height: 50px;
}

.aat-note-textarea:focus {
    outline: none;
    border-color: #b7791f;
    box-shadow: 0 0 0 3px rgba(214, 158, 46, 0.15);
}

.aat-note-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* Materials tags */
.materials-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.material-tag {
    background: #fdf2e9;
    color: #5b3a1a;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e0b88a;
}

.material-tag:hover {
    background: #f5dcc3;
    border-color: #c9935a;
}

.material-tag .material-id {
    font-size: 11px;
    opacity: 0.55;
    font-family: monospace;
}

.material-tag .remove {
    cursor: pointer;
    font-weight: bold;
    margin-left: 2px;
    color: #8B5E3C;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.material-tag .remove:hover {
    opacity: 1;
    color: #e53e3e;
}

/* Linked-entry badges (Related Concepts / Compound Of) */
.linked-entry-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.linked-entry-tag {
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.linked-entry-tag.related {
    background: #f3e8fd;
    color: #553c7b;
    border-color: #c8a8e9;
}

.linked-entry-tag.related:hover {
    background: #e9d5fb;
    border-color: #a87fd0;
}

.linked-entry-tag.compound {
    background: #e6f6f4;
    color: #1f5e57;
    border-color: #9bd4cc;
}

.linked-entry-tag.compound:hover {
    background: #d2efea;
    border-color: #6cbdb1;
}

.linked-entry-tag .remove {
    cursor: pointer;
    font-weight: bold;
    margin-left: 2px;
    opacity: 0.6;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.linked-entry-tag .remove:hover {
    opacity: 1;
    color: #e53e3e;
}

.concept-card .entry-section:last-child {
    margin-bottom: 0;
}

.concept-col-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 15px;
    font-weight: 700;
    color: #2d3748;
}

.concept-col-title .col-icon {
    width: 16px;
    height: 16px;
    color: #718096;
}

/* Right panel tabs */
.right-panel-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.right-panel-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: #718096;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.right-panel-tab:hover {
    color: #4a5568;
}

.right-panel-tab.active {
    color: #2b6cb0;
    border-bottom-color: #2b6cb0;
}

.right-panel-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.merge-suggestions-header {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.entry-headword {
    font-size: 32px;
    font-weight: 800;
    color: #1f3a2e;
    text-shadow: 0 1px 0 rgba(255, 255, 0.04);
    margin-bottom: 10px;
    cursor: pointer;
}

.forms-list, .categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.categories-list .aat-type-tag {
    background: #fff7df;
    border: 1px solid #edd9a3;
    color: #5f4b10;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.3;
}

.categories-list .aat-type-tag .aat-type-id {
    color: #7c6216;
    font-size: 11px;
    text-decoration: none;
}

.categories-list .aat-type-tag .aat-type-id:hover {
    text-decoration: underline;
}

.categories-list .aat-type-tag.aat-type-wikidata {
    background: #eef6ff;
    border-color: #b9d6ff;
    color: #1f4f8a;
}

.categories-list .aat-type-tag.aat-type-close {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.categories-list .aat-type-tag.aat-type-broader {
    background: #f5f3ff;
    border-color: #d8ccff;
    border-style: dashed;
    color: #553c9a;
}

.categories-list .aat-type-tag.aat-type-uncertain {
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.3);
}

.categories-list .aat-wd-indicator,
.categories-list .aat-close-indicator,
.categories-list .aat-broader-indicator,
.categories-list .aat-uncertain-indicator {
    font-weight: 700;
    font-size: 10px;
}

.categories-list .aat-wd-indicator {
    color: #1d4ed8;
}

.categories-list .aat-close-indicator {
    color: #c2410c;
}

.categories-list .aat-broader-indicator {
    color: #6d28d9;
}

.categories-list .aat-uncertain-indicator {
    color: #b91c1c;
}

.categories-list .aat-type-note-btn {
    color: #6b7280;
    cursor: pointer;
    font-size: 12px;
}

.categories-list .aat-type-note-btn:hover {
    color: #374151;
}

.categories-list .aat-type-tag .remove {
    cursor: pointer;
    font-weight: 700;
    color: #b91c1c;
    margin-left: 2px;
}

.categories-list .aat-type-tag .remove:hover {
    color: #7f1d1d;
}

.form-tag {
    background: #ecf0f1;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: alias;
}

.form-tag.selected {
    background: #3498db;
    color: white;
    cursor: default;
}

.form-tag .remove {
    cursor: pointer;
    font-weight: bold;
    color: #e74c3c;
}

.form-tag.selected .remove {
    color: white;
}

.category-tag {
    background: #3498db;
    color: white;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.category-clickable {
    cursor: pointer;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.6);
}

.category-clickable:hover {
    border-bottom: 1px solid white;
}

.category-tag .remove {
    cursor: pointer;
    font-weight: bold;
}

.description-text {
    background: #f8f9fa;
    padding: 8px;
    border-radius: 3px;
    border-left: 3px solid #3498db;
    margin-bottom: 8px;
    font-size: 13px;
}

.memo-text {
    background: #fef9f3;
    padding: 8px;
    border-radius: 3px;
    border-left: 3px solid #e67e22;
    margin-bottom: 8px;
    font-size: 13px;
    cursor: pointer;
}

.memo-text:hover {
    background: #fef5eb;
}

textarea {
    width: 100%;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 3px;
    font-family: inherit;
    font-size: 13px;
}

textarea:focus {
    outline: none;
    border-color: #3498db;
}

input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    border: 2px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
}

input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
}

input[type="password"] {
    padding: 6px 8px;
    border: 2px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
}

#qualifiers-list {
    padding-right: 4px;
}

.qualifier-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    border-left: 3px solid #9b59b6;
    font-size: 13px;
    transition: background 0.15s, border-color 0.15s;
}

.qualifier-item.qualifier-merge-selected {
    background: #ebf5fb;
    border-left-color: #2980b9;
    box-shadow: 0 0 0 1px #2980b9;
}

.qualifier-merge-btn {
    background: #e2e8f0;
    color: #4a5568;
    border: none;
    transition: background 0.15s, color 0.15s;
}

.qualifier-item .qualifier-variants {
    margin-bottom: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.qualifier-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.qualifier-badge.canonical {
    background: #9b59b6;
    color: white;
    border: 2px solid #9b59b6;
}

.qualifier-badge.variant {
    background: #f0e6f6;
    color: #7d3c98;
    border: 1px solid #c39bd3;
    cursor: pointer;
    transition: all 0.2s;
}

.qualifier-badge.variant:hover {
    background: #e8daef;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.qualifier-type-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    vertical-align: middle;
    margin-right: 4px;
}

.qualifier-aat-tag {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 2px;
    font-size: 10px;
    color: #2980b9;
    background: #eaf2f8;
    margin-left: 6px;
    vertical-align: middle;
}

.qualifier-item .qualifier-desc {
    font-size: 12px;
    color: #555;
    margin-bottom: 6px;
    line-height: 1.4;
}

.qualifier-item .qualifier-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.qualifier-item .btn-sm {
    font-size: 11px;
    padding: 4px 8px;
}

/* Merge Qualifiers Preview */
.qualifier-merge-preview {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f0e6f6;
    border: 1px solid #c39bd3;
    border-radius: 6px;
    font-size: 13px;
}

.qualifier-merge-preview-term {
    margin-bottom: 4px;
    word-break: break-word;
}

.qualifier-merge-preview-desc {
    color: #555;
    font-size: 12px;
    word-break: break-word;
}

/* Promote Qualifier Preview */
.promote-preview {
    padding: 10px 14px;
    background: #f0faf4;
    border: 2px dashed #27ae60;
    border-radius: 6px;
    font-size: 16px;
    font-family: 'Georgia', serif;
    min-height: 24px;
    word-break: break-word;
}

/* Word Order Selector */
.word-order-selector {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.word-order-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid #cbd5e0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    background: #fff;
}

.word-order-option:hover {
    background: #f7fafc;
    border-color: #9b59b6;
}

.word-order-option input[type="radio"] {
    margin: 0;
}

.word-order-option input[type="radio"]:checked + span {
    color: #8e44ad;
    font-weight: 600;
}

.word-order-option:has(input[type="radio"]:checked) {
    border-color: #9b59b6;
    background: #f5ebff;
}

#merge-suggestions {
    max-height: none;
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    min-height: 0;
    background: #f6f8fa; /* subtle contrast */
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e6edf3;
}

.merge-candidate {
    background: #fff9e6;
    border: 2px solid #f39c12;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
}

.merge-candidate h4 {
    color: #f39c12;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.similarity-score {
    background: #f39c12;
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
}

.merge-reason {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    font-style: italic;
}

.merge-preview {
    background: white;
    padding: 8px;
    border-radius: 3px;
    margin-bottom: 8px;
    font-size: 12px;
}

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

.edit-mode {
    background: #e8f5e9;
    border: 2px solid #4caf50;
}

.edit-controls {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.add-btn {
    background: #4caf50;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 8px;
    /* ensure icons and glyphs inside the button are vertically centered */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

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

/* Make the split icon solid white on green add-btn */
.add-btn .split-icon svg {
    fill: white;
    stroke: none;
    width: 1em;
    height: 1em;
}

.loading {
    text-align: center;
    padding: 30px;
    color: #7f8c8d;
    font-size: 13px;
}

.error {
    background: #ffe6e6;
    border: 2px solid #e74c3c;
    color: #c0392b;
    padding: 15px 25px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    min-width: 300px;
    text-align: center;
    animation: slideUp 0.3s ease-out;
}

.success {
    background: #e8f5e9;
    border: 2px solid #4caf50;
    color: #2e7d32;
    padding: 15px 25px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    min-width: 300px;
    text-align: center;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.stats {
    display: flex;
    gap: 15px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.stat-item {
    background: #ecf0f1;
    padding: 6px 10px;
    border-radius: 3px;
    font-size: 12px;
}

.stat-item strong {
    color: #2c3e50;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Confirm Modal specific styling */
#confirm-modal .modal-content {
    max-width: 480px;
}

#confirm-modal h3 {
    margin: 0 0 16px 0;
    color: #1a202c;
    font-size: 20px;
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 12px;
}

#confirm-modal p {
    margin: 0 0 24px 0;
    color: #4a5568;
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-wrap;
}

#confirm-modal .modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

#confirm-modal .btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#confirm-modal .btn-primary {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.3);
}

#confirm-modal .btn-primary:hover {
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.4);
    transform: translateY(-1px);
}

#confirm-modal .btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#confirm-modal .btn-secondary:hover {
    background: #cbd5e0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

/* Rationale radio button options styling */
#confirm-rationale-options {
    margin-bottom: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: #f7fafc;
}

#confirm-rationale-options label {
    display: block;
    margin-bottom: 2px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

#confirm-rationale-options label:hover {
    background-color: #edf2f7;
}

#confirm-rationale-options input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 16px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: bold;
    color: #555;
    font-size: 13px;
}

.autocomplete {
    position: relative;
}

.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #ddd;
    border-top: none;
    border-radius: 0 0 3px 3px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.autocomplete-suggestions.active {
    display: block;
}

.autocomplete-item {
    padding: 8px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

.autocomplete-item:hover {
    background: #f5f5f5;
}

/* Merge With / Entry Picker result list */
.merge-target-list {
    max-height: 52vh;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
}

.merge-target-item {
    border-bottom: 1px solid #edf2f7;
}

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

.merge-target-info {
    padding: 10px 12px;
    cursor: pointer;
}

.merge-target-info:hover {
    background: #f8fafc;
}

.merge-target-info .headword {
    font-size: 14px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 4px;
}

.merge-target-info .headword a {
    color: #2b6cb0;
    text-decoration: none;
}

.merge-target-info .headword a:hover {
    text-decoration: underline;
}

.merge-target-info .forms {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    color: #718096;
    font-size: 12px;
}

.forms-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    background: #edf2f7;
    color: #4a5568;
    font-size: 11px;
    line-height: 1.2;
}

.inline-edit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.inline-edit input {
    width: auto;
    min-width: 200px;
}


.category-manager-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 5px;
    min-height: 200px;
}

.category-manager-item {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-manager-item:hover {
    background: #f8f9fa;
}

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

.edit-section {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.edit-section:last-child {
    border-bottom: none;
}

.edit-section h4 {
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
}

.help-text {
    font-size: 12px;
    color: #777;
    margin-bottom: 8px;
}

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

.inline-actions input {
    flex: 1;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

#category-help-link {
    font-size: 12px;
    color: #3498db;
    font-weight: normal;
    cursor: pointer;
    margin-left: 8px;
    text-decoration: underline;
}

@media (max-width: 768px) {
    #auth-section.authenticated {
        position: static;
        margin-bottom: 12px;
        width: 100%;
        text-align: right;
    }

    #auth-authenticated {
        display: inline-flex;
    }

    h1 {
        padding-right: 0;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.btn .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    transform: translateY(2px);
}

.btn .btn-icon svg {
    width: 100%;
    height: 100%;
    color: inherit; /* feather uses stroke=currentColor */
}

.btn .btn-icon svg [stroke] {
    stroke: currentColor;
}

.pagination .btn {
    padding: 0.2rem 0.5rem;
}

/* Make icons inside the smaller .add-btn behave like other toolbar buttons */
.add-btn .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.add-btn .btn-icon svg {
    width: 1em;
    height: 1em;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Style top-level panel headers to distinguish them */
.panel > h2 {
    background: linear-gradient(90deg, rgba(52, 152, 219, 0.08), rgba(155, 89, 182, 0.04));
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    color: #2c3e50;
    font-size: 15px;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

/* Ensure entry title remains readable inside panels */
.entry-section h3 {
    font-size: 14px;
    color: #2c3e50;
    margin-bottom: 8px;
}

/* Compact merge suggestion card styles */
.merge-candidate.compact {
    background: #ffffff;
    border: 1px solid #e0e6ea;
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
}

/* Multi-merge selected state */
.merge-candidate.compact.multi-merge-selected {
    background: #fff8e1;
    border: 2px solid #f39c12;
    box-shadow: 0 2px 4px rgba(243, 156, 18, 0.2);
}

.merge-candidate.compact .mc-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.merge-candidate.compact .mc-head {
    font-weight: 700;
    color: #1f3a2e;
    font-size: 13px;
}

.merge-candidate.compact .mc-score {
    background: #f39c12;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.merge-candidate.compact .mc-meta {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: #666;
    flex-wrap: wrap;
}

/* Ensure the forms container wraps badges and provides spacing for many forms */
.merge-candidate.compact .mc-forms {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.merge-candidate.compact .mc-desc {
    font-size: 12px;
    color: #444;
    max-height: 3.6em; /* approx 3 lines */
    overflow: hidden;
}

/* When description is absent, display an em-dash placeholder */
.merge-candidate.compact .mc-desc.empty strong::after {
    /* Place an em-dash after the 'Description:' label when there is no description text */
    content: '\00a0\2014'; /* non-breaking space + em-dash */
    color: #999;
    font-weight: 600;
    margin-left: 4px;
}

.merge-candidate.compact .mc-sources {
    color: #2c3e50;
    font-size: 12px;
    font-weight: 600;
}

.merge-actions.compact-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.merge-candidate.compact .btn {
    padding: 4px 8px;
    font-size: 12px;
}

/* Form badges in merge cards */
.mc-form-badge {
    display: inline-block;
    background: #ecf0f1;
    color: #2c3e50;
    padding: 3px 6px;
    border-radius: 12px;
    font-size: 11px;
    margin-right: 6px;
}

/* Muted sources inline next to the head */
.mc-sources-muted {
    color: #8a96a3;
    font-weight: 500;
    margin-left: 8px;
    font-size: 12px;
}

/* Larger action buttons on suggestion cards */
.btn-merge, .btn-view {
    padding: 6px 10px;
    font-size: 13px;
}

h1#page-header {
    margin-bottom: 14px;
}

.h1-favicon {
    top: 6px;
    position: relative;
}

.h1-doc-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #3498db;
    text-decoration: none;
    transition: color 0.2s ease, transform 0.2s ease;
    position: relative;
    top: -2px;
}

.h1-doc-link:hover {
    color: #2980b9;
    transform: scale(1.1);
}

.h1-doc-link .btn-icon {
    width: 22px;
    height: 22px;
}

.h1-doc-link .btn-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
}

/* Public Glossary link in header */
.h1-public-glossary-link {
    position: absolute;
    top: 12px;
    right: 15px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #4299e1;
    color: white;
    text-decoration: none;
    border: none; /* Remove any default border */
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    box-sizing: border-box; /* Ensure consistent box model */
    transition: background 0.2s ease, transform 0.2s ease;
}

.h1-public-glossary-link:hover {
    background: #3182ce;
    transform: translateY(-1px);
    text-decoration: none;
}

.h1-public-glossary-link .btn-icon {
    width: 16px;
    height: 16px;
}

.h1-public-glossary-link .btn-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
}

/* Download Unknown Meanings button in header */
.h1-download-unknown-link {
    position: absolute;
    top: 12px;
    right: 165px; /* Position to the left of Public Glossary button - reduced gap */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #ed8936;
    color: white;
    text-decoration: none;
    border: none; /* Remove button default border */
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.5;
    box-sizing: border-box; /* Ensure consistent box model */
    font-family: inherit; /* Match font family */
    transition: background 0.2s ease, transform 0.2s ease;
}

.h1-download-unknown-link:hover {
    background: #dd6b20;
    transform: translateY(-1px);
}

.h1-download-unknown-link .btn-icon {
    width: 16px;
    height: 16px;
}

.h1-download-unknown-link .btn-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
}

.entry-reviewed {
    opacity: 0.6;
    pointer-events: none; /* disable interactions inside entry pane */
    filter: grayscale(0.02);
}

.entry-help-wanted {
    background-color: rgba(255, 192, 203, 0.15); /* subtle pink wash */
}

/* Dictionary Lookup Modal */
#dictionary-lookup-modal .modal-content {
    max-width: 550px;
}

#dictionary-lookup-modal h3 {
    font-size: 22px;
    color: #1a202c;
    margin-bottom: 12px;
}

#dictionary-lookup-modal p {
    color: #4a5568;
    font-size: 15px;
}

/* QA Identifiers Manager */
.qa-identifiers-modal-content {
    max-width: 980px;
    width: 96%;
}

.qa-identifiers-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 12px;
    color: #4a5568;
}

.qa-identifiers-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 12px;
    min-height: 420px;
}

.qa-identifiers-list {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    overflow-y: auto;
    max-height: 58vh;
}

.qa-identifiers-item {
    padding: 8px 10px;
    border-bottom: 1px solid #edf2f7;
    cursor: pointer;
}

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

.qa-identifiers-item:hover {
    background: #edf2f7;
}

.qa-identifiers-item.active {
    background: #ebf8ff;
    border-left: 3px solid #3182ce;
    padding-left: 7px;
}

.qa-identifiers-item-key {
    font-family: monospace;
    font-size: 12px;
    color: #2d3748;
}

.qa-identifiers-item-meta {
    font-size: 11px;
    color: #718096;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qa-identifiers-editor {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    padding: 12px;
    overflow-y: auto;
    max-height: 58vh;
}

.qa-id-field-row {
    display: grid;
    grid-template-columns: 180px 1fr auto;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.qa-id-field-row input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 12px;
}

.qa-id-field-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.qa-id-empty {
    color: #718096;
    font-style: italic;
    padding: 10px 0;
}

/* Qualifier annotation modal token chips */
#qualifier-annotate-modal .qa-token-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 34px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
}

#qualifier-annotate-modal .qa-token {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #1f2937;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

#qualifier-annotate-modal .qa-token:hover {
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

#qualifier-annotate-modal .qa-token.selected {
    border-color: #3182ce;
    box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.22);
}

#qualifier-annotate-modal .qa-token.annotated {
    border-color: rgba(15, 23, 42, 0.15);
    color: #fff;
    padding-right: 8px;
}

#qualifier-annotate-modal .qa-token.annotated.auto {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.28);
}

#qualifier-annotate-modal .qa-token.annotated.curated {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

#qualifier-annotate-modal .qa-token-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    padding: 0 5px;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.5);
    font-size: 11px;
    line-height: 1;
}

#qualifier-annotate-modal .qa-token-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.22);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

#qualifier-annotate-modal .qa-token-remove:hover {
    background: rgba(0, 0, 0, 0.34);
}

#qualifier-annotate-modal .qa-type-picker {
    display: none;
    margin-top: 10px;
    padding: 8px;
    border: 1px solid #dbeafe;
    border-radius: 6px;
    background: #eff6ff;
}

#qualifier-annotate-modal .qa-type-picker.show {
    display: block;
}

#qualifier-annotate-modal .qa-type-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

#qualifier-annotate-modal .qa-type-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    background: #fff;
    color: #1e3a8a;
    font-size: 12px;
    cursor: pointer;
}

#qualifier-annotate-modal .qa-type-btn:hover {
    background: #dbeafe;
}

#qualifier-annotate-modal #qa-suggestions {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    max-height: 180px;
    overflow-y: auto;
    padding: 6px;
}

#qualifier-annotate-modal .qa-suggestion-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

#qualifier-annotate-modal .qa-suggestion-item:hover {
    background: #f8fafc;
}

#qualifier-annotate-modal .qa-suggestion-item .sug-type {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    color: #fff;
    font-size: 11px;
    flex-shrink: 0;
}

#qualifier-annotate-modal .qa-suggestion-item .sug-sim {
    margin-left: 4px;
    color: #64748b;
    font-size: 11px;
}

.qa-id-pick-item:hover {
    background: #f8fafc;
}

@media (max-width: 900px) {
    .qa-identifiers-layout {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .qa-identifiers-list,
    .qa-identifiers-editor {
        max-height: 40vh;
    }

    #qualifier-annotate-modal .qa-type-grid {
        grid-template-columns: 1fr;
    }

    #aat-picker-modal .aat-picker-content > div:last-child {
        justify-content: flex-start !important;
    }

    #aat-picker-modal .aat-picker-uncertain-toggle {
        width: 100%;
        margin-right: 0;
    }
}

