/* --- Шапка --- */
.learn-page{width:100%;min-width:0;overflow-wrap:anywhere;}
.topbar{ display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin:6px 0 8px; }
.txt-short{ display:none; }
.topbar .spacer{ flex:1; }
.lesson-pill{ gap:8px; min-width:0; max-width:100%; }
.lesson-pill-title{ min-width:0; white-space:normal; overflow-wrap:anywhere; text-align:left; }
.lesson-pill .lesson-learned{ flex:0 0 auto; }
.lesson-pill .chk input{ width:16px; height:16px; }
.center-progress{ text-align:center; font-weight:700; margin-bottom:6px; }
.lang-switch{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:10px; }
.lang-switch > button{min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere;}
#word-view{min-width:0;max-width:100%;overflow-wrap:anywhere;}
/* .lang-btn, .ctrl-btn, .check-btn — единый стандарт кнопок в style.css */

.answer-field{
  display:flex; justify-content:center; align-items:center; gap:6px;
  flex-wrap:wrap; max-width:100%; padding:6px 4px; min-height:56px;
  margin-top:10px; margin-bottom:8px;
}
.answer-cell, .slot{
  width:40px; height:50px; border-radius:10px; border:2px dashed #cbd5e1;
  display:inline-flex; align-items:center; justify-content:center;
  font-size:22px; color:#0f172a; background:#f8fafc;
  flex:0 0 auto;
}
/* [ДОБАВЛЕНО v8.20] интерактивные слоты */
.slot.clickable{ cursor:pointer; border-style:solid; }
.slot.clickable:hover{ background:#e0ecff; border-color:#2563eb; }
.slot.drag-over{ background:#dbeafe; border-color:#2563eb; border-style:solid; transform:scale(1.08); }
.slot.dragging, .letter.dragging{ opacity:.45; }
.pointer-drag-preview{
  position:fixed !important;
  z-index:9999;
  pointer-events:none;
  opacity:.92;
  transform:none !important;
  transition:none !important;
  box-sizing:border-box;
  margin:0 !important;
  box-shadow:0 10px 24px rgba(15,23,42,.28) !important;
  border-color:#2563eb !important;
}

/* Кнопки букв — сетка */
.letter-grid{
  width:auto;
  margin:16px auto 0;
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(50px, max-content));
  gap:10px;
  justify-content:center;
  align-content:center;
  justify-items:center; align-items:center;
}
.letter-btn, .letter{
  width:50px; height:50px; background:#fff; border:1px solid #cbd5e1;
  border-radius:12px; box-shadow:0 2px 6px rgba(0,0,0,.05);
  font-size:22px; font-weight:600; color:#0f172a; cursor:pointer; transition:all .2s;
  display:flex; align-items:center; justify-content:center; line-height:1; padding:0;
}
.letter-btn:hover, .letter:hover{ background:#e0ecff; border-color:#2563eb; transform:scale(1.05); }
.letter.clickable{ cursor:pointer; }
.letter{ touch-action:none; }
/* Долгое нажатие пальцем не должно выделять текст или открывать меню — иначе перетаскивание обрывается */
.letter, .letter-btn, #answer-slots .slot{
  -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; touch-action:none;
}

.builder-controls{ margin-top:10px; }
.controls-row{ display:flex; flex-wrap:wrap; margin:8px 0; gap:10px; }
.controls-row.split{ justify-content:space-between; }
.controls-row.center{ justify-content:center; margin:0; padding:10px 0; }
.nav-row{ display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:10px; margin-top:14px; }
.nav-row > .ctrl-btn{flex:1 1 100px;min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere;}
.nav-row > .del-word-btn{flex:0 0 44px;padding-left:0;padding-right:0;}
.controls-row > button{min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere;}

.answer-field::-webkit-scrollbar{ height:6px; }
.answer-field::-webkit-scrollbar-thumb{ background:#cbd5e1; border-radius:6px; }

.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: #fff; color: #0f172a;
  width: min(560px, 92vw);
  padding: 22px 26px 26px;
  border-radius: 14px; box-shadow: 0 14px 40px rgba(2,6,23,.28);
  border: 1px solid #e2e8f0;
  text-align: left;
  max-height:calc(100vh - 24px);
  max-height:calc(100dvh - 24px);
  overflow-y:auto;
  overflow-wrap:anywhere;
}
.modal-head{ display:flex; justify-content:flex-end; margin:-6px -6px 6px; }
.modal-head-actions{ display:flex; gap:8px; align-items:center; }
.flag-toggle input{ display:none; }
.flag-toggle .icon{
  display:inline-flex; align-items:center; justify-content:center;
  width:34px; height:34px;
  border:1px solid #e2e8f0; border-radius:8px;
  background:#f8fafc; color:#64748b;
  font-size:18px; line-height:1;
  cursor:pointer; user-select:none;
}
.flag-toggle .icon:hover{ background:#eef2ff; }
.flag-toggle input:checked + .icon{
  background:#fef3c7; color:#b45309; border-color:#f59e0b;
}
.close{
  appearance:none; border:none; background:#f1f5f9; color:#0f172a;
  width:34px; height:34px; border-radius:8px; cursor:pointer;
  font-size:20px; line-height:1;
}
.close:hover{ background:#e2e8f0; }
.modal-content p{ margin:8px 0; }
.modal-content strong{ font-weight:700; }

/* Редактируемый текст — нажми чтобы отредактировать на месте */
.editable-text{
  cursor: pointer;
  border-radius: 4px;
  transition: background .15s;
}
.editable-text:hover{ background: #f0f9ff; text-decoration: underline dotted #94a3b8; }

/* Активный contenteditable при инлайн-редактировании */
.inline-editing{
  background: #eff6ff !important;
  border: 1.5px solid #2563eb;
  border-radius: 6px;
  padding: 2px 8px;
  outline: none;
  cursor: text;
  text-decoration: none !important;
  min-width: 60px;
  white-space: pre-wrap;
}

/* Фейерверк */
#fw-canvas{
  position:fixed; inset:0; width:100%; height:100%;
  pointer-events:none; z-index:1200;
}

/* [ИЗМЕНЕНО v8.24] Кнопка аудио-иконки + выравнивание строки с правильным словом */
#modal-line2{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.audio-btn{
  appearance:none; border:1px solid #e2e8f0; background:#f8fafc; color:#0f172a;
  border-radius:10px; cursor:pointer; line-height:1; font-weight:700;
  padding:6px 10px; font-size:14px; transition:transform .15s, background .15s, border-color .15s;
}
.audio-btn.mini{ padding:2px 8px; font-size:12px; border-radius:8px; }
.audio-btn.big{  padding:8px 14px; font-size:18px; border-radius:12px; }
.audio-btn.icon{ width:32px; height:32px; padding:0; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; }
.audio-btn:hover{ background:#eef2ff; border-color:#cbd5e1; transform:translateY(-1px); }
.audio-btn.playing{ transform:scale(1.06); }

@media (max-width:420px){
  .letter-grid{
    grid-template-columns:repeat(auto-fit, minmax(48px, max-content));
    gap:8px;
  }
  .letter-btn, .letter{ width:48px; height:48px; font-size:20px; }
}

/* ── Телефоны и Telegram Mini App: две большие кнопки, урок отдельной строкой ── */
@media (max-width:480px){
  .topbar{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .topbar .spacer{ display:none; }
  .topbar > a.pill-btn{ min-height:48px; font-size:16px; white-space:normal; overflow-wrap:anywhere; min-width:0; }
  .topbar > a.pill-btn:first-child{ grid-column:1; grid-row:1; }
  #next-lesson-btn{ grid-column:2; grid-row:1; }
  .lesson-pill{ grid-column:1 / -1; grid-row:2; justify-content:space-between; min-width:0; }
  .lesson-pill-title{ white-space:normal; overflow-wrap:anywhere; min-width:0; }
}

/* ── Galaxy Fold внешний экран и схожие (~260–340px) ── */
@media (max-width:380px){
  /* Сокращаем текст кнопок — всё на одной строке */
  .txt-full{ display:none; }
  .txt-short{ display:inline; }

  /* Топбар: одна строка, сжатые gap и padding */
  .topbar{ gap:6px; }
  .topbar > a.pill-btn{ font-size:15px; padding:8px 10px; }

  /* Кнопки навигации внизу */
  .nav-row{ gap:6px; }

  /* Модалка — полная ширина */
  .modal-content{ padding:14px 14px 18px; }
}
