html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background: #008080; /* фон "старого рабочего стола" */
    font-family: Tahoma, Verdana, sans-serif;
    color: #000;
}

.desktop {
    height: 100%;
    display: flex;
}

/* Окно в стиле старых Windows — на весь экран */
.window {
    background: #d4d0c8;
    border: 3px solid #000;
    box-shadow: 0 0 0 1px #fff inset;
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    height: 100%;
    margin: 0;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out, box-shadow 0.2s ease-out;
}

.window-titlebar {
    background: linear-gradient(to right, #8a2be2, #cccccc);
    color: #fff;
    padding: 2px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
    font-size: 13px;
    transition: background 0.2s ease-out;
}

.window-titlebar-buttons {
    display: flex;
    gap: 2px;
}

.title-button {
    width: 16px;
    height: 14px;
    border: 1px solid #000;
    background: #c0c0c0;
    box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #808080 inset;
    font-size: 10px;
    line-height: 12px;
    text-align: center;
    cursor: default;
}

.window-menu {
    background: #d4d0c8;
    padding: 2px 6px;
    border-bottom: 1px solid #808080;
    font-size: 12px;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out;
}

.window-menu span {
    margin-right: 10px;
}

.window-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    border-bottom: 1px solid #808080;
    background: #f0f0f0;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out;
}

.logo-area img {
    height: 32px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-nav {
    display: flex;
    gap: 4px;
}

.nav-button {
    padding: 3px 8px;
    border: 1px solid #808080;
    background: #d4d0c8;
    box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #808080 inset;
    font-size: 12px;
    cursor: pointer;
}

.nav-button:active {
    box-shadow: -1px -1px 0 #fff inset, 1px 1px 0 #808080 inset;
}

/* иконка профиля справа */
.profile-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
}

.window-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.sidebar {
    width: 200px;
    background: #ece9d8;
    border-right: 1px solid #808080;
    padding: 8px;
    font-size: 12px;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out;
}

.sidebar h4 {
    margin: 6px 0 4px;
    font-size: 12px;
    color: #0a246a;
}

.sidebar-item {
    margin: 2px 0;
}

.main-area {
    flex: 1;
    padding: 10px;
    background: #ffffff;
    overflow: auto;
    transition: background-color 0.2s ease-out;
}

/* Экраны */
.screen {
    display: none;
    opacity: 0;
}

.screen.active {
    display: block;
    animation: screenFadeIn 0.25s ease-out;
    opacity: 1;
}

@keyframes screenFadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Анимация смены урока */
#screen-lesson.lesson-transition {
    animation: lessonSwitch 0.3s ease-out;
}

@keyframes lessonSwitch {
    0% {
        transform: translateX(8px);
        opacity: 0.6;
    }
    60% {
        transform: translateX(-2px);
        opacity: 1;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

h1, h2, h3 {
    margin-top: 0;
}

.primary-button {
    margin-top: 10px;
    padding: 6px 16px;
    border: 2px solid #808080;
    background: #d4d0c8;
    box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #808080 inset;
    cursor: pointer;
    font-size: 14px;
}

.primary-button:active {
    box-shadow: -1px -1px 0 #fff inset, 1px 1px 0 #808080 inset;
}

.secondary-button {
    margin-top: 4px;
    margin-bottom: 8px;
    padding: 5px 12px;
    border: 2px solid #808080;
    background: #e0e0e0;
    box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #808080 inset;
    cursor: pointer;
    font-size: 13px;
}

.secondary-button:active {
    box-shadow: -1px -1px 0 #fff inset, 1px 1px 0 #808080 inset;
}

.secondary-button:disabled {
    opacity: 0.6;
    cursor: default;
}

.nav-button,
.primary-button,
.secondary-button,
.quiz-button {
    transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, background 0.15s ease-out;
}

.nav-button:hover,
.primary-button:hover,
.secondary-button:hover,
.quiz-button:hover {
    transform: translateY(-1px);
}

.nav-button:active,
.primary-button:active,
.secondary-button:active,
.quiz-button:active {
    transform: translateY(1px);
}

#btn-trial {
    animation: ctaPulse 1.6s ease-in-out infinite;
}

@keyframes ctaPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(10, 36, 106, 0.5);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(10, 36, 106, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(10, 36, 106, 0);
    }
}

.hint {
    font-size: 12px;
    color: #555;
}

/* Тумблер темы */

