/* MSF Prep - Modern Conversational Style */
:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --accent: #3b82f6;
    --accent-soft: #eff6ff;
    --success: #10b981;
    --error: #ef4444;
    --border: #e5e7eb;
    --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html, body {
    height: 100%;
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Layout */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
}

/* Header */
header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
}

.logo {
    font-family: var(--mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.logo span {
    color: var(--text-muted);
    font-weight: 400;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.header-actions a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.header-actions a:hover {
    color: var(--text);
}

#user-display {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Main content */
main {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

/* Setup screen */
.setup-container {
    max-width: 500px;
    margin: 0 auto;
}

.setup-header {
    text-align: center;
    margin-bottom: 3rem;
}

.setup-header h1 {
    font-family: var(--mono);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.setup-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Load error message */
.load-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.load-error p {
    margin: 0;
    color: #dc2626;
    font-size: 0.9rem;
}

.load-error a {
    color: #dc2626;
    font-weight: 600;
}

/* MSF Guidelines Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #fefce8 0%, #fef3c7 100%);
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 1.5rem 0 1.5rem;
}

.modal-icon {
    font-size: 2rem;
}

.modal-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: #92400e;
    margin: 0;
}

.modal-body {
    padding: 1.25rem 1.5rem;
}

.modal-body p {
    font-size: 1rem;
    color: #78350f;
    margin: 0 0 1.25rem 0;
    line-height: 1.6;
}

.modal-body p strong {
    color: #92400e;
}

.msf-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.msf-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: white;
    border: 2px solid #d97706;
    border-radius: 8px;
    color: #b45309;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
}

.msf-link:hover {
    background: #fffbeb;
    border-color: #b45309;
    color: #92400e;
    transform: translateY(-1px);
}

.msf-link-main {
    background: #f59e0b;
    border-color: #f59e0b;
    color: white;
}

.msf-link-main:hover {
    background: #d97706;
    border-color: #d97706;
    color: white;
}

.msf-links-apps {
    display: flex;
    gap: 0.5rem;
}

.msf-link-app {
    flex: 1;
    font-size: 0.9rem;
    padding: 0.6rem 0.75rem;
}

.msf-tip {
    font-size: 0.9rem !important;
    margin: 0 !important;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    text-align: center;
}

.modal-footer {
    padding: 0 1.5rem 1.5rem 1.5rem;
}

.modal-footer .btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
}

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

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--sans);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Autocomplete styles */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--sans);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.autocomplete-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.autocomplete-dropdown.hidden {
    display: none;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.1s;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: var(--accent-soft);
}

.autocomplete-item .main-text {
    font-weight: 500;
}

.autocomplete-item .sub-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.autocomplete-item .tag {
    font-family: var(--mono);
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    background: var(--border);
    border-radius: 4px;
    color: var(--text-muted);
}

.autocomplete-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.country-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--accent-soft);
    border-radius: 8px;
    font-size: 0.9rem;
}

.country-preview .diseases {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.disease-tag {
    font-family: var(--mono);
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--accent);
    color: white;
    border-radius: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--text);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #333;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
}

/* Guidelines reminder */
.guidelines-reminder {
    text-align: right;
    margin-bottom: 0.5rem;
}

.guidelines-reminder a {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--accent);
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    background: var(--accent-soft);
    border-radius: 4px;
    transition: all 0.2s;
}

.guidelines-reminder a:hover {
    background: #dbeafe;
}

/* Chat interface */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
}

.scenario-banner {
    padding: 1rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.scenario-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--mono);
}

.scenario-text {
    font-size: 0.95rem;
    line-height: 1.7;
}

/* Messages */
.messages {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 1rem;
}

.message {
    margin-bottom: 1.5rem;
    animation: messageIn 0.3s ease;
}

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

.message-question {
    max-width: 85%;
}

.message-question .content {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    border-radius: 12px 12px 12px 4px;
}

