/* SNOMED NER Demo Styles */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --warning: #ca8a04;
    --error: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
    --gray-800: #1f2937;
    --medcat-color: #3b82f6;
    --medcat-bg: rgba(59, 130, 246, 0.15);
    --obs-color: #10b981;
    --obs-bg: rgba(16, 185, 129, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
}

.container {
    margin-left: 280px;
    margin-right: 280px;
    padding: 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 1.5rem;
}

header h1 {
    font-size: 1.75rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

header h1 .version {
    font-size: 1.1rem;
    font-weight: normal;
    color: var(--gray-600);
}

header .subtitle {
    color: var(--gray-600);
    font-size: 0.95rem;
    text-align: center;
}

header .demo-desc {
    color: var(--gray-500);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

header .demo-note {
    color: var(--gray-400);
    font-size: 0.8rem;
    font-style: italic;
    margin-top: 0.25rem;
}

header .debug-links {
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

header .debug-links a {
    color: var(--primary);
    text-decoration: none;
}

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

header .about-link {
    display: inline-block;
    color: var(--primary);
    font-size: 0.85rem;
    text-decoration: none;
    margin-top: 0.5rem;
}

header .about-link:hover {
    text-decoration: underline;
}

header {
    text-align: center;
}

/* Left panel */
.left-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.left-panel .features {
    padding: 1rem 1.25rem;
    text-align: left;
    flex: 1;
    overflow-y: auto;
}

.feature {
    font-size: 0.85rem;
    color: var(--gray-600);
    line-height: 1.5;
    margin-bottom: 0.75rem;
    list-style-type: disc;
    display: list-item;
    margin-left: 1rem;
}

.feature strong {
    color: var(--gray-800);
    font-size: 0.9rem;
}

.system-specs {
    padding: 0.75rem 1.25rem;
    flex: 1;
}

.spec-row {
    margin-bottom: 0.6rem;
}

.spec-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 0.1rem;
}

.spec-value {
    display: block;
    font-size: 0.8rem;
    color: var(--gray-700);
    line-height: 1.4;
}

.spec-link {
    margin-top: 0.75rem;
}

.about-page-link {
    display: inline-block;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
}

.about-page-link:hover {
    text-decoration: underline;
}

.left-panel-nav {
    padding: 0.75rem 1.25rem;
    flex: 1;
}

.left-panel-nav .nav-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.left-panel-nav .nav-link:hover {
    text-decoration: underline;
}

.left-panel-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.8rem;
    color: var(--gray-600);
}

.left-panel-footer a {
    color: var(--primary);
    text-decoration: none;
}

.left-panel-footer a:hover {
    text-decoration: underline;
}

.left-panel-links {
    padding: 0.5rem 1.25rem 1rem;
    font-size: 0.8rem;
    color: var(--gray-600);
}

.left-panel-links p {
    margin: 0 0 0.5rem;
}

.left-panel-links p:last-child {
    margin-bottom: 0;
}

.left-panel-links a {
    color: var(--primary);
    text-decoration: none;
}

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

/* Main content */
main {
    flex: 1;
}

/* Input section */
.input-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.input-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

textarea {
    width: 100%;
    min-height: 250px;
    padding: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 1rem;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.options {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
}

/* Sample notes */
.sample-notes {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.sample-label {
    font-size: 0.9rem;
    color: var(--gray-600);
}

.sample-label a {
    color: var(--primary);
    text-decoration: none;
}

.sample-label a:hover {
    text-decoration: underline;
}

.sample-btn {
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.sample-btn:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.more-samples {
    font-size: 0.9rem;
    color: var(--gray-600);
}

.more-samples a {
    color: var(--primary);
    text-decoration: none;
}

.more-samples a:hover {
    text-decoration: underline;
}

button#extract-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

button#extract-btn:hover {
    background: var(--primary-dark);
}

/* Results container */
.results-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.stats {
    display: flex;
    gap: 1.5rem;
}

.stat {
    color: var(--gray-600);
}

.stat strong {
    color: var(--primary);
    font-size: 1.1rem;
}

.legend-label {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--gray-800);
    margin-right: 0.5rem;
}

.legend-item {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

.legend-item.negated {
    background: var(--medcat-bg);
    border-bottom: 2px dashed #dc2626;
}

.legend-item.uncertain {
    background: var(--medcat-bg);
    border-bottom: 2px dashed var(--medcat-color);
}

.legend-item.historical {
    background: var(--medcat-bg);
    border-bottom: 2px solid var(--medcat-color);
    opacity: 0.6;
}

.legend-item.family {
    background: var(--medcat-bg);
    border-bottom: 2px solid #7c3aed;
}

.legend-item.with-value {
    background: var(--obs-bg);
    border-bottom: 2px solid var(--obs-color);
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
}

.export-btn {
    background: white;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.export-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-800);
}


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

.export-btn:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

/* FHIR bundle floating panel */
.fhir-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 2rem;
}

.fhir-panel {
    background: white;
    width: min(820px, 100%);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.fhir-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.fhir-panel-title {
    font-weight: 600;
    color: var(--gray-800);
}

.fhir-panel-sub {
    font-weight: 400;
    color: var(--gray-400);
    font-size: 0.85rem;
}

.fhir-panel-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fhir-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0 0.35rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.fhir-close-btn:hover {
    color: var(--gray-800);
    background: var(--gray-200);
}

.fhir-tree-btn {
    background: white;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.fhir-tree-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-800);
}

.fhir-json {
    margin: 0;
    padding: 1.1rem 1.25rem;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--gray-800);
}