.theme-toggle {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.theme-toggle-track {
    width: 52px;
    height: 22px;
    border-radius: 999px;
    background: #c0c0c0;
    border: 1px solid #808080;
    box-shadow: inset 1px 1px 0 #fff;
    position: relative;
    transition: background 0.2s ease-out, box-shadow 0.2s ease-out;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    overflow: hidden; /* чтобы иконки не вылазили за края */
}

.theme-toggle-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 1px 1px 0 #808080;
    position: absolute;
    top: 1px;
    left: 1px;
    transform: translateX(0);
    transition: transform 0.2s ease-out, background 0.2s ease-out, box-shadow 0.2s ease-out;
}

.theme-toggle-icon {
    font-size: 11px;
    line-height: 1;
    opacity: 0.65;
    transition: opacity 0.2s ease-out;
    pointer-events: none;
}

.theme-toggle-icon-sun {
    margin-right: 6px;
}

.theme-toggle-icon-moon {
    margin-left: 6px;
    opacity: 0.25;
}

.theme-toggle-on .theme-toggle-track {
    background: #202020;
    box-shadow: inset 1px 1px 0 #000;
}

.theme-toggle-on .theme-toggle-thumb {
    transform: translateX(28px);
    background: #ffe08a;
    box-shadow: 1px 1px 0 #000;
}

.theme-toggle-on .theme-toggle-icon-sun {
    opacity: 0.25;
}

.theme-toggle-on .theme-toggle-icon-moon {
    opacity: 0.9;
}

/* Лейаут стран */

.country-layout {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-top: 10px;
}

.country-lists {
    width: 40%;
    max-width: 280px;
}

.country-list {
    list-style: none;
    margin: 0 0 10px 0;
    padding: 0;
}

.country-list-title {
    font-size: 13px;
    margin: 6px 0 4px;
    font-weight: bold;
    color: #0a246a;
}

.country-item {
    padding: 6px 8px;
    margin-bottom: 4px;
    border: 1px solid #808080;
    background: #e4e4e4;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.country-item:hover {
    background: #d0d8ff;
}

.country-item.selected {
    background: #c0d0ff;
}

.country-item-flag {
    font-size: 18px;
    margin-right: 8px;
}

.country-item-name {
    flex: 1;
    font-size: 13px;
}

.country-item-status {
    font-size: 11px;
    color: #555;
    margin-left: 6px;
    white-space: nowrap;
}

.country-preview {
    flex: 1;
    min-height: 140px;
    border: 2px solid #808080;
    background: #f5f5ff;
    padding: 8px;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out;
}

.country-preview-placeholder {
    font-size: 13px;
    color: #555;
}

.country-preview-card {
    font-size: 13px;
    animation: cardAppear 0.22s ease-out;
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.country-preview-header {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.country-preview-flag {
    font-size: 32px;
    margin-right: 10px;
}

.country-preview-name {
    font-weight: bold;
    font-size: 16px;
}

.country-preview-language,
.country-preview-level,
.country-preview-count {
    font-size: 13px;
    margin-bottom: 2px;
}

.country-lessons-list {
    margin-top: 4px;
    font-size: 13px;
}

.country-lessons-list ul {
    margin: 4px 0 0 18px;
    padding: 0;
}

.country-lesson-item {
    cursor: pointer;
    text-decoration: underline;
}

.country-lesson-item:hover {
    color: #0a246a;
}

/* Общие системные блоки */

.system-message {
    margin-top: 10px;
    padding: 6px;
    border: 2px solid #808080;
    background: #ffffe1;
    font-size: 13px;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out, color 0.2s ease-out;
}

/* Прогресс */

.progress-summary {
    margin-top: 10px;
}

.profile-box {
    margin-top: 10px;
    padding: 8px;
    border: 2px solid #808080;
    background: #f5f5f5;
    font-size: 14px;
}

.profile-input,
.profile-select {
    margin-top: 4px;
    padding: 4px 6px;
    border: 2px solid #808080;
    background: #ffffff;
    font-size: 13px;
    box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #808080 inset;
}

.profile-input {
    max-width: 220px;
}

.profile-select {
    max-width: 260px;
}

.progress-bar {
    margin-top: 6px;
    height: 10px;
    background: #d0d0d0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #0a8a2a;
    width: 0;
    transition: width 0.25s ease-out;
}

/* Урок */

.dialogue-block {
    border: 2px solid #808080;
    background: #f5f5f5;
    padding: 10px;
    margin-bottom: 12px;
    line-height: 1.5;
    font-size: 15px;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out;
}

.replica {
    margin-bottom: 8px;
}

.speaker {
    font-weight: bold;
    margin-bottom: 2px;
}

.english-line {
    margin-bottom: 2px;
}

.russian-line {
    font-size: 14px;
    font-style: italic;
    color: #555;
}

.word {
    padding: 1px 2px;
    border-radius: 2px;
    cursor: pointer;
}

.word:hover {
    background: #ffff99;
}

#word-translation-box {
    margin-top: 8px;
    padding: 8px 10px;
    border: 2px solid #808080;
    background: #ffffff;
    font-size: 15px;
    min-height: 24px;
    line-height: 1.4;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out, color 0.2s ease-out, box-shadow 0.2s ease-out;
}

#word-translation-box.translation-animate {
    animation: translationPulse 0.25s ease-out;
}

