:root {
    /* Цвета Telegram WebApp */
    --bg: var(--tg-theme-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #222222);
    --hint: var(--tg-theme-hint-color, #999999);
    --link: var(--tg-theme-link-color, #2678b6);
    --btn: var(--tg-theme-button-color, #2678b6);
    --btn-text: var(--tg-theme-button-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
    --section-bg: var(--tg-theme-section-bg-color, #ffffff);
    --header-bg: var(--tg-theme-header-bg-color, #ffffff);
    --section-sep: var(--tg-theme-section-separator-color, #e0e0e0);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--section-sep);
}

.home-btn {
    font-size: 22px;
    text-decoration: none;
    color: var(--text);
    margin-left: auto;
    padding: 4px;
    cursor: pointer;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
}

.back-btn {
    background: none;
    border: none;
    color: var(--link);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
}

/* Content */
.content {
    padding: 16px;
    min-height: calc(100vh - 60px);
}

/* Loader */
.loader {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--secondary-bg);
    border-top-color: var(--btn);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Home Page */
.page-home {
    text-align: center;
    padding-top: 24px;
}

.logo {
    font-size: 64px;
    margin-bottom: 16px;
}

.welcome {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--hint);
    margin-bottom: 32px;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--section-bg);
    border: 1px solid var(--section-sep);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    transition: opacity 0.2s;
}

.menu-btn:active {
    opacity: 0.7;
}

.menu-icon {
    font-size: 24px;
    width: 32px;
    text-align: center;
}

/* Sections */
.section {
    background: var(--section-bg);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
}

.section-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 15px;
    color: var(--link);
    border-bottom: 1px solid var(--section-sep);
}

.section-content {
    padding: 12px 16px;
}

.section-content p {
    margin-bottom: 8px;
}

/* Image */
.img-container {
    margin: 12px auto;
    border-radius: 12px;
    overflow: hidden;
    max-width: 300px;
    min-width: 120px;
    cursor: pointer;
    background: #000;
}

.img-container img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 8px;
}

.img-caption {
    text-align: center;
    font-size: 13px;
    color: var(--hint);
    padding: 8px;
}

/* Lists */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--section-bg);
    border-bottom: 1px solid var(--section-sep);
    cursor: pointer;
    transition: opacity 0.2s;
}

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

.list-item:active {
    opacity: 0.7;
}

.list-item .num {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--btn);
    color: var(--btn-text);
    border-radius: 50%;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.list-item .text {
    flex: 1;
    font-size: 15px;
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--btn);
    color: var(--btn-text);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: opacity 0.2s;
}

.btn:active {
    opacity: 0.8;
}

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

.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.btn-row .btn {
    flex: 1;
    margin-top: 0;
}

/* Specialty Detail */
.spec-detail {
    padding: 16px;
}

.spec-detail h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.spec-code {
    display: inline-block;
    background: var(--btn);
    color: var(--btn-text);
    font-size: 16px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.spec-section {
    margin-bottom: 16px;
}

.spec-section h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--link);
}

.spec-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--section-sep);
}

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

/* Progress bar for test */
.progress-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--section-sep);
}

.progress-dot.filled {
    background: var(--btn);
}

/* Test question */
.question-text {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
}

.option-btn {
    display: block;
    width: 100%;
    padding: 14px 16px;
    background: var(--section-bg);
    border: 2px solid var(--section-sep);
    border-radius: 12px;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    margin-bottom: 8px;
    transition: all 0.2s;
    color: var(--text);
}

.option-btn.selected {
    border-color: var(--btn);
    background: var(--btn);
    color: var(--btn-text);
}

.option-btn:active {
    opacity: 0.8;
}

/* Results */
.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--section-bg);
    border-radius: 12px;
    margin-bottom: 8px;
}

.result-num {
    font-size: 20px;
    font-weight: 700;
    color: var(--btn);
}

.result-text {
    flex: 1;
}

.result-text h4 {
    font-size: 15px;
    margin-bottom: 2px;
}

.result-text p {
    font-size: 13px;
    color: var(--hint);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.pagination button {
    padding: 8px 16px;
    background: var(--secondary-bg);
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: default;
}

/* FAQ categories */
.faq-category {
    padding: 14px 16px;
    border-bottom: 1px solid var(--section-sep);
    cursor: pointer;
}

.faq-category:last-child {
    border-bottom: none;
}

.faq-category:active {
    opacity: 0.7;
}

.faq-category h3 {
    font-size: 15px;
    margin-bottom: 4px;
}

/* Error */
.error-msg {
    text-align: center;
    padding: 40px 16px;
    color: #ff4444;
}

.error-msg button {
    margin-top: 16px;
}

/* Admission menu */
.adm-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.adm-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--section-bg);
    border: 1px solid var(--section-sep);
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.adm-item:active {
    opacity: 0.7;
}

.adm-icon {
    font-size: 24px;
    width: 32px;
    text-align: center;
}

.adm-text h3 {
    font-size: 15px;
    margin-bottom: 2px;
}

.adm-text p {
    font-size: 13px;
    color: var(--hint);
}

/* Doc link */
.doc-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--link);
    text-decoration: none;
    padding: 8px 0;
}

.doc-link:active {
    opacity: 0.7;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--hint);
}

/* Test intro */
.test-intro {
    text-align: center;
    padding: 24px 16px;
}

.test-intro .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.test-intro p {
    margin-bottom: 12px;
    color: var(--hint);
}
