:root {
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --card-bg: #ffffff;
    --border-color: #dee2e6;
    --primary-color: #0d6efd;
    --primary-hover: #0b5ed7;
    --accent-color: #e9ecef;
    --success-color: #198754;
    --error-color: #dc3545;

    /* Enhanced segmented control colors */
    --segment-bg: #f0f4ff;
    --segment-hover: #e6eeff;
    --segment-shadow: 0 2px 8px rgba(13, 110, 253, 0.08);
    --segment-shadow-hover: 0 4px 12px rgba(13, 110, 253, 0.15);
    --segment-shadow-selected: 0 2px 6px rgba(13, 110, 253, 0.3);
    --primary-gradient: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);

    /* Enhanced card shadows */
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #121212;
        --text-color: #e0e0e0;
        --card-bg: #1e1e1e;
        --border-color: #333;
        --primary-color: #3d8bfd;
        --primary-hover: #5c9eff;
        --accent-color: #2c2c2c;

        /* Dark mode segmented control colors */
        --segment-bg: #2a2e3f;
        --segment-hover: #353945;
        --segment-shadow: 0 2px 8px rgba(61, 139, 253, 0.1);
        --segment-shadow-hover: 0 4px 12px rgba(61, 139, 253, 0.2);
        --segment-shadow-selected: 0 2px 6px rgba(61, 139, 253, 0.35);
        --primary-gradient: linear-gradient(135deg, #3d8bfd 0%, #5c9eff 100%);

        /* Dark mode card shadows */
        --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
        --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.5);
    }
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    /* Disable scroll anchoring globally: prevents the browser from adjusting
       window.scrollY when the sticky header changes height, which caused
       the header to oscillate between scrolled/non-scrolled states. */
    overflow-anchor: none;
}

.container {
    max-width: 1900px;
    /* Increased width for better space utilization on tablets/PCs */
    margin: 0 auto;
    padding: 20px;
}

/* Typography */
h1,
h2,
h3 {
    color: var(--text-color);
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
    text-align: center;
}

.btn:hover {
    background-color: var(--primary-hover);
    text-decoration: none;
}

.btn:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--accent-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

/* Layout: Language Selection */
.lang-selector {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 50px;
    flex-wrap: wrap;
    /* Safe wrap */
}

.lang-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    width: 350px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.lang-card:hover {
    text-decoration: none;
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* Info Pages */
.info-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: 10px;
    max-width: 900px;
    margin: 40px auto;
}

/* STUDY VIEW */
.study-header {
    position: sticky;
    top: 0;
    background-color: var(--bg-color);
    z-index: 1000;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 28px;
    display: flex;
    gap: 30px;
    align-items: flex-start;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.image-container {
    flex: 0 0 30%;
    text-align: center;
    max-width: 30%;
    transition: flex 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-container img {
    max-width: 100%;
    height: auto;
    max-height: 28vh;
    border-radius: 5px;
    cursor: zoom-in;
    border: 1px solid var(--border-color);
    object-fit: contain;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.prompt-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10px;
}

.prompt-box {
    background-color: var(--accent-color);
    padding: 15px;
    border-radius: 5px;
    margin-top: 10px;
    font-weight: 500;
}

/* 3+2 Grid Layout - Top row has 3 cards, bottom row has 2 centered cards */
.models-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 24px;
    margin-bottom: 150px;
    /* Space for footer */
}

.model-card {
    grid-column: span 2; /* Each card spans 2 columns = 3 cards per row */
}

/* Center the last 2 cards on the second row */
.model-card:nth-child(4) {
    grid-column: 2 / 4; /* Starts at column 2 */
}

.model-card:nth-child(5) {
    grid-column: 4 / 6; /* Starts at column 4 */
}

/* Responsive */
@media (max-width: 1000px) {
    .models-grid {
        grid-template-columns: 1fr;
    }

    /* Reset column spans for single column layout */
    .model-card {
        grid-column: auto;
    }

    .study-header {
        position: static;
        flex-direction: column;
    }

    .image-container {
        flex: auto;
        max-width: 100%;
    }
}

.model-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    border-left: 4px solid var(--primary-color);
}