/* Collapsible JSON tree */
.fhir-json .jt-node,
.fhir-json .jt-line {
    white-space: nowrap;
}

.fhir-json summary.jt-summary {
    cursor: pointer;
    list-style: none;
    border-radius: 4px;
}

.fhir-json summary.jt-summary::-webkit-details-marker {
    display: none;
}

.fhir-json summary.jt-summary::before {
    content: "\25BE"; /* ▾ — escape keeps it charset-independent */
    display: inline-block;
    width: 1em;
    color: var(--gray-400);
    transition: transform 0.15s;
}

.fhir-json details:not([open]) > summary.jt-summary::before {
    transform: rotate(-90deg);
}

.fhir-json summary.jt-summary:hover {
    background: var(--gray-100);
}

/* Preview text ("… N keys }") shows only when the node is collapsed. */
.fhir-json .jt-preview {
    color: var(--gray-400);
    font-style: italic;
}

.fhir-json details[open] > summary.jt-summary > .jt-preview {
    display: none;
}

.fhir-json .jt-children {
    margin-left: 0.4rem;
    padding-left: 0.85rem;
    border-left: 1px solid var(--gray-200);
}

.fhir-json .jt-line,
.fhir-json .jt-close {
    padding-left: 1em; /* align with content after the disclosure marker */
}

.fhir-json .jt-key {
    color: #7c3aed;
}

