/* Тема берётся из нативных переменных Telegram. Есть запасные значения для
   открытия вне Telegram. */
:root {
    --bg:      var(--tg-theme-bg-color, #ffffff);
    --sec-bg:  var(--tg-theme-secondary-bg-color, #f1f3f5);
    --text:    var(--tg-theme-text-color, #1c1c1c);
    --hint:    var(--tg-theme-hint-color, #8a8f98);
    --link:    var(--tg-theme-link-color, #2481cc);
    --button:  var(--tg-theme-button-color, #2481cc);
    --btn-txt: var(--tg-theme-button-text-color, #ffffff);
    --accent:  #e8590c;
    --success: #2f9e44;
    --danger:  #e03131;
    --warn:    #f08c00;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать display:flex у .container,
   иначе все экраны показываются стопкой. */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    /* Защита контента: запрет выделения текста. */
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 18px 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.screen { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

h1 { font-size: 22px; margin: 0 0 18px; }
.muted { color: var(--hint); font-size: 14px; line-height: 1.5; }
.counter { margin-bottom: 12px; font-size: 13px; }

.stats {
    display: flex; gap: 8px; margin-bottom: 24px;
}
.stats > div {
    flex: 1; background: var(--sec-bg); border-radius: 12px; padding: 12px 4px;
    display: flex; flex-direction: column; gap: 2px;
}
.stats span { font-size: 22px; font-weight: 700; }
.stats small { color: var(--hint); font-size: 11px; }

.btn {
    border: none; border-radius: 12px; padding: 15px 18px;
    font-size: 16px; font-weight: 600; cursor: pointer;
    width: 100%; margin: 7px 0; color: var(--btn-txt);
    background: var(--button); transition: transform .06s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--button); }
.btn-success { background: var(--success); }
.btn-danger  { background: var(--danger); }
.btn-warn    { background: var(--warn); }
.btn-ghost   { background: transparent; color: var(--link); }

.badge {
    background: rgba(255,255,255,.3); border-radius: 10px;
    padding: 2px 9px; font-size: 14px; margin-left: 6px;
}

/* Экран повторения: контент сверху, кнопки — в панели, прибитой к низу.
   Положение кнопок не зависит от длины вопроса/ответа/истории. */
#review-screen {
    justify-content: flex-start;
    padding-top: 32px;
    padding-bottom: 190px; /* место под панель, чтобы контент не уезжал под неё */
}
#learn-screen {
    justify-content: flex-start;
    padding-top: 24px;
    padding-bottom: 110px; /* одна кнопка — панель ниже, чем на повторении */
}
.action-bar {
    position: fixed;
    left: 50%; bottom: 0;
    transform: translateX(-50%);
    width: 100%; max-width: 480px;
    display: flex; flex-direction: column; gap: 10px;
    padding: 12px 18px calc(14px + max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px)));
    background: var(--bg);
    box-shadow: 0 -8px 16px -8px rgba(0, 0, 0, .12);
    z-index: 10;
}
.action-bar .btn { margin: 0; }
/* «Забыл/Помню» и «Дальше» занимают одну и ту же ячейку — не двигаются при смене. */
.slot { display: grid; }
.slot > * { grid-area: 1 / 1; }
/* «Показать ответ» после раскрытия не исчезает, а прячется — место сохраняется. */
#review-show[hidden] { display: block !important; visibility: hidden; }

.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

.ru-word { font-size: 30px; font-weight: 700; margin: 8px 0; }
.en-word { font-size: 26px; font-weight: 700; color: var(--accent); margin: 6px 0 2px; }
.transcription { color: var(--hint); font-size: 16px; margin-bottom: 10px; }
.cue { font-size: 15px; margin-bottom: 8px; }
.question { font-size: 34px; font-weight: 700; margin: 30px 0; }

.story {
    background: var(--sec-bg); border-left: 4px solid var(--warn);
    border-radius: 8px; padding: 14px; text-align: left;
    font-size: 15px; line-height: 1.5; margin: 8px 0 18px;
}

/* Картинка на белом фоне + защита от простого скачивания.
   Прозрачный слой сверху перехватывает долгое нажатие / перетаскивание. */
.img-wrap { position: relative; display: inline-block; margin: 12px auto; }
.img-wrap::after {
    content: ""; position: absolute; inset: 0;
    pointer-events: auto; /* перехват касаний по картинке */
}
.card-img {
    max-width: 100%; max-height: 240px; border-radius: 12px;
    background: #fff; object-fit: contain; display: block;
    -webkit-user-drag: none; user-drag: none; pointer-events: none;
}

.express-card {
    margin-top: 18px; border-radius: 12px; padding: 12px 14px; text-align: left;
    background: linear-gradient(135deg, rgba(240,140,0,.15), rgba(240,140,0,.05));
    border: 1px solid rgba(240,140,0,.3);
}
.express-card .express-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.express-card .express-sub { font-size: 12px; color: var(--hint); margin-bottom: 8px; }
.express-card .btn { margin: 0; }

.blocks-section { margin-top: 22px; text-align: left; }
.blocks-title { font-size: 13px; color: var(--hint); font-weight: 600;
    text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; }

.block-row {
    display: flex; align-items: center; gap: 10px;
    background: var(--sec-bg); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px;
}
.block-row.completed { opacity: .7; }
.block-row input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--button); }
.block-row .block-info { flex: 1; min-width: 0; }
.block-row .block-label { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.block-row .block-progress { font-size: 12px; color: var(--hint); margin-top: 2px; }
.block-row .block-due {
    background: var(--warn); color: #fff; border-radius: 8px;
    padding: 1px 8px; font-size: 12px; font-weight: 600; flex: none;
}
.block-bar { height: 4px; background: rgba(0,0,0,.08); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.block-bar > div { height: 100%; background: var(--success); }

.trial { margin-top: 20px; }

.settings-line {
    margin-top: 14px; display: flex; align-items: center; justify-content: center;
    gap: 8px; font-size: 13px; color: var(--hint);
}
.btn-link {
    background: none; border: none; color: var(--link); font-size: 13px;
    cursor: pointer; padding: 0; text-decoration: underline;
}
.btn-link.danger { color: var(--danger); display: block; margin: 16px auto 0; }
.block-row .block-reset {
    background: none; border: none; color: var(--danger); font-size: 11px;
    cursor: pointer; padding: 0; text-decoration: underline; flex: none;
}
.settings-edit { margin-top: 14px; }
.settings-edit .row { margin-bottom: 8px; }
.time-field {
    flex: 1; font-size: 12px; color: var(--hint); text-align: left;
    display: flex; flex-direction: column; gap: 4px;
}
.time-field input[type="time"] {
    font-size: 16px; padding: 8px; border-radius: 8px; border: 1px solid var(--sec-bg);
    background: var(--sec-bg); color: var(--text);
}
.lock { font-size: 48px; margin-bottom: 8px; }

.spinner {
    width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid var(--sec-bg); border-top-color: var(--link);
    margin: 0 auto 14px; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.notify-field{display:flex;align-items:center;gap:8px;margin:10px 0;font-size:14px}
.notify-field input{width:auto;margin:0}