.model-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

.model-header {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 12px;
    padding-bottom: 10px;
    text-align: center;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    letter-spacing: 0.5px;
}

.model-text {
    flex-grow: 1;
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--accent-color);
    border-radius: 8px;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
    color: var(--text-color);
    font-weight: 450;
}

/* Translation Tooltip Badge */
.trans-badge {
    font-size: 0.7rem;
    background-color: var(--accent-color);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
    cursor: help;
}

/* Ratings */
.rating-group {
    margin-bottom: 12px;
}

.rating-label {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
    color: var(--text-color);
    opacity: 0.9;
}

.rating-options input[type="radio"] {
    display: none;
}

.scale-label {
    font-size: 0.8rem;
    color: #666;
    margin: 0 10px;
    align-self: center;
    font-weight: 500;
}

.rating-options {
    display: flex;
    justify-content: center;
    /* Center the whole group including labels */
    align-items: center;
    /* Align labels and buttons vertically */
    background: var(--accent-color);
    padding: 5px;
    border-radius: 20px;
}

.rating-options input[type="radio"]:checked+span {
    background-color: var(--primary-color);
    color: white;
    padding: 2px 7px;
    border-radius: 50%;
}

/* Footer / Navigation */
.study-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    flex: 1;
    margin: 0 20px;
    height: 6px;
    background: var(--accent-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success-color);
    width: 0%;
    transition: width 0.3s;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.lightbox img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 50px;
    cursor: pointer;
}

/* Segmented Control Styles - Enhanced Modern Design */
.segmented-control {
    display: flex;
    width: 100%;
    border: none;
    border-radius: 10px;
    overflow: visible;
    background: var(--accent-color);
    margin-top: 5px;
    box-shadow: var(--segment-shadow);
    padding: 4px;
    gap: 4px;
}

.segment-opt {
    flex: 1;
    padding: 9px 6px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    border-right: none;
    border-radius: 8px;
    background: var(--segment-bg);
    color: var(--text-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.3px;
    line-height: 1.3;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.segment-opt:last-child {
    border-right: none;
}

.segment-opt:hover {
    background: var(--segment-hover);
    transform: translateY(-2px);
    box-shadow: var(--segment-shadow-hover);
}

.segment-opt.selected {
    background: var(--primary-gradient);
    color: white;
    font-weight: 600;
    box-shadow: var(--segment-shadow-selected);
    transform: scale(1.02);
}

.segment-opt:active {
    transform: scale(0.98);
    transition: all 0.1s;
}

/* Click animation */
@keyframes segment-click {
    0% { transform: scale(1); }
    50% { transform: scale(0.98); }
    100% { transform: scale(1.02); }
}

.segment-clicked {
    animation: segment-click 0.2s ease-out;
}

/* Modal Styles for "Show Original" */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 5000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 25px;
    border-radius: 10px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.5;
}

.modal-close:hover {
    opacity: 1;
}

.btn-original-modal {
    background: #6c757d;
    font-size: 0.8rem;
    padding: 4px 8px;
    margin-top: 8px;
    border-radius: 4px;
    color: white;
    border: none;
    cursor: pointer;
}

.btn-original-modal:hover {
    background: #5a6268;
}

/* Existing Author Image */
.author-img {
    width: 250px;
    height: auto;
    border-radius: 50%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

/* Scroll-more hint toast: appears after top row is rated */
.scroll-more-hint {
    position: fixed;
    bottom: 72px; /* sit above the footer bar */
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: rgba(13, 110, 253, 0.93);
    color: white;
    padding: 10px 22px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(13, 110, 253, 0.35);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.scroll-more-hint.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

