:root {
    /* Caritas Color Palette */
    --caritas-red: #DC1A1A;
    --caritas-red-dark: #B01515;
    --caritas-red-light: #E85050;

    --primary-main: var(--caritas-red);
    --primary-light: var(--caritas-red-light);
    --primary-dark: var(--caritas-red-dark);

    --accent-main: #F5A623;
    /* Warm accent */

    --bg-color: #f8f8f8;
    --surface-color: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.9);

    --text-main: #333333;
    --text-muted: #666666;
    --text-light: #ffffff;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);

    --font-heading: Helvetica, Arial, sans-serif;
    --font-body: Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-body);
    background-color: #ffffff;
    color: var(--text-main);
    line-height: 1.6;
    padding: 20px;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* Header */
.main-header {
    text-align: center;
    padding: 40px 0 20px;
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.logo-img {
    height: 100px;
    width: auto;
}

h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--primary-main);
    letter-spacing: -0.5px;
}

.year-badge {
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: var(--accent-main);
    color: var(--text-main);
    padding: 2px 8px;
    border-radius: 12px;
    vertical-align: middle;
    font-weight: 700;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Input Section */
.input-section {
    padding: 20px 0;
    border-bottom: 2px solid var(--primary-main);
    margin-bottom: 40px;
}

.input-card {
    text-align: center;
}

.input-card h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.instruction {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.input-wrapper {
    position: relative;
    max-width: 500px;
    margin: 0 auto 20px;
}

input[type="text"] {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.1rem;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    background: #f0f4f8;
    transition: all 0.3s ease;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

input[type="text"]:focus {
    border-color: var(--primary-light);
    background: white;
    box-shadow: 0 0 0 4px rgba(220, 26, 26, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-main), var(--primary-dark));
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-md);
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Suggestions Box */
.suggestions-box {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10;
    overflow: hidden;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, 0.05);
    text-align: left;
}

.suggestions-box.hidden {
    display: none;
}

.suggestion-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.1s;
}

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

.suggestion-item:hover,
.suggestion-item.active {
    background: #ffe0e0;
}

.match-highlight {
    color: var(--primary-main);
    font-weight: 700;
}

.topic-count-badge {
    background: #edf2f7;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Visualization Section */
.viz-section {
    background: transparent;
    padding: 0;
}

.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 24px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 16px;
}

.viz-header h2 {
    font-size: 1.5rem;
}

.viz-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.chart-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chart-row {
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 1;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

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

.chart-label {
    width: 300px;
    text-align: right;
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-bar-area {
    flex-grow: 1;
    position: relative;
    height: 28px;
    background: #edf2f7;
    border-radius: 6px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-light), var(--primary-main));
    border-radius: 6px;
    width: 0%;
    /* Animate this */
    transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.chart-value {
    position: absolute;
    right: 8px;
    /* Inside the bar area, but right aligned if bar is small? No, let's put it slightly outside or dynamically */
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-left: 8px;
}

/* If bar is very short, value might need to be outside. For simplified proto, putting it right of bar area */
.chart-bar-area {
    /* Reset */
    overflow: visible;
    background: transparent;
    display: flex;
    align-items: center;
}

.chart-bar-bg {
    flex-grow: 1;
    background: #edf2f7;
    height: 12px;
    border-radius: 6px;
    margin-right: 10px;
    position: relative;
}

.chart-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--primary-main);
    border-radius: 6px;
}

.chart-value-text {
    width: 30px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
}

.main-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding-bottom: 20px;
}

/* Animations */
.upvote-anim {
    animation: pulse 0.4s ease-in-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* Instructional Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--surface-color);
    width: 90%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: slideUp 0.4s ease-out;
    transform: translateY(20px);
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--primary-main);
    margin: 0;
}

.modal-close-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    padding: 4px;
    display: flex;
}

.modal-close-icon:hover {
    color: var(--primary-main);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-intro {
    font-size: 1.1rem;
    margin-bottom: 24px;
    color: var(--text-main);
    line-height: 1.5;
}

.modal-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-list li {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.list-icon {
    background: #fff5f5;
    color: var(--primary-main);
    padding: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.list-text strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-main);
    font-size: 1rem;
}

.list-text p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.4;
    margin: 0;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #f0f0f0;
    text-align: right;
    background: #fbfbfb;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Floating Help Button */
.help-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-main);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    transition: transform 0.2s, background 0.2s;
}

.help-fab:hover {
    transform: scale(1.1);
    background: var(--primary-dark);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}