/* ===================== Дизайн v2: перекриває базові стилі app.css ===================== */
:root {
  --bg: #f3f5fa; --card: #fff; --text: #1d2433; --muted: #6a7385; --line: #e3e7ef; --line-2: #d3d9e4;
  --sel: #e3f3ff; --shadow: 0 1px 2px rgba(20,30,60,.05), 0 6px 20px rgba(20,30,60,.06); --radius: 18px;
  --c1: #58cc02; --c2: #1cb0f6; --soft: rgba(28,176,246,.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f1a1f; --card: #172429; --line: #26363d; --line-2: #31444c; --sel: #15364a; --shadow: 0 1px 0 rgba(255,255,255,.03), 0 8px 24px rgba(0,0,0,.25); --soft: rgba(28,176,246,.14); }
}
:root[data-theme="dark"] { --bg: #0f1a1f; --card: #172429; --line: #26363d; --line-2: #31444c; --sel: #15364a; --shadow: 0 1px 0 rgba(255,255,255,.03), 0 8px 24px rgba(0,0,0,.25); --soft: rgba(28,176,246,.14); }

body { font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-weight: 600; letter-spacing: .1px; }
h1 { font-size: 1.75rem; font-weight: 900; letter-spacing: -.3px; }
h2 { font-size: 1.15rem; font-weight: 800; }
b, strong { font-weight: 800; }
.page { padding: 20px 16px 28px; }

/* Картки */
.card { border: 1.5px solid var(--line); box-shadow: var(--shadow); transition: transform .15s, border-color .15s, box-shadow .15s; }
a.card:hover, .mode:hover { transform: translateY(-2px); border-color: var(--blue); }
a.card:active, .mode:active { transform: translateY(0); }
.card.hero { background: linear-gradient(135deg, #58cc02 0%, #20b8a8 55%, #1cb0f6 100%); box-shadow: 0 10px 30px rgba(28,176,246,.25); }
.card.hero .ico { background: rgba(255,255,255,.22); }
.ico { width: 48px; height: 48px; flex: none; border-radius: 14px; display: grid; place-items: center; font-size: 1.55rem; background: var(--soft); }
.ring { width: 46px; height: 46px; } .ring span { width: 36px; height: 36px; }
.pill { font-weight: 700; }
.btn { font-weight: 800; border-radius: 16px; }
.btn.primary { box-shadow: 0 4px 0 var(--brand-d); border-bottom-width: 2px; }
.btn.primary:active { box-shadow: 0 1px 0 var(--brand-d); transform: translateY(3px); }

/* Шапка зі статистикою */
.top-stats { border: 1.5px solid var(--line); box-shadow: var(--shadow); padding: 12px 16px; }
.stat b { font-weight: 900; }
.greet { margin: 20px 0 14px; }
.greet h1 { margin: 0; }
.greet p { margin: 2px 0 0; }

/* Курси: кольорова плашка */
.course { position: relative; overflow: hidden; padding-left: 20px; }
.course::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: linear-gradient(var(--c1), var(--c2)); }
.course .ico { background: linear-gradient(135deg, var(--c1), var(--c2)); color: #fff; font-weight: 900; font-size: 1.3rem; }
.course-hero { border-radius: 22px; padding: 18px 20px 20px; color: #fff; background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: var(--shadow); margin-bottom: 8px; }
.course-hero h1 { margin: 6px 0 4px; color: #fff; }
.course-hero .small { opacity: .92; }
.course-hero .bar { background: rgba(255,255,255,.3); height: 10px; margin: 12px 0 14px; }
.course-hero .bar-fill { background: #fff; }
.course-hero .btn { background: #fff; color: #1d2433; border-color: rgba(0,0,0,.08); box-shadow: 0 4px 0 rgba(0,0,0,.14); }
.back { color: inherit; display: inline-flex; align-items: center; gap: 6px; font-weight: 800; opacity: .9; background: none; border: 0; font: inherit; cursor: pointer; padding: 0; }
.module-head { display: flex; align-items: center; gap: 10px; margin: 24px 0 10px; font-weight: 900; color: var(--muted); text-transform: uppercase; font-size: .8rem; letter-spacing: .8px; }
.module-head::after { content: ""; flex: 1; height: 1.5px; background: var(--line); }
.card.next { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(88,204,2,.18), var(--shadow); }
.tag { display: inline-block; font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; padding: 2px 8px; border-radius: 99px; background: var(--brand); color: #fff; margin-left: 6px; vertical-align: 2px; }
.lesson-num { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 900; background: var(--soft); color: var(--blue); }
.lesson-num.done { background: var(--brand); color: #fff; }

/* Словник */
.stats { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats > div { border: 1.5px solid var(--line); box-shadow: var(--shadow); padding: 10px 4px; }
.stats b { font-weight: 900; }
.mode { border: 1.5px solid var(--line); box-shadow: var(--shadow); padding: 14px; gap: 4px; transition: transform .15s, border-color .15s; }
.mode .ico { width: 42px; height: 42px; font-size: 1.3rem; margin-bottom: 4px; }
.word-row { border: 1.5px solid var(--line); }
.search { border-width: 1.5px; box-shadow: var(--shadow); }

/* Нижнє меню / бокова панель на ПК */
#tabs { border-top: 1.5px solid var(--line); box-shadow: 0 -6px 20px rgba(20,30,60,.06); }
#tabs a { gap: 2px; font-size: .68rem; font-weight: 800; position: relative; }
#tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.active svg { stroke-width: 2.4; }
#tabs a.active { color: var(--brand-d); }
#tabs .brand { display: none; }
.tab-badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font-style: normal; font-size: .66rem; display: grid; place-items: center; }
@media (min-width: 900px) {
  body { padding: 0 0 0 232px; }
  #tabs { top: 0; bottom: 0; right: auto; width: 232px; max-width: none; margin: 0; flex-direction: column; gap: 4px; padding: 20px 14px; border: 0; border-right: 1.5px solid var(--line); border-radius: 0; box-shadow: none; }
  #tabs a { flex: none; flex-direction: row; justify-content: flex-start; gap: 14px; padding: 11px 14px; border-radius: 14px; font-size: .98rem; color: var(--text); }
  #tabs a:hover { background: var(--sel); }
  #tabs a.active { background: var(--sel); color: var(--blue); }
  #tabs .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-size: 1rem; line-height: 1.1; color: var(--text); }
  #tabs .brand:hover { background: none; }
  #tabs .brand img { width: 40px; height: 40px; }
  #tabs .brand b { color: var(--brand-d); }
  .tab-badge { position: static; margin-left: auto; }
  .page { padding-top: 28px; }
  .session { min-height: calc(100vh - 56px); }
  .toast { bottom: 30px; }
}

/* Урок */
.lesson { padding-top: 0; }
.lesson-top { gap: 10px; padding: 10px 12px 8px; margin: 0 -16px; border-bottom: 1.5px solid var(--line); }
.lesson-top .t { flex: 1; min-width: 0; }
.lesson-top .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-progress { height: 6px; margin-top: 6px; }
.toc-btn { border: 1.5px solid var(--line); background: var(--card); color: var(--text); border-radius: 12px; padding: 7px 11px; font: inherit; font-weight: 800; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.toc-btn:hover { border-color: var(--blue); }
.steps { gap: 6px; padding: 10px 0 6px; }
.step { width: 30px; height: 30px; font-size: .78rem; font-weight: 900; color: var(--muted); border-width: 1.5px; font-family: inherit; }
.step.info { opacity: 1; border-style: dashed; }
.step.done { color: #7a5a00; }
.step.perfect { color: #2b7a0b; }
.step.cur { outline: none; background: var(--blue); border-color: var(--blue); color: #fff; }
.toc { position: fixed; inset: 0; z-index: 40; background: rgba(10,15,25,.45); display: flex; align-items: flex-end; justify-content: center; }
.toc-panel { background: var(--card); width: 100%; max-width: 560px; max-height: 80vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 14px 10px calc(14px + env(safe-area-inset-bottom)); }
.toc-panel h3 { margin: 4px 10px 8px; font-weight: 900; }
@media (min-width: 900px) { .toc { align-items: center; } .toc-panel { border-radius: 22px; } }
.toc-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-weight: 700; padding: 9px 8px; border-radius: 12px; cursor: pointer; }
.toc-item:hover, .toc-item.cur { background: var(--sel); }
.toc-item .step { flex: none; pointer-events: none; }
.toc-item small { display: block; color: var(--muted); font-weight: 600; }
.sec-head { margin-top: 14px; }
.badge { font-weight: 800; }
.lesson h2 { font-size: 1.35rem; font-weight: 900; margin: 10px 0 4px; }
.sec-body { margin-top: 12px; }
.sec-nav { position: sticky; bottom: 0; z-index: 4; margin: 24px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-top: 1.5px solid var(--line); }
.sec-nav .btn { flex: 1; max-width: 240px; }
.reading { border-width: 1.5px; box-shadow: var(--shadow); }
.rule { border-width: 1.5px; box-shadow: var(--shadow); }
.items li { line-height: 2.1; }
input.gap { width: var(--w, 9ch); min-width: 5ch; max-width: 100%; font-weight: 700; text-align: center; border-radius: 8px 8px 0 0; }
.bank { position: sticky; top: 8px; z-index: 3; background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(6px); border-style: solid; border-width: 1.5px; box-shadow: var(--shadow); }
.chip { font-weight: 700; }
.option { border-width: 1.5px; border-bottom-width: 3.5px; font-weight: 700; }
.tile { border-width: 1.5px; border-bottom-width: 3.5px; font-weight: 700; }
.q-title { font-weight: 900; }
.q-sent, .q-def { border-width: 1.5px; box-shadow: var(--shadow); }
.answer-input { border-width: 1.5px; font-weight: 700; }
.word-card, .flash { border-width: 1.5px; box-shadow: var(--shadow); }
.result-banner { box-shadow: var(--shadow); }

.goal .bar { flex: none; height: 10px; }
.lbl-full { display: none; }
@media (min-width: 900px) { .lbl-full { display: inline; } .lbl-short { display: none; } }

input.gap { height: 1.9em; padding: 0 6px; vertical-align: baseline; }

body.no-nav { padding-left: 0; padding-bottom: 0; }
#tabs a span.lbl-full, #tabs a span.lbl-short { font-size: inherit; }

.sec-img { max-height: 46vh; object-fit: contain; }
.module-head .mh-link { order: 2; text-transform: none; letter-spacing: 0; font-size: .85rem; color: var(--blue); font-weight: 800; }
.module-head::after { order: 1; }

/* Пошук + вибір порядку слів в одному рядку */
.search-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 10px; }
.search-row .search { flex: 1; min-width: 0; margin: 0; }
.sort-sel { max-width: 44%; padding: 0 10px; border-width: 1.5px; border-radius: 14px; box-shadow: var(--shadow); cursor: pointer; }
@media (max-width: 480px) { .sort-sel { max-width: 40%; font-size: 13px; } }
input.gap.long { display: block; width: 100%; margin: 6px 0 2px; text-align: left; }

/* Акаунт */
.account .avatar { width: 44px; height: 44px; border-radius: 50%; }
.account .gbtn { min-height: 44px; }

/* Немає світла: картка з графіком відключень */
.card.power { display: block; border: 1.5px solid #f59e0b; background: color-mix(in srgb, #f59e0b 10%, var(--card)); }
.card.power.offline { border-color: var(--line); background: var(--card); }
.card.power > * + * { margin-top: 6px; }
.gpv-bar { display: grid; grid-template-columns: repeat(48, 1fr); gap: 1px; margin: 8px 0 2px; position: relative; }
.gpv-s { height: 16px; background: #22c55e; border-radius: 2px; }
.gpv-s.off { background: #ef4444; }
.gpv-s.maybe { background: #f59e0b; }
.gpv-s.now { outline: 2px solid var(--text); outline-offset: 1px; z-index: 1; }
.gpv-ticks { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 11px; opacity: .7; }

/* Користувач: аватар у шапці, блок у боковій панелі */
.avatar.sm { width: 30px; height: 30px; border-radius: 50%; flex: none; object-fit: cover; }
.avatar.letter { display: inline-grid; place-items: center; background: var(--blue); color: #fff; font-weight: 800; }
.user-chip { position: relative; display: inline-flex; align-items: center; text-decoration: none; flex: none; }
.user-chip .priv { position: absolute; right: -6px; bottom: -4px; font-size: 11px; font-style: normal; }
.user-chip.login { padding: 5px 12px; border-radius: 999px; border: 1.5px solid var(--blue); color: var(--blue); font-weight: 800; font-size: 13px; }
#tabs .me { display: none; }
@media (min-width: 900px) {
  #tabs .me:not([hidden]) { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding: 8px 10px; border-radius: 14px; background: var(--sel); text-decoration: none; color: var(--text); font-weight: 800; }
  #tabs .me span { display: flex; flex-direction: column; line-height: 1.15; }
  #tabs .me small { font-weight: 600; font-size: 11px; opacity: .7; }
}
.priv-toggle { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.priv-toggle input { margin-top: 4px; }
.priv-toggle span { display: flex; flex-direction: column; gap: 2px; }

/* Рейтинг */
.board .board-tabs { margin-bottom: 4px; }
.board .board-tabs a { cursor: pointer; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 12px; }
.board-row + .board-row { border-top: 1px solid var(--line); }
.board-row.me { background: var(--sel); }
.board-row .place { width: 28px; text-align: center; font-weight: 900; }
.board-row .xp { white-space: nowrap; }
.board .seg { background: var(--sel); margin-top: 0; }
.board .seg a { color: var(--text); }
.board .seg a.on { background: var(--blue); color: #fff; }
.account .priv-toggle { justify-content: flex-start; text-align: left; }
