* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    color: #243044;
    background: linear-gradient(135deg, #f6efe7, #eef4ff);
    min-height: 100vh;
}

a {
    color: inherit;
}

.page {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 60px;
}

.page.narrow {
    width: min(460px, calc(100% - 32px));
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 40px;
}

.logo {
    font-size: 28px;
    font-weight: 800;
}

.subtitle {
    margin-top: 6px;
    color: #6b7280;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.login-btn,
.small-link,
button,
.cancel-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    background: #243044;
    color: white;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
}

.small-link {
    background: rgba(36, 48, 68, 0.08);
    color: #243044;
}

.cancel-link {
    margin-left: 8px;
    background: rgba(36, 48, 68, 0.08);
    color: #243044;
}

.hero {
    background: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: 28px;
    padding: 36px;
    box-shadow: 0 20px 50px rgba(31, 41, 55, 0.08);
    margin-bottom: 24px;
}

.hero h1 {
    margin: 0 0 12px;
    font-size: clamp(32px, 5vw, 56px);
    line-height: 1;
}

.hero p {
    margin: 0;
    color: #6b7280;
    font-size: 18px;
}

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.lesson-card,
.form-card {
    background: rgba(255,255,255,0.78);
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 24px;
    padding: 24px;
    text-decoration: none;
    box-shadow: 0 15px 35px rgba(31, 41, 55, 0.08);
}

.lesson-card h2 {
    margin: 0 0 10px;
    font-size: 22px;
}

.lesson-card p {
    margin: 0;
    color: #6b7280;
}

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: #6b7280;
    text-decoration: none;
}

.trainer {
    display: grid;
    justify-items: center;
    gap: 18px;
}

.counter {
    color: #6b7280;
    font-size: 18px;
}

.flip-card {
    width: min(640px, 100%);
    height: 360px;
    perspective: 1000px;
    cursor: pointer;
}

.flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.65s;
    transform-style: preserve-3d;
}

.flip-card.is-flipped .flip-inner {
    transform: rotateY(180deg);
}

.flip-side {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    padding: 34px;
    border-radius: 34px;
    background: white;
    backface-visibility: hidden;
    box-shadow: 0 25px 60px rgba(31, 41, 55, 0.16);
}

.flip-back {
    transform: rotateY(180deg);
    background: #fff8f1;
}

.card-text {
    font-size: clamp(22px, 4.5vw, 40px);
    font-weight: 800;
    text-align: center;
}

.hint {
    margin-top: 22px;
    color: #9ca3af;
    text-align: center;
}

.sound-btn {
    position: absolute;
    top: 22px;
    right: 22px;
    width: 46px;
    height: 46px;
    padding: 0;
    background: rgba(36, 48, 68, 0.08);
    color: #243044;
    font-size: 20px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.controls button {
    min-width: 130px;
}

.form-card h1 {
    margin-top: 0;
}

form {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    background: white;
}

textarea {
    resize: vertical;
}

.help {
    font-size: 13px;
    color: #6b7280;
    font-weight: 400;
}

.error {
    background: #fee2e2;
    color: #991b1b;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 16px;
}

.success {
    background: #dcfce7;
    color: #166534;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 16px;
}

.admin-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    gap: 18px;
    align-items: start;
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.admin-lesson-row {
    display: grid;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(36,48,68,0.12);
}

.admin-lesson-row span {
    display: block;
    margin-top: 4px;
    color: #6b7280;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.row-actions a {
    font-size: 14px;
}

.row-actions form {
    display: inline;
}

button.danger {
    background: #b91c1c;
    padding: 8px 12px;
}

.empty {
    background: rgba(255,255,255,0.8);
    padding: 24px;
    border-radius: 22px;
    color: #6b7280;
}

/* Компактный режим для GetCourse iframe: включается через &embed=1 */
.embed-body {
    background: transparent;
    min-height: 0;
}

.embed-page {
    width: 100%;
    padding: 8px 12px 16px;
}

.embed-page .trainer {
    gap: 10px;
}

.embed-page .counter {
    font-size: 16px;
}

.embed-page .flip-card {
    width: min(640px, 100%);
    height: 330px;
}

.embed-page .flip-side {
    border-radius: 28px;
    box-shadow: 0 18px 45px rgba(31, 41, 55, 0.14);
}

.embed-page .card-text {
    font-size: clamp(22px, 4.5vw, 40px);
}

.embed-page .hint {
    margin-top: 16px;
}

.embed-page .controls {
    margin-top: 2px;
    gap: 10px;
}

.embed-page .controls button {
    min-width: 120px;
    padding: 9px 14px;
}

@media (max-width: 760px) {
    .topbar {
        flex-direction: column;
    }

    .hero {
        padding: 24px;
    }

    .flip-card {
        height: 300px;
    }

    .admin-layout,
    .two-cols {
        grid-template-columns: 1fr;
    }

    .embed-page {
        padding: 6px 8px 12px;
    }

    .embed-page .flip-card {
        height: 300px;
    }

    .embed-page .flip-side {
        padding: 28px;
    }
}
