:root {
    --bg-page: #F3F5F7;
    --bg-card: #FFFFFF;
    --accent-primary: #2E2F33;
    --accent-success: #00B341;
    --accent-warning: #FFC400;
    --accent-orange:  #F57C00;
    --accent-danger: #FF3333;
    --text-main: rgba(0, 0, 0, 0.86);
    --text-muted: rgba(0, 0, 0, 0.5);
}
body {
    margin: 0;
    font-family: 'YS Text', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}
.container { max-width: 800px; margin: 0 auto; padding: 0 16px; }

/* ========================================= */
/* LAYOUT & CARDS */
/* ========================================= */
.card-wrapper {
    background: var(--bg-card);
    border-radius: 40px;
    padding: 32px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.04);
    margin-bottom: 24px;
}
/* Внутренние карточки результатов */
.card-inner {
    background: var(--bg-page); /* Чуть темнее белого */
    border-radius: 24px;
    padding: 24px;
}
.card-inner h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 18px;
    color: var(--text-main);
}

@media (max-width: 767px) {
    .card-wrapper { padding: 20px; border-radius: 24px; }
    .card-inner { padding: 16px; border-radius: 16px; }
}

/* ========================================= */
/* ANALYTICS & BARS (RESTORED) */
/* ========================================= */
.analytics-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}
.dist-label {
    font-weight: 700;
    width: 16px;
    text-align: center;
    color: var(--text-main);
}
.dist-bar-bg {
    flex: 1;
    height: 10px;
    background-color: rgba(0,0,0,0.06);
    border-radius: 6px;
    overflow: hidden;
}
.dist-bar-fill {
    height: 100%;
    width: 0%; /* JS меняет это */
    border-radius: 6px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.dist-pct {
    width: 36px;
    text-align: right;
    color: var(--text-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* Forecast List (Callouts) */
.forecast-list { margin: 0; }
.callout {
    background: var(--bg-card);
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 8px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.callout.success {
    background: #E6F7EB; /* Светло-зеленый */
    color: #007029;
}

/* ========================================= */
/* LOGIC: TABS & FORMS */
/* ========================================= */
.input-section { display: none; animation: fadeIn 0.3s ease; }
.input-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.input-base {
    width: 100%;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-main);
    background: var(--bg-page);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-base:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(46, 47, 51, 0.1);
    background: var(--bg-card);
}

.complex-row { display: flex; gap: 8px; margin-bottom: 8px; }
.complex-row input:first-child { flex: 2; }
.complex-row input:not(:first-child) { flex: 1; }

/* ========================================= */
/* BUTTONS */
/* ========================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: none; cursor: pointer; font-family: inherit; font-weight: 600;
    transition: all 0.2s; text-decoration: none;
}
.btn-secondary {
    background: var(--bg-page); color: var(--text-main);
    border-radius: 12px; font-size: 14px; padding: 12px 20px;
}
.btn-secondary:hover { background: #E8EAEB; color: var(--accent-primary); }

.btn-grade {
    flex: 1; font-size: 22px; font-weight: 700; border: none;
    height: 56px; border-radius: 14px; cursor: pointer;
    transition: transform 0.1s ease; color: white;
}
.btn-grade:active { transform: scale(0.96); }

/* Colors */
.bg-5 { background-color: var(--accent-success) !important; color: white !important; }
.bg-4 { background-color: var(--accent-warning) !important; color: #2E2F33 !important; }
.bg-3 { background-color: var(--accent-orange) !important; color: white !important; }
.bg-2 { background-color: var(--accent-danger) !important; color: white !important; }
.bg-1 { background-color: #9E9E9E !important; color: white !important; }

/* ========================================= */
/* NAVIGATION */
/* ========================================= */
.nav-link {
    text-decoration: none; color: var(--text-muted); font-weight: 500; font-size: 15px;
    transition: color 0.2s; display: flex; align-items: center; gap: 4px;
}
.nav-link:hover { color: var(--accent-primary); }

.nav-dropdown { position: relative; height: 100%; display: flex; align-items: center; }
.nav-dropdown-menu {
    display: none; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    background: var(--bg-card); min-width: 180px; padding: 8px; border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1); border: 1px solid rgba(0,0,0,0.08);
    z-index: 1000; margin-top: 0px; padding-top: 4px;
}
.nav-dropdown-menu::before { content: ''; position: absolute; top: -15px; left: 0; right: 0; height: 15px; background: transparent; }
.nav-dropdown:hover .nav-dropdown-menu { display: block; animation: slideUp 0.2s ease; }
.nav-dropdown-menu a {
    display: block; padding: 10px 12px; text-decoration: none; color: var(--text-main);
    font-size: 14px; font-weight: 500; border-radius: 8px; transition: background 0.2s;
}
.nav-dropdown-menu a:hover { background: var(--bg-page); color: var(--accent-primary); }
@keyframes slideUp { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Mobile Nav */
.mobile-nav-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 1000; opacity: 0; pointer-events: none;
    transition: opacity 0.3s; backdrop-filter: blur(4px);
}
.mobile-nav-overlay.active { opacity: 1; pointer-events: auto; }
.mobile-nav-content {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 280px; max-width: 80%; background: var(--bg-card); padding: 24px;
    transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.1);
}
.mobile-nav-overlay.active .mobile-nav-content { transform: translateX(0); }
.nav-link-mobile {
    display: block; padding: 14px 0; text-decoration: none; color: var(--text-main);
    font-weight: 500; font-size: 16px; border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* ========================================= */
/* MODE SELECTOR */
/* ========================================= */
.mode-selector-scroll {
    display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 8px; padding-top: 4px;
}
.mode-selector-scroll::-webkit-scrollbar { display: none; }
.mode-selector-scroll input[type="radio"] { display: none; }
.mode-selector-scroll label {
    flex-shrink: 0; display: inline-flex; align-items: center; padding: 8px 16px;
    border-radius: 12px; background: transparent; color: var(--text-muted);
    font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
    transition: all 0.2s; white-space: nowrap; user-select: none;
}
.mode-selector-scroll input[type="radio"]:checked + label {
    background: var(--bg-card); color: var(--text-main);
    border-color: rgba(0,0,0,0.04); box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.mode-selector-scroll label:hover { color: var(--text-main); background: rgba(0,0,0,0.03); }
.mode-selector-scroll input[type="radio"]:checked + label:hover { background: var(--bg-card); }
.mode-selector-mobile { display: none; }

/* ========================================= */
/* FAQ */
/* ========================================= */
.faq-list {
    background: var(--bg-card); border-radius: 24px; border: 1px solid rgba(0,0,0,0.08);
    padding: 0 24px; margin-top: 24px;
}
.faq-item { border-bottom: 1px solid rgba(0,0,0,0.05); }
.faq-item:last-child { border-bottom: none; }
.faq-header {
    width: 100%; text-align: left; background: transparent; border: none; padding: 24px 0;
    font-size: 17px; font-weight: 600; color: var(--text-main) !important;
    cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    outline: none; transition: color 0.2s;
}
.faq-header:hover { color: var(--accent-primary) !important; }
.faq-icon {
    position: relative; width: 24px; height: 24px; flex-shrink: 0; margin-left: 16px;
    background-color: var(--text-muted);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center; mask-position: center; transition: transform 0.3s, background-color 0.2s;
}
.faq-header.active .faq-icon { transform: rotate(-180deg); background-color: var(--accent-primary); }
.faq-content {
    max-height: 0; opacity: 0; visibility: hidden; overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease, visibility 0.4s;
}
.faq-content.active { max-height: 800px; opacity: 1; visibility: visible; }
.faq-content-inner { padding-top: 8px; padding-bottom: 24px; }
.faq-content p { margin: 0; color: rgba(0, 0, 0, 0.6) !important; font-size: 15px; line-height: 1.6; }

/* ========================================= */
/* UTILS & UI POLISH */
/* ========================================= */
.hide-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.hide-scrollbar::-webkit-scrollbar { display: none; }
.value-update { animation: valueFlash 0.4s ease-out; }
@keyframes valueFlash {
    0% { transform: scale(1); } 50% { transform: scale(1.08); color: var(--accent-success); } 100% { transform: scale(1); }
}

/* Toasts */
#toast-container { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: max-content; max-width: 90vw; }
.toast { background: var(--accent-primary); color: white; padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); animation: toastSlideUp 0.3s forwards; pointer-events: auto; }
.toast.success { background: var(--accent-success); }
.toast.fade-out { animation: toastFadeOut 0.3s ease forwards; }
@keyframes toastSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastFadeOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(10px); } }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.modal.active { opacity: 1; pointer-events: auto; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); }
.modal-content { position: relative; width: 100%; max-width: 400px; background: var(--bg-card); border-radius: 24px; padding: 24px; box-shadow: 0 10px 40px rgba(0,0,0,0.1); transform: scale(0.95) translateY(10px); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); margin: 16px !important; }
.modal.active .modal-content { transform: scale(1) translateY(0); }