.fhir-json .jt-string { color: #16a34a; }
.fhir-json .jt-number { color: #2563eb; }
.fhir-json .jt-boolean { color: #c2410c; }
.fhir-json .jt-null { color: var(--gray-400); }
.fhir-json .jt-bracket,
.fhir-json .jt-close { color: var(--gray-500); }

/* Two-panel layout */
.results-panels {
    display: flex;
    min-height: 400px;
}

/* Text panel (left) */
.text-panel {
    flex: 1;
    border-right: none;
    display: flex;
    flex-direction: column;
}

.panel-header {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1.25rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.annotated-text {
    padding: 1.25rem;
    flex: 1;
    overflow-y: auto;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.9;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.entity-count {
    padding: 0.75rem 1.25rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    font-size: 1.1rem;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.entity-count .reset-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.entity-count .reset-btn:hover {
    background: var(--primary-dark);
}

.entity-count strong {
    color: var(--primary);
}

.debug-time {
    color: var(--gray-400);
    font-size: 0.85rem;
}

/* Entity highlights */
mark.entity {
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

mark.source-medcat {
    background: var(--medcat-bg);
    border-bottom: 2px solid var(--medcat-color);
}

mark.source-obs_matcher {
    background: var(--obs-bg);
    border-bottom: 2px solid var(--obs-color);
}

mark.entity:hover {
    filter: brightness(0.95);
}

mark.entity.selected {
    box-shadow: 0 0 0 2px var(--primary);
    filter: brightness(0.92);
}

mark.source-medcat.selected {
    background: rgba(59, 130, 246, 0.3);
}

mark.source-obs_matcher.selected {
    background: rgba(16, 185, 129, 0.3);
}

/* Detail panel (right) */
.detail-panel {
    display: flex;
    flex-direction: column;
    background: var(--gray-50);
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    border-left: 1px solid var(--gray-200);
    z-index: 100;
}

.detail-content {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
}

.detail-placeholder {
    color: var(--gray-400);
    text-align: center;
    padding: 3rem 1rem;
    font-size: 0.95rem;
}

.entity-detail {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detail-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-row.highlight {
    background: white;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--gray-200);
}

.detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--gray-800);
    word-break: break-word;
}

.entity-text-value {
    font-weight: 600;
    font-size: 1.1rem;
}

.preferred-name {
    color: var(--primary-dark);
    font-weight: 500;
}

.sem-type-value {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.cui-link {
    color: var(--primary);
    text-decoration: none;
    font-family: 'SF Mono', Monaco, monospace;
}

.cui-link:hover {
    text-decoration: underline;
}

.source-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.source-badge.source-medcat {
    background: var(--medcat-bg);
    color: var(--medcat-color);
}

.source-badge.source-obs_matcher {
    background: var(--obs-bg);
    color: var(--obs-color);
}

.value-display,
.dose-display,
.frequency-display {
    font-family: 'SF Mono', Monaco, monospace;
    color: var(--success);
    font-weight: 600;
}

.position-value {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.85rem;
    color: var(--gray-400);
}

/* Hidden on desktop; the mobile @media reveals them */
.concept-paren-suffix { display: none; }
.header-context-flags { display: none; }

/* Context flags in detail panel */
.context-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.context-flag {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.context-flag.negated {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.context-flag.uncertain {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.context-flag.historical {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

.context-flag.family {
    background: #faf5ff;
    color: #7c3aed;
    border: 1px solid #ddd6fe;
}

/* Disambiguation candidates */
.disambiguation-row {
    margin-top: 0.5rem;
}

.sense-content {
    margin-top: 0.25rem;
}

.sense-term {
    font-size: 0.9rem;
    color: var(--gray-700);
    margin-bottom: 0.25rem;
}

.sense-candidates-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}

.candidates-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.candidate-item {
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--gray-100);
}

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

.candidate-row1 {
    display: flex;
    align-items: flex-start;
    gap: 0.3rem;
}

.candidate-row2 {
    display: flex;
    justify-content: space-between;
    margin-top: 0.1rem;
}

.candidate-selected {
    color: var(--success);
    font-size: 0.8rem;
    margin-left: 0.3rem;
}

.candidate-item.selected {
    font-weight: 500;
}

.candidate-name {
    font-size: 0.85rem;
    color: var(--gray-700);
    line-height: 1.3;
}

.candidate-item.selected .candidate-name {
    color: var(--gray-800);
}

.candidate-cui {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.75rem;
    color: var(--gray-400);
}

.candidate-score {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.75rem;
    color: var(--gray-400);
}

.candidate-item.selected .candidate-score {
    color: var(--success);
    font-weight: 600;
}

.raw-similarity {
    color: var(--gray-400);
    font-weight: 400;
    font-size: 0.7rem;
}

/* Laterality badge (superscript in annotated text) */
.laterality-badge {
    font-size: 0.7em;
    font-weight: 600;
    color: var(--gray-500);
    margin-left: 1px;
}

/* Laterality prefix in summary panels */
.laterality-prefix {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--gray-500);
}

/* Entity context styling in annotated text */
mark.entity.negated {
    border-bottom: 2px dashed #dc2626;
}

mark.entity.uncertain {
    border-bottom-style: dashed;
}

mark.entity.historical {
    opacity: 0.6;
}

mark.entity.family {
    border-bottom-color: #7c3aed;
}

mark.entity.has-dosage,
mark.entity.has-subspans {
    background: var(--obs-bg);
    border-bottom-color: var(--obs-color);
}

/* Subspans - hidden by default, shown on hover */
.subspan {
    transition: all 0.15s ease;
}

.subspan.highlighted {
    background: var(--obs-bg);
    border-bottom: 2px solid var(--obs-color);
    border-radius: 3px;
    padding: 0.1rem 0.2rem;
}

/* Safety net spans - highlighted in red */
.safety-net-span {
    background: #fee2e2;
    border-bottom: 2px solid #dc2626;
    border-radius: 3px;
    padding: 0.1rem 0.2rem;
    cursor: help;
}

/* Sections collapsible */
.sections-details {
    border-top: 1px solid var(--gray-200);
}

.sections-details summary {
    padding: 1rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    user-select: none;
}

.sections-details summary:hover {
    background: var(--gray-100);
}

.sections-list {
    padding: 0.5rem 1.25rem 1rem;
}

.section-item {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--gray-100);
}

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

.section-category {
    background: var(--gray-200);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
}

.section-header {
    color: var(--gray-600);
    font-family: monospace;
    font-size: 0.9rem;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--gray-600);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Error */
.error {
    background: #fef2f2;
    color: var(--error);
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #fecaca;
    max-width: 900px;
    margin: 1rem auto;
}

/* Summary Panels (Medications + Observations) */
.summary-panels {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.summary-panel {
    flex: 1;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
}

.summary-panel .panel-header {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: none;
}

.panel-export-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 3px;
    cursor: not-allowed;
    opacity: 0.7;
    font-weight: 500;
}

.panel-export-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.medication-sections {
    padding: 1rem;
}

.medication-section {
    margin-bottom: 1rem;
}

.medication-section:last-child {
    margin-bottom: 0;
}

.medication-section h4 {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.medication-section .med-table tr.negated .med-col-name {
    color: var(--error);
    text-decoration: line-through;
}

.medication-section .med-table tr.uncertain .med-col-name {
    color: var(--warning);
    font-style: italic;
}

.medication-section .med-table tr.historical .med-col-name {
    color: var(--gray-400);
}

.med-dose,
.med-freq {
    color: var(--success);
    font-weight: 600;
}

/* Medication table layout */
.med-table {
    width: 100%;
    border-collapse: collapse;
}

.med-table tr {
    cursor: pointer;
}

.med-table tr:hover,
.med-table tr.highlighted {
    background: var(--primary-light);
}

.med-table td {
    padding: 0.2rem 0.25rem;
    vertical-align: baseline;
    font-size: 0.9rem;
}

.med-col-action {
    width: 1.5em;
    text-align: center;
    font-size: 0.8em;
}

.med-col-name {
    color: var(--gray-800);
}

.med-col-dose {
    color: var(--success);
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

/* Diseases Summary */
.diseases-list {
    padding: 1rem;
}

.disease-section {
    margin-bottom: 1rem;
}

.disease-section:last-child {
    margin-bottom: 0;
}

.disease-section h4 {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.disease-section ul {
    list-style: none;
    margin: 0;
    padding: 0;
    padding-left: 0.5rem;
}

.disease-section li {
    padding: 0.2rem 0;
    font-size: 0.9rem;
    color: var(--gray-800);
}

.disease-section li.negated {
    color: var(--error);
    text-decoration: line-through;
}

.disease-section li.uncertain {
    color: var(--warning);
    font-style: italic;
}

.disease-section li.historical {
    color: var(--gray-400);
}

.disease-section li.family {
    color: var(--gray-500);
    font-style: italic;
}

.disease-category {
    font-size: 0.8rem;
    color: var(--gray-400);
}

/* Observations Summary */
.observations-list {
    padding: 1rem;
}

.observations-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.observations-list li {
    padding: 0.3rem 0;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-100);
}

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

.obs-name {
    color: var(--gray-600);
}

.obs-value {
    font-weight: 600;
    color: var(--success);
}

/* Panel item hover highlighting */
.panel-item {
    cursor: pointer;
    transition: background 0.15s ease;
}

.panel-item:hover,
.panel-item.highlighted {
    background: var(--primary-light);
    border-radius: 3px;
}

/* Entity highlighted from panel hover */
mark.entity.panel-highlighted {
    box-shadow: 0 0 0 2px var(--primary);
    filter: brightness(0.92);
}

/* Main Footer */
.main-footer {
    text-align: center;
    padding: 1.5rem 0 1rem;
    color: var(--gray-400);
    font-size: 0.8rem;
}

.main-footer .attribution {
    font-size: 0.7rem;
    margin-top: 0.25rem;
}

.main-footer .footer-desc {
    margin-bottom: 0.5rem;
}

/* Responsive */
@media (max-width: 1200px) {
    .left-panel { display: none; }

    .container {
        margin-left: 0;
        margin-right: 0;
    }

    /* Detail panel becomes a tap-anchored popover on mobile/tablet.
       JS sets inline top/left in page coordinates and toggles .open. */
    .detail-panel {
        position: absolute;
        top: 0;
        left: 0;
        right: auto;
        bottom: auto;
        width: min(360px, calc(100vw - 24px));
        max-height: 60vh;
        height: auto;
        background: white;
        border-left: none;
        border: 1px solid var(--gray-300);
        border-radius: 10px;
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
        z-index: 1000;
        display: none;
    }
    .detail-panel.open { display: flex; }

    /* Entity text serves as the popover header on mobile — hide "Entity Details" */
    .detail-panel .panel-header { display: none; }

    .detail-content {
        max-height: calc(60vh - 0.5rem);
        padding: 0.75rem;
    }

    /* Concise content inside the mobile popover ---------------------------- */
    .entity-detail { gap: 0.4rem; }

    /* Rows hidden entirely on mobile (info merged elsewhere or low signal) */
    .detail-row--position,
    .detail-row--section,
    .detail-row--detected-name,
    .detail-row--sem-type,        /* sem type now sits in the name's (parens) */
    .detail-row.context-row {     /* context flags now sit in the blue header */
        display: none;
    }

    /* Inline label : value layout for the conditional info rows
       (Value, Dose, Frequency, Laterality, Action, Confidence).
       Highlight, disambiguation, concept-id/name keep their own layouts. */
    .detail-row:not(.highlight):not(.disambiguation-row):not(.context-row):not(.detail-row--concept-id):not(.detail-row--concept-name) {
        flex-direction: row;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.5rem;
    }
    .detail-row:not(.highlight):not(.disambiguation-row):not(.context-row):not(.detail-row--concept-id):not(.detail-row--concept-name) .detail-label {
        flex: 0 0 auto;
        font-size: 0.7rem;
    }
    .detail-row:not(.highlight):not(.disambiguation-row):not(.context-row):not(.detail-row--concept-id):not(.detail-row--concept-name) .detail-value {
        flex: 1 1 auto;
        text-align: right;
        font-size: 0.88rem;
    }

    /* Concept block — labels dropped, values stacked flush-left.
       Name shows its (semantic-type) suffix muted on mobile. */
    .detail-row--concept-name,
    .detail-row--concept-id {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
    }
    .detail-row--concept-name .detail-label,
    .detail-row--concept-id .detail-label { display: none; }
    .detail-row--concept-name .detail-value {
        text-align: left;
        width: 100%;
        font-size: 1rem;
    }
    .detail-row--concept-id .detail-value {
        text-align: left;
        width: 100%;
        font-size: 0.9rem;
    }
    .concept-paren-suffix {
        display: inline;
        color: var(--gray-500);
        font-weight: 400;
    }

    /* Entity-text header becomes a full-width blue title bar; context-flag
       chips sit on the right. Negative margins cancel .detail-content padding
       so the bar touches the rounded popover corners. */
    .detail-row.highlight {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        margin: -0.75rem -0.75rem 0.5rem;
        padding: 0.55rem 0.75rem;
        background: var(--primary);
        border: none;
        border-radius: 10px 10px 0 0;
    }
    .detail-row.highlight .detail-label { display: none; }
    .entity-text-value {
        font-size: 1.15rem;
        color: white;
    }
    .header-context-flags {
        display: flex;
        gap: 0.25rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    /* White chip + colored bottom-border per flag — same visual key as the
       desktop legend row, just inlined into the header. */
    .header-context-flags .context-flag {
        background: white;
        color: var(--gray-800);
        border: none;
        border-radius: 3px;
        font-size: 0.65rem;
        padding: 0.1rem 0.4rem;
        text-transform: none;
    }
    .header-context-flags .context-flag.negated    { border-bottom: 2px dashed #dc2626; }
    .header-context-flags .context-flag.uncertain  { border-bottom: 2px dashed var(--medcat-color); }
    .header-context-flags .context-flag.historical { border-bottom: 2px solid var(--medcat-color); opacity: 0.7; }
    .header-context-flags .context-flag.family     { border-bottom: 2px solid #7c3aed; }

    /* Context Sense (disambiguation) — drop the label header, separator above */
    .disambiguation-row { margin-top: 0.25rem; }
    .detail-row.disambiguation-row .detail-label { display: none; }
    .sense-content {
        border-top: 1px solid var(--gray-200);
        padding-top: 0.4rem;
        margin-top: 0.25rem;
    }
    .sense-term,
    .sense-candidates-label { display: none; }

    /* Selected candidate: tint background instead of explicit (Selected) text */
    .candidate-selected { display: none; }
    .candidate-item.selected {
        background: rgba(37, 99, 235, 0.07);
        margin: 0 -0.35rem;
        padding-left: 0.35rem;
        padding-right: 0.35rem;
        border-radius: 4px;
    }

    .candidate-item { padding: 0.2rem 0; }
    .candidate-row2 { margin-top: 0; }
    .candidate-name { font-size: 0.82rem; }
    .candidate-keywords { gap: 0.25rem; margin-top: 0.15rem; }
    .keyword-tag { font-size: 0.7rem; padding: 0.1rem 0.35rem; }

    /* Legends row hidden — the header chips above carry the visual key */
    .stats { display: none; }

    /* Derived panels stack vertically on mobile (horizontal on desktop) */
    .summary-panels { flex-direction: column; }
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .options {
        flex-direction: column;
        gap: 0.75rem;
    }

    .results-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .header-buttons {
        width: 100%;
    }

    .header-buttons button {
        flex: 1;
    }

    .annotated-text {
        font-size: 0.85rem;
    }
}

/* ==================== About Page Styles ==================== */

.about-page {
    max-width: 900px;
}

.about-page header {
    text-align: center;
    margin-bottom: 1rem;
}

.about-nav {
    margin-bottom: 2rem;
}

.nav-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-link:hover {
    text-decoration: underline;
}

.about-content {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.about-section {
    margin-bottom: 2.5rem;
}

.about-section:last-child {
    margin-bottom: 0;
}

.about-section h2 {
    color: var(--gray-800);
    font-size: 1.4rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gray-100);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.feature-card {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid var(--gray-100);
}

.feature-card h3 {
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.feature-card p {
    color: var(--gray-600);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

.about-section p {
    color: var(--gray-700);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.about-section ul {
    color: var(--gray-700);
    line-height: 1.6;
    padding-left: 1.5rem;
}

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

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.25rem;
    font-size: 0.9rem;
}

.comparison-table th,
.comparison-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.comparison-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
}

.comparison-table td:first-child {
    font-weight: 500;
}

.comparison-table th:not(:first-child),
.comparison-table td:not(:first-child) {
    text-align: center;
}

.disambiguation-screenshot {
    margin: 0.75rem 0 0.25rem 0;
}

.disambiguation-screenshot img {
    max-width: 100%;
    width: auto;
    height: auto;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.disambiguation-screenshot.side-by-side {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.disambiguation-screenshot.side-by-side img {
    max-height: 280px;
    width: auto;
    object-fit: contain;
}

.about-section blockquote {
    background: var(--gray-50);
    border-left: 4px solid var(--primary);
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    border-radius: 0 8px 8px 0;
}

.about-section blockquote a {
    color: var(--primary);
    text-decoration: none;
}

.about-section blockquote a:hover {
    text-decoration: underline;
}

.download-box {
    background: var(--gray-800);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-top: 1rem;
}

.download-box code {
    display: block;
    color: #4ade80;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.download-box code:last-of-type {
    margin-bottom: 0;
}

.download-note {
    color: var(--gray-400);
    font-size: 0.85rem;
    margin: 0.75rem 0 0 0;
    font-style: italic;
}

.code-block {
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.85rem;
    color: var(--gray-800);
    overflow-x: auto;
}

.section-note {
    font-size: 0.8rem;
    color: var(--gray-400);
    font-style: italic;
    margin-top: -0.5rem;
    margin-bottom: 0.75rem;
}

.who-for {
    font-size: 0.9rem;
    color: var(--gray-500);
    font-style: italic;
    margin-top: 0.5rem;
}

.about-section.limitations {
    background: #fef2f2;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #fecaca;
}

.about-section.limitations h2 {
    color: #991b1b;
    border-bottom-color: #fecaca;
}

.about-section.notice {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    border: 1px solid var(--gray-200);
}

.about-section.notice h2 {
    font-size: 1rem;
    color: var(--gray-600);
    border-bottom: none;
    margin-bottom: 0.5rem;
}

.about-section.notice p {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 0;
}

.about-section.limitations ul {
    color: var(--gray-700);
}

.about-section.status {
    background: #fffbeb;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #fde68a;
}

.about-section.status h2 {
    color: #92400e;
    border-bottom-color: #fde68a;
}

.status-badge {
    display: inline-block;
    background: #f59e0b;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    margin-bottom: 0.5rem;
}

.status-inline {
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.status-badge-small {
    display: inline-block;
    background: #fbbf24;
    color: #78350f;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.about-footer {
    text-align: center;
    color: var(--gray-400);
    font-size: 0.85rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-100);
}

@media (max-width: 600px) {
    .about-content {
        padding: 1.25rem;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }
}

/* Debug mode: Keyword highlighting in text */
.keyword-highlight {
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 500;
}

.keyword-highlight.boost {
    background: rgba(22, 163, 74, 0.3);
    border: 1px solid var(--success);
}

.keyword-highlight.demote {
    background: rgba(220, 38, 38, 0.3);
    border: 1px solid var(--error);
}

.keyword-highlight.section {
    background: rgba(202, 138, 4, 0.3);
    border: 1px solid var(--warning);
}

.keyword-highlight.concept {
    background: rgba(59, 130, 246, 0.3);
    border: 1px solid #3b82f6;
}

.keyword-highlight.soft_section {
    background: rgba(147, 51, 234, 0.3);
    border: 1px solid #9333ea;
}

/* Debug mode: Keyword tags in candidate panel */
.candidate-keywords {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.keyword-tag {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 500;
}

.keyword-tag.boost {
    background: rgba(22, 163, 74, 0.15);
    color: var(--success);
    border: 1px solid rgba(22, 163, 74, 0.3);
}

.keyword-tag.demote {
    background: rgba(220, 38, 38, 0.15);
    color: var(--error);
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.keyword-tag.section {
    background: rgba(202, 138, 4, 0.15);
    color: var(--warning);
    border: 1px solid rgba(202, 138, 4, 0.3);
}

.keyword-tag.soft_section {
    background: rgba(147, 51, 234, 0.15);
    color: #9333ea;
    border: 1px solid rgba(147, 51, 234, 0.3);
}

/* Heat map visualization for soft section */
.heat-map-highlight {
    border-radius: 2px;
}

/* Hoverable candidate items */
.candidate-item[data-keywords] {
    cursor: pointer;
}

.candidate-item[data-keywords]:hover {
    background: var(--gray-100);
}

/* =========================================================================
   Reconciliation page (/reconcile)
   ========================================================================= */

/* No sidebars on this page — a simple centered column. */
.reconcile-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.reconcile-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.reconcile-toolbar .reset-btn {
    background: white;
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.reconcile-toolbar .reset-btn:hover {
    background: var(--gray-100);
}

.reconcile-toolbar .reconcile-hint {
    flex: 1;
    color: var(--gray-500);
    font-size: 0.85rem;
}

/* Two zones: the bundle (Conditions + Medications) and the staging pool (Ignore). */
.reconcile-board {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.bundle-zone {
    flex: 1.7;
    min-width: 320px;
    border: 1px solid var(--primary);
    background: #f4f8ff;
    border-radius: 10px;
    padding: 0.5rem 0.65rem 0.7rem;
}

.bundle-columns {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}

.pool-zone {
    flex: 1.1;
    min-width: 240px;
}

/* Zone captions above each side. */
.zone-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--primary);
    padding: 0.2rem 0.25rem 0.5rem;
}

.zone-header .zone-arrow { font-weight: 400; }

.zone-header-muted { color: var(--gray-400); }

.bucket-column {
    flex: 1;
    min-width: 150px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.bundle-zone .bucket-column { background: white; }

/* Placeholder shown in an empty output bucket. */
.dropzone-empty {
    color: var(--gray-400);
    font-size: 0.8rem;
    font-style: italic;
    text-align: center;
    padding: 1.25rem 0.5rem;
}

/* Sticky action bar anchoring the primary action + a live bundle summary. */
.reconcile-actionbar {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.bundle-summary {
    font-size: 0.9rem;
    color: var(--gray-600);
}

.bucket-header {
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.6rem 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bucket-header.bucket-conditions { background: var(--primary); }
.bucket-header.bucket-meds       { background: var(--success); }
.bucket-header.bucket-ignore     { background: var(--gray-400); }

.bucket-count {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    padding: 0.05rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.bucket-dropzone {
    min-height: 140px;
    /* Always keep a chip-sized blank strip at the bottom so there's room to drop
       into even when the box is otherwise full. */
    padding: 0.6rem 0.6rem 2.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex: 1;
    transition: background 0.15s, outline 0.15s;
}

/* Only the dense staging pool scrolls; the output boxes grow with their content
   so a drop target is always visible without scrolling. */
.pool-zone .bucket-dropzone {
    max-height: 62vh;
    overflow-y: auto;
}

/* Labelled sub-sections inside the Ignore column. */
.ignore-section + .ignore-section { margin-top: 0.5rem; }

.ignore-section-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
    color: var(--gray-400);
    padding-bottom: 0.2rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
}

.ignore-section-count { color: var(--gray-300); }

/* Pool chips wrap like tags so the staging area stays compact. */
.ignore-section-items {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.pool-zone .chip {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

.pool-zone .chip-remove { margin-left: 0.1rem; }

.bucket-dropzone.drag-over {
    outline: 2px dashed var(--primary);
    outline-offset: -4px;
    background: var(--primary-light);
}

.chip {
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    padding: 0.4rem 0.55rem;
    font-size: 0.85rem;
    cursor: grab;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    user-select: none;
    touch-action: none;
}

.chip:active { cursor: grabbing; }

/* The original chip while its clone is being dragged. */
.chip.drag-source { opacity: 0.35; }

/* Floating clone that tracks the cursor during a drag — the "held" card. */
.chip-floating {
    position: fixed;
    z-index: 300;
    margin: 0;
    pointer-events: none;
    opacity: 0.95;
    cursor: grabbing;
    border: 2px solid var(--primary);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    transform: rotate(-1.5deg);
}

.chip-name {
    color: var(--gray-800);
    font-weight: 500;
}

.chip-badge {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--success);
    background: var(--gray-50);
    border-radius: 3px;
    padding: 0 0.3rem;
}

.chip-flag {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 600;
    border-radius: 3px;
    padding: 0.05rem 0.3rem;
}

.chip-flag.negated   { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
.chip-flag.uncertain { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.chip-flag.family    { background: #faf5ff; color: #7c3aed; border: 1px solid #ddd6fe; }

.chip-mult {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-100);
    border-radius: 8px;
    padding: 0.05rem 0.35rem;
}

/* Hand-added concept chips */
.chip.chip-added {
    border-style: dashed;
    border-color: var(--primary);
}

.chip-added-mark {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.8rem;
}

.chip-remove {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.1rem;
}

.chip-remove:hover { color: var(--error); }

/* Add-concept search box */
.concept-search {
    position: relative;
    margin-bottom: 1rem;
    max-width: 480px;
}

#concept-search-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-family: inherit;
}

#concept-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.concept-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    margin-top: 2px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    max-height: 280px;
    overflow-y: auto;
}

.suggestion {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.suggestion:hover,
.suggestion.active {
    background: var(--primary-light);
}

.suggestion .sugg-main {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-width: 0;
}

.suggestion .sugg-name { color: var(--gray-800); }

.suggestion .sugg-cui {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--gray-400);
    flex-shrink: 0;
}

.sugg-tag {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    border-radius: 3px;
    padding: 0.05rem 0.35rem;
}

.sugg-tag-condition  { background: var(--primary-light); color: var(--primary-dark); }
.sugg-tag-finding    { background: #faf5ff; color: #7c3aed; }
.sugg-tag-medication { background: #dcfce7; color: #15803d; }
.sugg-tag-other      { background: var(--gray-100); color: var(--gray-600); }

.sugg-matched {
    font-size: 0.72rem;
    font-style: italic;
    color: var(--gray-400);
}

.suggestion-loading {
    color: var(--gray-400);
    font-style: italic;
    cursor: default;
}