@keyframes translationPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(10, 36, 106, 0.7);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(10, 36, 106, 0);
    }
}

/* тултип перевода */

.translation-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.88);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 15px;
    line-height: 1.4;
    max-width: 320px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
}

/* Грамматика */

.grammar-block {
    margin-top: 10px;
    padding: 8px 10px;
    border: 2px solid #808080;
    background: #fff7e6;
    font-size: 14px;
    line-height: 1.5;
}

.grammar-title {
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 14px;
}

.grammar-content p {
    margin: 0 0 4px;
}

.grammar-content ul {
    margin: 4px 0 0 18px;
    padding: 0;
}

.grammar-content li {
    margin-bottom: 2px;
}

/* Квиз */

.quiz {
    margin-top: 10px;
    padding: 8px;
    border: 2px solid #808080;
    background: #f0f0ff;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out, transform 0.2s ease-out;
}

.quiz-options {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.quiz-button {
    padding: 4px 10px;
    border: 2px solid #808080;
    background: #d4d0c8;
    cursor: pointer;
    font-size: 13px;
    box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #808080 inset;
}

.quiz-button:active {
    box-shadow: -1px -1px 0 #fff inset, 1px 1px 0 #808080 inset;
}

.quiz-button-correct {
    background: #cce8c6;
    animation: quizCorrect 0.25s ease-out;
}

.quiz-button-wrong {
    background: #f1c0c0;
    animation: quizWrong 0.25s ease-out;
}

@keyframes quizCorrect {
    0% {
        transform: scale(0.97);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes quizWrong {
    0% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(-3px);
    }
    100% {
        transform: translateX(0);
    }
}

.quiz-shake {
    animation: quizShake 0.25s ease-out;
}

@keyframes quizShake {
    0% {
        transform: translateX(0);
    }
    20% {
        transform: translateX(-3px);
    }
    40% {
        transform: translateX(3px);
    }
    60% {
        transform: translateX(-2px);
    }
    80% {
        transform: translateX(2px);
    }
    100% {
        transform: translateX(0);
    }
}

.quiz-input {
    margin-top: 4px;
    padding: 6px 8px;
    border: 2px solid #808080;
    background: #ffffff;
    font-size: 14px;
    max-width: 320px;
    width: 100%;
    box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #808080 inset;
}

.quiz-check-button {
    margin-left: 6px;
    margin-top: 6px;
}

#quiz-feedback {
    margin-top: 6px;
    font-size: 13px;
}

.mini-window {
    margin-top: 10px;
    padding: 8px;
    border: 2px solid #000;
    background: #d4d0c8;
    box-shadow: 0 0 0 1px #fff inset;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out, box-shadow 0.2s ease-out;
}

.mini-window:not(.hidden) {
    animation: miniPop 0.22s ease-out;
}

@keyframes miniPop {
    0% {
        transform: scale(0.95) translateY(4px);
        opacity: 0;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.mini-window-title {
    background: #000080;
    color: #fff;
    padding: 2px 4px;
    font-size: 12px;
    margin: -8px -8px 6px -8px;
}

#lesson-success-next {
    margin-top: 6px;
}

#lesson-success-next .primary-button {
    font-size: 13px;
    padding: 4px 10px;
}

/* Достопримечательность */

.place-block {
    margin-top: 10px;
}

.place-card {
    margin-top: 8px;
    border: 2px solid #808080;
    background: #f5f5f5;
    padding: 10px;
    box-shadow: 0 0 0 1px #fff inset;
    transition: background-color 0.2s ease-out, border-color 0.2s ease-out, box-shadow 0.2s ease-out;
    max-width: 640px;
}

.place-card.place-card-open {
    animation: placeDrop 0.22s ease-out;
}

@keyframes placeDrop {
    0% {
        opacity: 0;
        transform: translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.place-card-title {
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 15px;
}

.place-card-body {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.place-card-body img {
    max-width: 160px;
    border-radius: 2px;
    border: 1px solid #808080;
    display: block;
}

.place-card-body p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.hidden {
    display: none;
}

/* Тёмная тема */

body.theme-dark {
    background: #000000;
    color: #e0e0e0;
}

body.theme-dark .window {
    background: #1e1e24;
    border-color: #000;
    box-shadow: 0 0 0 1px #444 inset;
}

body.theme-dark .window-titlebar {
    background: linear-gradient(to right, #000000, #333333);
}

body.theme-dark .window-menu {
    background: #262626;
    border-bottom-color: #555;
}

body.theme-dark .window-toolbar {
    background: #262626;
    border-bottom-color: #555;
}

body.theme-dark .sidebar {
    background: #202020;
    border-right-color: #555;
}

body.theme-dark .sidebar h4 {
    color: #c0d0ff;
}

body.theme-dark .main-area {
    background: #1b1b1f;
}

body.theme-dark .country-preview {
    background: #242433;
    border-color: #555;
}

body.theme-dark .country-item {
    background: #2b2b33;
    border-color: #555;
}

body.theme-dark .country-item.selected {
    background: #39405a;
}

body.theme-dark .country-list-title {
    color: #c0d0ff;
}

body.theme-dark .system-message {
    background: #35351f;
    border-color: #777;
    color: #f0f0c0;
}

body.theme-dark .dialogue-block {
    background: #24242c;
    border-color: #555;
}

body.theme-dark .russian-line {
    color: #aaaaaa;
}

body.theme-dark #word-translation-box {
    background: #202026;
    border-color: #666;
    color: #f2f2f2;
}

body.theme-dark .quiz {
    background: #24243a;
    border-color: #666;
}

body.theme-dark .mini-window {
    background: #2a2a32;
    border-color: #000;
    box-shadow: 0 0 0 1px #555 inset;
}

body.theme-dark .mini-window-title {
    background: #181845;
}

body.theme-dark .place-card {
    background: #24242c;
    border-color: #666;
    box-shadow: 0 0 0 1px #555 inset;
}

body.theme-dark .place-card-body img {
    border-color: #666;
}

body.theme-dark .profile-box {
    background: #24242c;
    border-color: #666;
}

body.theme-dark .progress-bar {
    background: #333;
}

body.theme-dark .progress-bar-fill {
    background: #36c26b;
}

body.theme-dark .grammar-block {
    background: #3a3120;
    border-color: #777;
}

body.theme-dark .profile-input,
body.theme-dark .profile-select {
    background: #202026;
    color: #f2f2f2;
    border-color: #666;
    box-shadow: 1px 1px 0 #000 inset, -1px -1px 0 #444 inset;
}

/* Мобильная адаптация */

@media (max-width: 768px) {

    body {
        background: #d4d0c8; /* чтобы зелёный фон не торчал по краям */
    }

    body.theme-dark {
        background: #000;
    }

    .window {
        margin: 0;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    .window-body {
        flex-direction: column;
    }

    .sidebar {
        display: none;
    }

    .window-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .logo-area img {
        height: 28px;
    }

    .top-nav {
        flex-wrap: wrap;
        gap: 6px;
    }

    .nav-button,
    .primary-button,
    .quiz-button,
    .secondary-button {
        font-size: 15px;
        padding: 8px 14px;
    }

    .main-area {
        padding: 8px;
    }

    h1 {
        font-size: 20px;
    }

    h2 {
        font-size: 18px;
    }

    .dialogue-block {
        font-size: 14px;
    }

    .country-layout {
        flex-direction: column;
    }

    .country-lists {
        width: 100%;
        max-width: none;
    }

    .country-preview {
        margin-top: 8px;
    }

    .country-item {
        padding: 10px 12px;
    }

    #lesson-success {
        font-size: 14px;
    }

    .place-card {
        max-width: 100%;
    }

    .place-card-body {
        flex-direction: column;
    }

    .place-card-body img {
        max-width: 100%;
    }

    .profile-input,
    .profile-select {
        width: 100%;
        max-width: 100%;
    }
}
