/* ============================================================
   Writing Master — mobile-first
   Палитра: Slate (нейтрали) + Indigo (действия), акценты уровней
   ============================================================ */

:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: rgba(30, 41, 59, 0.72);
  --card-solid: #1e293b;
  --stroke: rgba(148, 163, 184, 0.16);
  --stroke-strong: rgba(148, 163, 184, 0.32);
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-2: #818cf8;
  --good: #34d399;
  --good-soft: rgba(52, 211, 153, 0.14);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 34px rgba(2, 6, 23, 0.45);
  /* акценты уровней */
  --lv-a1: #34d399; --lv-a2: #2dd4bf; --lv-b1: #38bdf8; --lv-b2: #818cf8; --lv-c1: #c084fc;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- фоновые орбы ---------- */
.wm-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.wm-bg-orb {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.35;
  animation: orbFloat 24s ease-in-out infinite alternate;
}
.wm-bg-orb--1 { width: 60vmax; height: 60vmax; top: -25vmax; right: -20vmax; background: radial-gradient(circle, #4338ca, transparent 65%); }
.wm-bg-orb--2 { width: 50vmax; height: 50vmax; bottom: -22vmax; left: -18vmax; background: radial-gradient(circle, #0e7490, transparent 65%); animation-delay: -12s; }
@keyframes orbFloat { to { transform: translate3d(4vmax, 3vmax, 0) scale(1.08); } }

/* ---------- шапка ---------- */
.wm-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--stroke);
}
.wm-back {
  display: flex; align-items: center; gap: 5px; text-decoration: none;
  color: var(--text-dim); font-size: 0.82rem; font-weight: 600;
  border: 1px solid var(--stroke-strong); border-radius: 10px;
  padding: 7px 9px; min-height: 36px; box-sizing: border-box;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  flex: 0 0 auto;
}
.wm-back:active { background: var(--accent-soft); }
@media (hover: hover) { .wm-back:hover { color: var(--accent-2); border-color: var(--accent); } }
.wm-back-txt { display: none; }
@media (min-width: 460px) { .wm-back-txt { display: inline; } }
.wm-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-size: 1.02rem; letter-spacing: 0.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.wm-logo-icon { font-size: 1.25rem; }
.wm-logo-text b { color: var(--accent-2); font-weight: 700; }
.wm-crumb { margin-left: auto; font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.wm-crumb a { color: var(--text-dim); text-decoration: none; }
.wm-crumb a:active { color: var(--accent-2); }

/* ---------- каркас ---------- */
.wm-app { max-width: 760px; margin: 0 auto; padding: 18px 16px 40px; min-height: 60dvh; }
.wm-footer { text-align: center; color: var(--text-faint); font-size: 0.74rem; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }

/* ---------- загрузка ---------- */
.wm-loader { display: grid; place-items: center; gap: 8px; padding: 18vh 0; color: var(--text-dim); }
.wm-loader-pen { font-size: 2.4rem; animation: penWrite 1.1s ease-in-out infinite; }
@keyframes penWrite { 0%,100% { transform: rotate(-6deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-6px); } }

/* ---------- появление экранов и секций ---------- */
.wm-view { animation: viewIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.wm-stagger > * { animation: viewIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: calc(var(--i, 0) * 70ms); }

/* ---------- герой главной ---------- */
.wm-hero { text-align: center; padding: 22px 6px 26px; }
.wm-hero h1 {
  margin: 0 0 10px; font-size: clamp(1.7rem, 6.4vw, 2.5rem); line-height: 1.18; letter-spacing: -0.02em;
  background: linear-gradient(120deg, #e2e8f0 30%, var(--accent-2) 70%, #c084fc);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.wm-hero p { margin: 0 auto; max-width: 34em; color: var(--text-dim); font-size: 0.95rem; }

/* ---------- карточки уровней ---------- */
.wm-levels { display: grid; gap: 14px; }
.wm-level-card {
  position: relative; display: block; text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 16px 16px 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform 0.22s ease, border-color 0.22s ease;
  overflow: hidden;
}
.wm-level-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--lv, var(--accent)); border-radius: 4px 0 0 4px; opacity: 0.9;
}
.wm-level-card:active { transform: scale(0.985); }
@media (hover: hover) {
  .wm-level-card:hover { transform: translateY(-3px); border-color: var(--stroke-strong); }
}
.wm-level-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.wm-level-badge {
  font-weight: 800; font-size: 1.05rem; letter-spacing: 0.04em;
  color: var(--lv, var(--accent-2));
  background: color-mix(in srgb, var(--lv, var(--accent)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--lv, var(--accent)) 40%, transparent);
  padding: 3px 10px; border-radius: 999px;
}
.wm-level-name { font-weight: 650; }
.wm-level-exam { margin-left: auto; font-size: 0.72rem; color: var(--text-faint); border: 1px solid var(--stroke); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.wm-level-sub { color: var(--accent-2); font-size: 0.83rem; margin: 0 0 4px; }
.wm-level-desc { color: var(--text-dim); font-size: 0.86rem; margin: 0 0 8px; }
.wm-level-meta { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--text-faint); }
.wm-level-progress { flex: 1; height: 5px; border-radius: 999px; background: rgba(148,163,184,0.18); overflow: hidden; }
.wm-level-progress i { display: block; height: 100%; border-radius: inherit; background: var(--lv, var(--accent)); transition: width 0.6s cubic-bezier(0.22,1,0.36,1); }

/* ---------- список юнитов ---------- */
.wm-units { display: grid; gap: 12px; }
.wm-unit-card {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.wm-unit-card:active { transform: scale(0.985); }
@media (hover: hover) { .wm-unit-card:hover { transform: translateX(4px); border-color: var(--stroke-strong); } }
.wm-unit-icon {
  flex: 0 0 44px; height: 44px; display: grid; place-items: center; font-size: 1.35rem;
  background: var(--accent-soft); border-radius: var(--radius-sm);
}
.wm-unit-body { min-width: 0; }
.wm-unit-title { font-weight: 650; font-size: 0.95rem; }
.wm-unit-tags { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.wm-tag { font-size: 0.68rem; color: var(--text-dim); border: 1px solid var(--stroke); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.wm-unit-check { margin-left: auto; font-size: 1.1rem; opacity: 0; transform: scale(0.4); transition: 0.3s; }
.wm-unit-card.is-done .wm-unit-check { opacity: 1; transform: none; }
.wm-unit-arrow { margin-left: auto; color: var(--text-faint); }
.wm-unit-card.is-done .wm-unit-arrow { display: none; }

/* ---------- страница юнита ---------- */
.wm-unit-hero { padding: 8px 2px 18px; }
.wm-unit-hero-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.wm-unit-hero h1 { margin: 0 0 6px; font-size: clamp(1.45rem, 5.6vw, 2rem); letter-spacing: -0.01em; line-height: 1.2; }
.wm-unit-hero .wm-goal { color: var(--text-dim); font-size: 0.92rem; margin: 0; max-width: 40em; }
.wm-chip {
  font-size: 0.72rem; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--stroke-strong); color: var(--text-dim); white-space: nowrap;
}
.wm-chip--accent { color: var(--accent-2); border-color: rgba(129, 140, 248, 0.45); background: var(--accent-soft); }

.wm-sections { display: grid; gap: 16px; }
.wm-section {
  background: var(--card); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.wm-section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 1.02rem; font-weight: 700; }
.wm-section-title .n {
  flex: 0 0 26px; height: 26px; display: grid; place-items: center; font-size: 0.78rem;
  background: var(--accent-soft); color: var(--accent-2); border-radius: 8px; font-weight: 700;
}
.wm-lead { color: var(--text-dim); font-size: 0.9rem; margin: 0 0 12px; }

/* intro points */
.wm-points { display: grid; gap: 10px; }
.wm-point { display: flex; gap: 10px; align-items: flex-start; background: rgba(15,23,42,0.45); border: 1px solid var(--stroke); border-radius: var(--radius-sm); padding: 10px 12px; }
.wm-point-icon { font-size: 1.2rem; line-height: 1.3; }
.wm-point b { display: block; font-size: 0.88rem; }
.wm-point p { margin: 2px 0 0; color: var(--text-dim); font-size: 0.84rem; }
.wm-point .ex { display: block; margin-top: 5px; font-size: 0.84rem; color: var(--good); font-style: italic; }

/* structure blocks */
.wm-blocks { display: grid; gap: 8px; }
.wm-block { position: relative; border-left: 3px solid var(--accent); background: rgba(15,23,42,0.45); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 9px 12px; }
.wm-block b { font-size: 0.86rem; color: var(--accent-2); }
.wm-block p { margin: 2px 0 0; font-size: 0.84rem; color: var(--text-dim); }
.wm-block .ex { display: block; margin-top: 4px; font-size: 0.86rem; color: var(--text); font-style: italic; }
.wm-block + .wm-block::before {
  content: "↓"; position: absolute; top: -14px; left: -12px; font-size: 0.7rem; color: var(--text-faint);
}

/* sample (разбор образца) */
.wm-sample-task {
  border: 1px dashed var(--stroke-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 12px; background: rgba(15,23,42,0.5);
}
.wm-sample-task .lbl { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--warn); }
.wm-sample-task .en { margin: 4px 0 0; font-size: 0.9rem; }
.wm-sample-task .ru { margin: 6px 0 0; font-size: 0.8rem; color: var(--text-dim); }
.wm-para { margin-bottom: 12px; }
.wm-para-en {
  background: #f8fafc; color: #1e293b; border-radius: var(--radius-sm) var(--radius-sm) var(--radius-sm) 4px;
  padding: 11px 14px; font-size: 0.93rem; line-height: 1.55;
  font-family: "Iowan Old Style", "Palatino", Georgia, serif;
  box-shadow: 0 4px 14px rgba(2,6,23,0.35);
}
.wm-para-en mark { background: rgba(99, 102, 241, 0.22); color: #3730a3; border-radius: 3px; padding: 0 2px; }
.wm-para-note {
  display: flex; gap: 7px; margin: 6px 0 0 14px; font-size: 0.8rem; color: var(--text-dim);
  border-left: 2px solid var(--accent); padding-left: 9px;
}
.wm-para-note::before { content: "💡"; font-size: 0.85rem; }

/* phrase bank */
.wm-phrase-group { margin-bottom: 12px; }
.wm-phrase-group:last-child { margin-bottom: 0; }
.wm-phrase-group h4 { margin: 0 0 7px; font-size: 0.82rem; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.05em; }
.wm-phrase {
  display: flex; flex-wrap: wrap; gap: 2px 10px; justify-content: space-between; align-items: baseline;
  padding: 7px 10px; border-radius: 10px; border: 1px solid transparent;
}
.wm-phrase:nth-child(odd) { background: rgba(15,23,42,0.4); }
.wm-phrase .en { font-size: 0.9rem; }
.wm-phrase .ru { font-size: 0.78rem; color: var(--text-faint); }

/* rubric */
.wm-rubric-scales { display: grid; gap: 12px; }
@media (min-width: 620px) { .wm-rubric-scales { grid-template-columns: 1fr 1fr; } }
.wm-scale { border: 1px solid var(--stroke); border-radius: var(--radius-sm); padding: 12px; background: rgba(15,23,42,0.45); }
.wm-scale h4 { margin: 0 0 8px; font-size: 0.86rem; display: flex; align-items: center; gap: 7px; }
.wm-scale h4 .sc { font-size: 0.66rem; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); }
.wm-crit { padding: 6px 0; border-top: 1px dashed var(--stroke); }
.wm-crit:first-of-type { border-top: 0; }
.wm-crit b { font-size: 0.82rem; }
.wm-crit .ru-name { color: var(--text-faint); font-size: 0.76rem; }
.wm-crit p { margin: 2px 0 0; font-size: 0.79rem; color: var(--text-dim); }
.wm-rubric-tip { margin: 12px 0 0; font-size: 0.82rem; color: var(--warn); background: var(--warn-soft); border: 1px solid rgba(251,191,36,0.25); border-radius: var(--radius-sm); padding: 9px 12px; }

/* pitfalls */
.wm-pitfalls { display: grid; gap: 10px; }
.wm-pitfall { border: 1px solid var(--stroke); border-radius: var(--radius-sm); overflow: hidden; }
.wm-pitfall .wrong, .wm-pitfall .right { display: flex; gap: 8px; padding: 8px 12px; font-size: 0.88rem; align-items: baseline; }
.wm-pitfall .wrong { background: var(--bad-soft); color: #fca5a5; text-decoration: line-through; text-decoration-thickness: 1px; }
.wm-pitfall .right { background: var(--good-soft); color: #6ee7b7; }
.wm-pitfall .wrong::before { content: "✗"; text-decoration: none; }
.wm-pitfall .right::before { content: "✓"; }
.wm-pitfall .why { padding: 7px 12px; font-size: 0.78rem; color: var(--text-dim); background: rgba(15,23,42,0.4); }

/* ---------- упражнения ---------- */
.wm-ex { border: 1px solid rgba(129,140,248,0.3); }
.wm-ex-instr { font-size: 0.86rem; color: var(--text-dim); margin: 0 0 12px; }
.wm-ex-feedback { min-height: 24px; margin-top: 10px; font-size: 0.86rem; font-weight: 600; transition: 0.3s; }
.wm-ex-feedback.ok { color: var(--good); animation: pop 0.35s ease; }
.wm-ex-feedback.bad { color: var(--bad); animation: shake 0.4s ease; }
@keyframes pop { 0% { transform: scale(0.7); } 60% { transform: scale(1.12); } 100% { transform: none; } }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* sort */
.wm-sort-list { display: grid; gap: 8px; }
.wm-sort-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: rgba(15,23,42,0.55); border: 1px solid var(--stroke-strong); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 12px; font-size: 0.88rem; cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
  font-family: inherit; min-height: 44px;
}
.wm-sort-item .num { flex: 0 0 24px; height: 24px; display: grid; place-items: center; font-size: 0.74rem; border-radius: 7px; background: var(--accent-soft); color: var(--accent-2); font-weight: 700; }
.wm-sort-item.is-picked { border-color: var(--accent); background: var(--accent-soft); }
.wm-sort-item.is-ok { border-color: var(--good); background: var(--good-soft); cursor: default; }
.wm-sort-item.is-bad { animation: shake 0.4s ease; border-color: var(--bad); }
.wm-sort-item:active { transform: scale(0.98); }

/* binary (register) */
.wm-bin-card {
  background: rgba(15,23,42,0.55); border: 1px solid var(--stroke-strong); border-radius: var(--radius-sm);
  padding: 14px; text-align: center; font-size: 0.95rem; margin-bottom: 12px; min-height: 64px;
  display: grid; place-items: center; transition: transform 0.25s, opacity 0.25s;
}
.wm-bin-card.swipe-out { transform: translateX(60px) rotate(4deg); opacity: 0; }
.wm-bin-btns { display: flex; gap: 10px; }
.wm-bin-btn {
  flex: 1; min-height: 46px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 650;
  font-family: inherit; cursor: pointer; border: 1px solid var(--stroke-strong);
  background: var(--bg-soft); color: var(--text); transition: transform 0.15s, background 0.2s;
}
.wm-bin-btn:active { transform: scale(0.96); }
.wm-bin-btn.ok { background: var(--good-soft); border-color: var(--good); }
.wm-bin-btn.bad { background: var(--bad-soft); border-color: var(--bad); }
.wm-bin-progress { font-size: 0.74rem; color: var(--text-faint); text-align: center; margin-top: 8px; }

/* gaps */
.wm-gap-item { margin-bottom: 14px; }
.wm-gap-item:last-child { margin-bottom: 0; }
.wm-gap-sentence { font-size: 0.93rem; margin: 0 0 8px; }
.wm-gap-slot {
  display: inline-block; min-width: 68px; border-bottom: 2px dashed var(--accent-2);
  text-align: center; color: var(--accent-2); font-weight: 650; padding: 0 4px;
  transition: 0.25s;
}
.wm-gap-slot.filled-ok { border-bottom-style: solid; border-color: var(--good); color: var(--good); animation: pop 0.3s ease; }
.wm-gap-options { display: flex; flex-wrap: wrap; gap: 8px; }
.wm-gap-opt {
  min-height: 40px; padding: 6px 14px; border-radius: 999px; font-size: 0.86rem; font-family: inherit;
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--stroke-strong); cursor: pointer;
  transition: transform 0.15s, border-color 0.2s, opacity 0.2s;
}
.wm-gap-opt:active { transform: scale(0.94); }
.wm-gap-opt.is-bad { animation: shake 0.4s ease; border-color: var(--bad); }
.wm-gap-opt.is-used { opacity: 0.35; pointer-events: none; }

/* ---------- финальное задание ---------- */
.wm-task { border: 1px solid rgba(129,140,248,0.45); background: linear-gradient(160deg, rgba(67,56,202,0.22), rgba(30,41,59,0.75)); }
.wm-task-prompt {
  background: #f8fafc; color: #1e293b; border-radius: var(--radius-sm); padding: 13px 15px;
  font-size: 0.93rem; font-family: "Iowan Old Style", "Palatino", Georgia, serif;
  box-shadow: 0 4px 14px rgba(2,6,23,0.35); margin-bottom: 10px; white-space: pre-line;
}
.wm-task-note { font-size: 0.8rem; color: var(--text-dim); margin: 0 0 12px; }
.wm-task-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.wm-check { display: grid; gap: 7px; margin: 0 0 14px; padding: 0; list-style: none; }
.wm-check li { display: flex; gap: 8px; font-size: 0.85rem; color: var(--text-dim); align-items: baseline; }
.wm-check li::before { content: "☐"; color: var(--accent-2); }
.wm-task-targets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.wm-target { font-size: 0.76rem; padding: 4px 10px; border-radius: 999px; background: var(--good-soft); border: 1px solid rgba(52,211,153,0.35); color: #6ee7b7; }
.wm-task-cta {
  display: flex; width: 100%; min-height: 52px; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; font-size: 1rem; font-weight: 700; font-family: inherit; cursor: pointer;
  color: #fff; background: linear-gradient(120deg, #6366f1, #8b5cf6);
  box-shadow: 0 10px 26px rgba(99, 102, 241, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.wm-task-cta:active { transform: scale(0.98); }
@media (hover: hover) { .wm-task-cta:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(99,102,241,0.45); } }

/* ---------- низ юнита ---------- */
.wm-unit-nav { display: flex; gap: 10px; margin-top: 20px; }
.wm-btn-ghost {
  flex: 1; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 14px; border: 1px solid var(--stroke-strong); background: transparent;
  color: var(--text-dim); font-size: 0.88rem; font-family: inherit; text-decoration: none; cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.wm-btn-ghost:active { border-color: var(--accent); color: var(--accent-2); }
.wm-btn-ghost.is-done { border-color: var(--good); color: var(--good); }

/* ---------- пустое состояние / ошибка ---------- */
.wm-empty { text-align: center; color: var(--text-dim); padding: 12vh 16px; }
.wm-empty .big { font-size: 2.6rem; margin-bottom: 8px; }

/* ---------- планшет/десктоп ---------- */
@media (min-width: 640px) {
  .wm-app { padding: 26px 24px 60px; }
  .wm-levels { grid-template-columns: 1fr 1fr; }
  .wm-hero { padding-top: 36px; }
  .wm-para { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 12px; align-items: start; }
  .wm-para-note { margin: 4px 0 0; }
}
@media (min-width: 900px) {
  .wm-app { max-width: 820px; }
}

/* ============================================================
   AI-тренажёр (оверлей WMTrainer)
   ============================================================ */
.wmt-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: viewIn 0.25s ease both;
}
.wmt-sheet {
  width: 100%; max-width: 720px; max-height: 92dvh;
  background: var(--bg-soft); border: 1px solid var(--stroke-strong); border-bottom: 0;
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column;
  animation: sheetUp 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.wmt-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--stroke);
}
.wmt-head-titles { display: grid; }
.wmt-head-titles b { font-size: 0.98rem; }
.wmt-head-titles span { font-size: 0.76rem; color: var(--text-dim); }
.wmt-close {
  margin-left: auto; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--stroke-strong);
  background: transparent; color: var(--text-dim); font-size: 1rem; cursor: pointer;
}
.wmt-close:active { background: var(--accent-soft); }
.wmt-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.wmt-prompt { margin-bottom: 12px; font-size: 0.88rem; }

.wmt-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.wmt-tab {
  flex: 1; min-height: 44px; border-radius: 12px; font-family: inherit; font-size: 0.88rem; font-weight: 650;
  border: 1px solid var(--stroke-strong); background: transparent; color: var(--text-dim); cursor: pointer;
  transition: 0.2s;
}
.wmt-tab.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }

.wmt-textarea {
  width: 100%; min-height: 160px; resize: none; box-sizing: border-box;
  background: rgba(15, 23, 42, 0.6); color: var(--text);
  border: 1px solid var(--stroke-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; font: inherit; font-size: 0.95rem; line-height: 1.55;
}
.wmt-textarea:focus { outline: none; border-color: var(--accent); }
.wmt-meter { display: flex; justify-content: space-between; margin-top: 6px; font-size: 0.78rem; color: var(--text-faint); }
.wmt-words.is-low { color: var(--warn); }
.wmt-words.is-ok { color: var(--good); font-weight: 650; }
.wmt-words.is-over { color: var(--bad); }
.wmt-hint { font-size: 0.82rem; color: var(--text-dim); }
.wmt-hint.is-warn { color: var(--warn); }
.wmt-submit-wrap { margin-top: 14px; }
.is-shake { animation: shake 0.4s ease; }

/* ожидание */
.wmt-wait { display: grid; place-items: center; gap: 10px; text-align: center; padding: 8vh 8px; color: var(--text-dim); }
.wmt-wait-step { font-size: 0.95rem; color: var(--text); min-height: 1.4em; }
.wmt-wait-bar { width: min(260px, 70%); height: 5px; border-radius: 999px; background: rgba(148,163,184,0.18); overflow: hidden; }
.wmt-wait-bar i { display: block; height: 100%; width: 40%; border-radius: inherit; background: var(--accent); animation: waitSlide 1.4s ease-in-out infinite alternate; }
@keyframes waitSlide { from { margin-left: -10%; } to { margin-left: 70%; } }

/* результат */
.wmt-grade {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  border: 1px solid var(--stroke-strong); border-radius: var(--radius); margin-bottom: 14px;
  background: rgba(15, 23, 42, 0.5);
}
.wmt-grade.is-good { border-color: rgba(52, 211, 153, 0.5); background: var(--good-soft); }
.wmt-grade-num {
  width: 56px; height: 56px; flex: 0 0 56px; display: grid; place-items: center;
  font-size: 1.7rem; font-weight: 800; border-radius: 16px;
  background: var(--accent-soft); color: var(--accent-2);
  animation: pop 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.wmt-grade.is-good .wmt-grade-num { background: rgba(52,211,153,0.2); color: var(--good); }
.wmt-grade b { display: block; font-size: 1rem; }
.wmt-grade span { font-size: 0.78rem; color: var(--text-dim); }

.wmt-scales { display: grid; gap: 12px; margin-bottom: 14px; }
@media (min-width: 620px) { .wmt-scales { grid-template-columns: 1.2fr 1fr; } }
.wmt-bar-row { display: grid; grid-template-columns: 1fr; gap: 3px; padding: 6px 0; border-top: 1px dashed var(--stroke); }
.wmt-bar-row:first-of-type { border-top: 0; }
.wmt-bar-label { font-size: 0.76rem; color: var(--text-dim); }
.wmt-bar-label b { color: var(--text); }
.wmt-bar { height: 8px; border-radius: 999px; background: rgba(148,163,184,0.18); overflow: hidden; }
.wmt-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
.wmt-bar-val { font-size: 0.74rem; color: var(--text-faint); justify-self: end; }

.wmt-speedo-box { text-align: center; }
.wmt-speedo { width: min(220px, 80%); }
.wmt-needle { transform-origin: 100px 110px; transition: transform 1.1s cubic-bezier(0.34, 1.4, 0.64, 1); }
.wmt-speedo-num { fill: var(--text); font-size: 26px; font-weight: 800; }
.wmt-ielts-mini { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.wmt-ielts-mini span { font-size: 0.7rem; color: var(--text-dim); border: 1px solid var(--stroke); border-radius: 999px; padding: 2px 8px; }

.wmt-comment {
  background: var(--accent-soft); border: 1px solid rgba(129,140,248,0.4); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 0.88rem; margin-bottom: 14px;
}
.wmt-comment.is-hw { background: var(--good-soft); border-color: rgba(52,211,153,0.4); }
.wmt-block { margin-bottom: 14px; }
.wmt-block h4 { margin: 0 0 8px; font-size: 0.9rem; }
.wmt-strengths { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 0.86rem; color: var(--text-dim); }
.wmt-errors { display: grid; gap: 10px; }
.wmt-improved { font-size: 0.9rem; }
.wmt-improved mark { background: rgba(52, 211, 153, 0.3); color: #065f46; }
.wmt-spoiler { margin-bottom: 14px; }
.wmt-spoiler summary { cursor: pointer; font-size: 0.86rem; color: var(--text-dim); padding: 6px 0; }
.wmt-actions { display: flex; gap: 10px; margin-top: 4px; }

/* конфетти */
.wmt-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.wmt-confetti i {
  position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; opacity: 0.9;
  animation: confettiFall linear both;
}
@keyframes confettiFall {
  to { transform: translateY(105vh) rotate(540deg); opacity: 0.6; }
}

/* ---------- камера ---------- */
.wmc-drop {
  position: relative; border: 2px dashed var(--stroke-strong); border-radius: var(--radius);
  padding: 22px 14px; text-align: center; transition: border-color 0.2s, background 0.2s;
}
.wmc-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.wmc-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.wmc-drop-inner { display: grid; gap: 4px; pointer-events: none; }
.wmc-drop-icon { font-size: 1.9rem; }
.wmc-drop-sub { font-size: 0.76rem; color: var(--text-faint); }
.wmc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.wmc-tile { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--stroke-strong); aspect-ratio: 3/4; animation: pop 0.3s ease both; }
.wmc-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wmc-page { position: absolute; left: 6px; bottom: 6px; font-size: 0.66rem; background: rgba(2,6,23,0.75); padding: 2px 7px; border-radius: 999px; }
.wmc-remove {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 8px;
  border: 0; background: rgba(2,6,23,0.75); color: #fca5a5; cursor: pointer; font-size: 0.8rem;
}
.wmc-msg { min-height: 1.2em; font-size: 0.78rem; color: var(--warn); margin: 8px 0 0; }

/* ---------- баннер ДЗ ---------- */
.wm-hw-banner {
  position: sticky; top: calc(54px + env(safe-area-inset-top)); z-index: 40;
  margin: 0 auto; max-width: 760px;
  background: linear-gradient(120deg, rgba(99, 102, 241, 0.25), rgba(30, 41, 59, 0.9));
  border: 1px solid rgba(129, 140, 248, 0.45); border-radius: 0 0 var(--radius) var(--radius);
  padding: 10px 16px; font-size: 0.84rem; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: viewIn 0.4s ease both;
}
.wm-hw-banner.is-warn { background: var(--warn-soft); border-color: rgba(251,191,36,0.4); }
.wm-hw-banner.is-done { background: var(--good-soft); border-color: rgba(52,211,153,0.45); }

/* десктоп: шторка становится модалкой по центру */
@media (min-width: 640px) {
  .wmt-overlay { align-items: center; padding: 24px; }
  .wmt-sheet { border-radius: 22px; border-bottom: 1px solid var(--stroke-strong); max-height: 88dvh; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