/* Base Buttons / Icons */
.btn-icon { background: none; border: none; cursor: pointer; padding: 4px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); transition: color 0.2s, transform 0.2s; outline: none; }
@media (hover: hover) and (pointer: fine) { .btn-icon:hover { color: var(--accent-danger); transform: scale(1.1); } }

/* Hero Section */
.hero-section { padding: 40px 0; }
.hero-title { font-size: 38px; line-height: 1.2; margin-bottom: 16px; margin-top: 0; }

/* Cookie Banner */
.cookie-banner { display: none; position: fixed; bottom: 16px; left: 16px; right: 16px; max-width: 400px; background: var(--bg-card); box-shadow: 0 4px 24px rgba(0,0,0,0.15); padding: 16px; border-radius: 16px; z-index: 9999; border: 1px solid rgba(0,0,0,0.08); font-size: 13px; line-height: 1.5; }

/* Responsive Overrides */
@media (min-width: 768px) {
    .desktop-nav { display: flex !important; }
    .mobile-menu-btn { display: none !important; }
}
@media (max-width: 767px) {
    .settings-text { display: none; }
    #btn-settings { padding: 0 12px !important; }
    .header-logo-text { font-size: 18px !important; }
    .header-logo-svg { width: 32px !important; height: 32px !important; }
    .faq-list { padding: 0 16px; border-radius: 20px; }
    .faq-header { font-size: 16px; padding: 20px 0; }
    .modal { align-items: flex-end; }
    .modal-content { margin: 0 !important; max-width: 100%; border-bottom-left-radius: 0; border-bottom-right-radius: 0; transform: translateY(100%); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
    .modal.active .modal-content { transform: translateY(0); }
    .hero-section { padding: 24px 0 24px; }
    .hero-title { font-size: 28px; }
    .cookie-banner { left: 0; right: 0; bottom: 0; max-width: 100%; border-radius: 20px 20px 0 0; border: none; border-top: 1px solid rgba(0,0,0,0.08); box-shadow: 0 -4px 20px rgba(0,0,0,0.1); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
@media (max-width: 600px) {
    .mode-selector-scroll { display: none !important; }
    .mode-selector-mobile { display: block; margin-bottom: 14px; }
}

/* ========================================= */
/* MOBILE OPTIMIZATION: SUBJECTS & INPUTS    */
/* ========================================= */
@media (max-width: 480px) {
    /* Делаем строки ввода предметов чуть компактнее по отступам, но больше по полям */
    .complex-row {
        gap: 6px;
    }
    
    /* Название предмета занимает больше места */
    .complex-row input:first-child { 
        flex: 1.5; 
        font-size: 14px; /* Чуть меньше шрифт, чтобы влезало длинное название */
        padding: 12px; 
    }
    
    /* Поле оценки короче */
    .complex-row input:not(:first-child) { 
        flex: 0.6; 
        text-align: center; 
        padding: 12px 4px;
    }

    /* Кнопка удаления - увеличиваем зону клика */
    .btn-remove {
        padding: 12px !important;
        margin-left: -4px;
        color: var(--accent-danger);
    }
}