.message-answer {
    max-width: 85%;
    margin-left: auto;
}

.message-answer .content {
    background: var(--text);
    color: white;
    padding: 1rem 1.25rem;
    border-radius: 12px 12px 4px 12px;
}

.message-feedback {
    max-width: 85%;
}

.message-feedback .content {
    padding: 1rem 1.25rem;
    border-radius: 12px;
}

.message-feedback.correct .content {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}

.message-feedback.incorrect .content {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.feedback-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feedback-explanation {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Patient update styling */
.patient-update {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.patient-update.negative {
    border-left-color: var(--error);
    background: #fef2f2;
}

.patient-update-header {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.patient-update-text {
    font-size: 0.9rem;
    line-height: 1.6;
}

.vitals-update {
    margin-top: 0.75rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.vital-item {
    padding: 0.25rem 0.5rem;
    background: var(--surface);
    border-radius: 4px;
    border: 1px solid var(--border);
}

.vital-item.critical {
    background: #fef2f2;
    border-color: var(--error);
    color: var(--error);
}

.clinical-reasoning {
    margin-top: 1rem;
    padding: 1rem;
    background: #f0fdf4;
    border-radius: 8px;
    border: 1px solid #bbf7d0;
}

.clinical-reasoning-header {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    color: #166534;
}

.clinical-reasoning-text {
    font-size: 0.85rem;
    line-height: 1.7;
    color: #14532d;
}

.question-number {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Input area */
.input-area {
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.input-field {
    flex: 1;
    position: relative;
}

.input-field textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    font-family: var(--sans);
    resize: none;
    min-height: 50px;
    max-height: 150px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-field textarea::placeholder {
    color: var(--text-muted);
}

.voice-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.voice-btn:hover {
    background: var(--bg);
}

.voice-btn.recording {
    background: #fef2f2;
    border-color: var(--error);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.voice-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.voice-btn.recording svg {
    color: var(--error);
}

.send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--text);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    background: #333;
}

.send-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

.send-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Progress */
.progress-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
}

.score-display {
    font-family: var(--mono);
}

/* Results */
.results-container {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.results-score {
    font-family: var(--mono);
    font-size: 4rem;
    font-weight: 700;
    margin: 2rem 0;
}

.results-grade {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.grade-excellent { background: #ecfdf5; color: #059669; }
.grade-good { background: #eff6ff; color: #2563eb; }
.grade-fair { background: #fffbeb; color: #d97706; }
.grade-needs-work { background: #fef2f2; color: #dc2626; }

.results-detail {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Leaderboard */
.leaderboard-container {
    max-width: 600px;
    margin: 0 auto;
}

.leaderboard-header {
    font-family: var(--mono);
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 0.875rem 1rem;
    text-align: left;
}

.leaderboard-table th {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.leaderboard-table td {
    border-bottom: 1px solid var(--border);
}

.leaderboard-table tr:last-child td {
    border-bottom: none;
}

.rank {
    font-family: var(--mono);
    font-weight: 600;
}

.rank-1 { color: #eab308; }
.rank-2 { color: #9ca3af; }
.rank-3 { color: #c2883b; }

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 640px) {
    header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .logo {
        font-size: 1rem;
    }
    
    .logo span {
        display: none;
    }
    
    .header-actions {
        gap: 0.75rem;
        font-size: 0.85rem;
    }
    
    #user-display {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    main {
        padding: 1rem;
    }
    
    .setup-header h1 {
        font-size: 1.2rem;
    }
    
    .setup-header p {
        font-size: 0.85rem;
    }
    
    .form-group label {
        font-size: 0.8rem;
    }
    
    .form-group input,
    .form-group select,
    .autocomplete-input {
        padding: 0.65rem 0.875rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .btn {
        padding: 0.875rem 1.25rem;
        font-size: 1rem;
    }
    
    .scenario-banner {
        padding: 0.875rem 1rem;
        margin-bottom: 1rem;
    }
    
    .scenario-meta {
        font-size: 0.7rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .scenario-text {
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    .message-question,
    .message-answer,
    .message-feedback {
        max-width: 100%;
    }
    
    .message-question .content,
    .message-answer .content,
    .message-feedback .content {
        padding: 0.875rem 1rem;
    }
    
    .question-number {
        font-size: 0.7rem;
    }
    
    .feedback-header {
        font-size: 0.95rem;
    }
    
    .feedback-explanation {
        font-size: 0.85rem;
    }
    
    .patient-update {
        padding: 0.75rem;
        margin-top: 0.75rem;
    }
    
    .patient-update-header {
        font-size: 0.8rem;
    }
    
    .patient-update-text {
        font-size: 0.85rem;
    }
    
    .vitals-update {
        font-size: 0.7rem;
    }
    
    .vital-item {
        padding: 0.2rem 0.4rem;
    }
    
    .clinical-reasoning {
        padding: 0.75rem;
        margin-top: 0.75rem;
    }
    
    .clinical-reasoning-header {
        font-size: 0.8rem;
    }
    
    .clinical-reasoning-text {
        font-size: 0.8rem;
    }
    
    .input-area {
        padding: 0.75rem 0;
    }
    
    .input-wrapper {
        gap: 0.5rem;
    }
    
    .input-field textarea {
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .voice-btn,
    .send-btn {
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }
    
    .voice-btn svg,
    .send-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .progress-indicator {
        font-size: 0.75rem;
        gap: 0.5rem;
    }
    
    .results-score {
        font-size: 3rem;
    }
    
    .results-grade {
        font-size: 0.85rem;
        padding: 0.4rem 1rem;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .results-actions button {
        width: 100%;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.6rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .autocomplete-dropdown {
        max-height: 200px;
    }
    
    .autocomplete-item {
        padding: 0.65rem 0.875rem;
    }
    
    .autocomplete-item .main-text {
        font-size: 0.95rem;
    }
    
    .autocomplete-item .sub-text {
        font-size: 0.8rem;
    }
    
    .country-preview {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    .disease-tag {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

/* Continue button */
.continue-prompt {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--accent-soft);
    border-radius: 8px;
}

.btn-continue {
    background: var(--accent);
    color: white;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-continue:hover {
    background: #2563eb;
}

.continue-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Clarification styling */
.message-clarification .content {
    background: #e0f2fe;
    border: 1px solid #7dd3fc;
    padding: 1rem 1.25rem;
    border-radius: 12px;
}

.clarify-header {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #0369a1;
}

.clarify-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #0c4a6e;
}

.clarify-text strong {
    color: #0369a1;
}

.clarify-note {
    font-size: 0.8rem;
    color: #0284c7;
    margin-top: 0.75rem;
    font-style: italic;
}

/* Hint styling */
.hint-notice {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}

.message-hint .content {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    padding: 1rem 1.25rem;
    border-radius: 12px;
}

.hint-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #92400e;
}

.hint-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #78350f;
}

.hint-note {
    font-size: 0.8rem;
    color: #a16207;
    margin-top: 0.75rem;
    font-style: italic;
}

/* Medical Abbreviation Tooltips */
.abbr-tooltip {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--accent);
    color: var(--accent);
    font-weight: 500;
}

.abbr-tooltip::after {
    content: attr(data-full);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.abbr-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--text);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 1000;
}

.abbr-tooltip:hover::after,
.abbr-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Touch device support */
@media (hover: none) {
    .abbr-tooltip:active::after,
    .abbr-tooltip:active::before {
        opacity: 1;
        visibility: visible;
    }
}

/* Ensure tooltip doesn't go off screen */
.abbr-tooltip.tooltip-left::after {
    left: 0;
    transform: translateX(0);
}

.abbr-tooltip.tooltip-right::after {
    left: auto;
    right: 0;
    transform: translateX(0);
}
