/* Shared visual foundation. Theme accents remain owned by terminal.css. */
@import url('../assets/fonts/golos.css?v=3');
@import url('../assets/fonts/hanzi.css?v=1');
:root {
  --sans: 'Golos Text', 'HT Hanzi', 'Segoe UI', sans-serif;
  --cjk: 'HT Hanzi', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --kai: 'HT Kai', 'Kaiti SC', 'STKaiti', 'KaiTi', 'HT Hanzi', serif;   /* 楷体: карточки «как пишется», прописи */
  --line: rgba(196, 218, 239, .18);
  --text-dim: #adbed1;
  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-6: 24px; --space-8: 32px;
}
html { font-size: 16px; scroll-padding-bottom: 100px; }
body { font-family: var(--sans); line-height: 1.5; background-size: 48px 48px; }
body:not(.teacher-page) { --text-dim: #adbed1; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, [role='button'] { touch-action: manipulation; }
button { white-space: normal; overflow-wrap: anywhere; }
button, .btn-ghost, .btn-continue { min-height: 44px; min-width: 44px; }
[role='button'] { min-height: 44px; }
.word-pinyin.blurred { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
input:not([type='checkbox']):not([type='radio']), select { min-height: 48px; }
textarea { min-height: 112px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
h1 { font: 700 32px/1.25 var(--sans); margin: 0 0 16px; overflow-wrap: anywhere; }
h2 { font: 700 22px/1.3 var(--sans); margin: 0 0 12px; }
.ui-icon { width: 22px; height: 22px; flex-shrink: 0; vertical-align: middle; }
.eyebrow { font: 600 14px/1.5 var(--sans); color: var(--text-dim); margin-bottom: 12px; }
.zh-tag { font-family: var(--cjk); }
.pinyin, .hero-card .pinyin, .word-pinyin { font-family: var(--sans); font-size: 18px; line-height: 1.6; }
.word-example .ex-pinyin, .grammar-card .ex-pinyin { font: 400 16px/1.6 var(--sans); color: var(--text-dim); }
.word-example, .example-row, .grammar-card .ru { font-size: 14px; }
.say-btn, .word-example .say-btn, .example-row .say-btn { min-width: 44px; min-height: 44px; }
/* Allow long examples to wrap beside the fixed-size pronunciation button.
   Each ruby word stays together with its pinyin. Shared with the teacher's board. */
.say-row > :not(.say-btn) { min-width: 0; overflow-wrap: anywhere; }
.say-row > .ex-hanzi { flex: 1; }
.match-wrong, .write-shake, .hack-wrong { animation: none; }
.hanzi, .word-hanzi, .quiz-hanzi, .lli-title, body[data-route='home'] .hero-card h1, body[data-route='lesson'] .hero-card h1 { font-family: var(--cjk); }
.hero-card h1 { font-family: var(--sans); }
.panel { border: 1px solid var(--line); border-radius: 16px; padding: 24px; background: var(--panel-solid); backdrop-filter: none; }
.panel + .panel { margin-top: 16px; }
.topbar { width: 100%; max-width: 1488px; margin: 0 auto; padding: 20px 32px; font-family: var(--sans); border-color: var(--line); gap: 16px; }
.topbar-title .glow { font-size: 20px; letter-spacing: -.4px; text-shadow: none; animation: none; color: var(--text); }
.topbar-sub, .topbar-stats .stat small { font-size: 12px; }
.topbar-stats { gap: 24px; align-items: center; }
.topbar-stats b { font-size: 18px; }
.topbar-user { font-size: 14px; max-width: 180px; overflow-wrap: anywhere; }
.stat-chips { cursor: pointer; min-height: 44px; justify-content: center; }
.body-row { max-width: 1488px; margin: auto; gap: 24px; padding: 24px 32px; }
.sidenav { width: 200px; min-width: 200px; padding: 0; position: sticky; top: 24px; align-self: flex-start; }
.sidenav .nav-item { min-height: 64px; width: 100%; border-radius: 12px; padding: 12px 16px; margin-bottom: 8px; font: 500 16px var(--sans); gap: 12px; border-color: transparent; }
.sidenav .nav-item:not(.active):not(:hover) { background: transparent; }
.sidenav .nav-item small { font-size: 12px; margin-top: 3px; }
.sidenav .nav-item.active { background: rgba(var(--accent-rgb), .1); border-color: rgba(var(--accent-rgb), .5); }
.view-root { padding: 0; flex: 1; max-width: 1280px; min-width: 0; animation: none; }
.home-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, .42fr); gap: 24px; align-items: start; }
.home-main, .home-aside { min-width: 0; }
.home-aside:empty { display: none; }
.home-layout:has(.home-aside:empty) { grid-template-columns: 1fr; }
.home-aside .panel { padding: 20px; }
.home-aside .me-head { align-items: flex-start; gap: 12px; }
.home-aside .home-level-art { width: 72px; height: 72px; object-fit: contain; }
.home-aside .me-today { font-size: 14px; }
.mascot-panel { margin: 0 0 24px; align-items: center; gap: 16px; }
.mascot-img { height: 112px; width: 84px; object-fit: contain; animation: none; flex-shrink: 0; }
.mascot-speech { border: 1px solid var(--line); background: var(--panel-solid); border-radius: 16px; padding: 16px 20px; flex: 1; }
.mascot-speech::before { display: none; }
.mascot-name { font-size: 12px; letter-spacing: .08em; margin-bottom: 4px; }
.mascot-line { font-size: 16px; }
.hero-card { position: relative; border-color: rgba(var(--accent-rgb), .35); }
.hero-card h1 { font-size: 32px; line-height: 1.4; }
.hero-card .ru { font-size: 16px; margin: 8px 0 20px; }
.progress-bar { height: 8px; border-radius: 4px; background: rgba(200,220,240,.12); }
.progress-bar > span, .mini-bar > span { transition: width 300ms ease; }
.progress-caption, .shop-note, .badge-desc, .me-today, .me-streak, .me-level, .earn-list, .history-day, .todo-when { font-size: 14px; line-height: 1.5; }
.btn-continue { min-height: 48px; border-radius: 12px; padding: 12px 20px; font: 600 16px/1.4 var(--sans); display: inline-flex; gap: 8px; align-items: center; justify-content: center; color: #07141b; }
.btn-ghost { border-radius: 12px; padding: 10px 16px; border-color: var(--line); font: 500 14px/1.45 var(--sans); }
.btn-ghost[disabled] { opacity: 1; color: var(--text-dim); background: rgba(200,220,240,.04); border-style: dashed; }
.section-grid { gap: 12px; margin-top: 24px; }
.section-tile { border-color: var(--line); border-radius: 12px; padding: 16px; font-size: 14px; }
.section-tile b { font-size: 18px; font-family: var(--sans); }
.todo-panel > .eyebrow { font-size: 22px; font-weight: 700; color: var(--text); }
.todo-item { padding: 16px; border-radius: 12px; min-height: 64px; gap: 12px; }
.todo-all-done { font-size: 14px; color: var(--success); margin-top: 12px; }
.todo-item.done { border-style: solid; border-color: rgba(57,255,136,.22); }
.lesson-list-item { padding: 20px 12px; gap: 16px; border-color: var(--line); }
.lli-main { min-width: 0; }
.lli-title { font-size: 22px; overflow-wrap: anywhere; }
.lli-ru { font-size: 14px; }
.tabs, .shop-tabs, .profile-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.settings-row { flex-wrap: wrap; gap: 12px; }
.settings-row .toggle { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 12px; font-size: 14px; }
/* Глобальное button{overflow-wrap:anywhere} ниже задумано для кнопок с длинным динамическим текстом
   (имена и т.п.) — короткие ярлыки вкладок оно рвёт посреди слова в тесной строке. Эти вкладки — не тот
   случай: словам тут и так некуда переноситься, кроме как между собой. */
.tab, .tab-btn, .shop-tab, .profile-tab { min-height: 44px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; font: 500 14px/1.4 var(--sans); color: var(--text); background: var(--panel-solid); overflow-wrap: normal; word-break: keep-all; hyphens: none; }
.tab.active, .tab-btn.active, .shop-tab.active, .profile-tab.active { background: var(--accent); color: #07141b; border-color: var(--accent); }
.tab .ui-icon, .profile-tab .ui-icon { margin-right: 8px; width: 20px; height: 20px; }
.profile-tabs { margin-bottom: 24px; }
.profile-tab { flex: 1; }
/* На узком экране 4 вкладки равной ширины не всегда помещаются в строку (самое длинное слово —
   «Достижения» — может упираться в край экрана вместо переноса, если браузер/масштаб шрифта
   устройства отличается от расчётного). Вместо хрупкого flex:1 — горизонтальная прокрутка: вкладка
   никогда не обрезается и не прячется, в крайнем случае до неё долистывают пальцем. */
@media (max-width: 520px) {
  .profile-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; padding-bottom: 4px; }
  .profile-tab { flex: 0 0 auto; scroll-snap-align: start; white-space: nowrap; }
}
/* Отклик на нажатие вкладки — вспышка поверх уже существующего transform:scale(.98) с button:active
   (ниже, в общих правилах). Чистый CSS, без JS: ::after появляется мгновенно и гаснет transition'ом. */
.tab, .tab-btn, .shop-tab, .profile-tab { position: relative; overflow: hidden; transition: transform .12s ease; }
.tab::after, .tab-btn::after, .shop-tab::after, .profile-tab::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.35), transparent 65%);
  opacity: 0; transition: opacity .3s ease;
}
.tab:active::after, .tab-btn:active::after, .shop-tab:active::after, .profile-tab:active::after { opacity: 1; transition: none; }

/* Переключение подраздела «Я» — своя анимация въезда на каждый: Профиль мягко всплывает, Сезон
   въезжает сбоку (по смыслу «дальше по пропуску»), у Мастерской уже есть своя плиточная (.shop-enter —
   cyber-shop.css), у Достижений — карточки всплывают по очереди (.badge-grid-enter ниже). */
.me-panel-enter { animation: me-panel-fade .32s ease-out both; }
@keyframes me-panel-fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
[data-tab="season"].me-panel-enter { animation-name: me-panel-slide; }
@keyframes me-panel-slide { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
.badge-grid-enter .badge { animation: badge-pop-in .35s cubic-bezier(.2,.8,.2,1) both; }
.badge-grid-enter .badge:nth-child(2) { animation-delay: .03s; } .badge-grid-enter .badge:nth-child(3) { animation-delay: .06s; }
.badge-grid-enter .badge:nth-child(4) { animation-delay: .09s; } .badge-grid-enter .badge:nth-child(5) { animation-delay: .12s; }
.badge-grid-enter .badge:nth-child(n+6) { animation-delay: .15s; }
@keyframes badge-pop-in { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .tab::after, .tab-btn::after, .shop-tab::after, .profile-tab::after { transition: none; }
  .me-panel-enter, [data-tab="season"].me-panel-enter, .badge-grid-enter .badge { animation: none; }
}
body[data-motion="off"] .tab::after, body[data-motion="off"] .tab-btn::after,
body[data-motion="off"] .shop-tab::after, body[data-motion="off"] .profile-tab::after { transition: none; }
body[data-motion="off"] .me-panel-enter,
body[data-motion="off"] [data-tab="season"].me-panel-enter,
body[data-motion="off"] .badge-grid-enter .badge { animation: none; }

.me-name { font-size: 26px; line-height: 1.3; }
body[data-route='me'] .panel > .eyebrow { font-size: 22px; font-weight: 700; color: var(--text); }
.shop-grid, .badge-grid { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.shop-item, .badge { min-width: 0; border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: var(--panel-solid); }
.shop-name, .badge-name { font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.shop-sub { font-size: 14px; }
.shop-preview { min-height: 92px; height: auto; display: flex; align-items: center; justify-content: center; gap: 8px; }
.preview-banner { width: 100%; height: auto; aspect-ratio: 3/1; object-fit: cover; border-radius: 10px; }
.preview-level { width: 88px; height: 88px; object-fit: contain; }
.badge { opacity: 1; }
.badge-art { width: 96px; height: 96px; margin-bottom: 16px; }
.badge-desc { flex: 1; }
.badge-chips { font-size: 13px; margin-top: 12px; }
.badge-name::before { content: none; }
.badge.earned .badge-name::before { content: '✓ '; }
.profile-details { margin-top: 16px; }
.profile-details > summary { min-height: 44px; cursor: pointer; font-size: 18px; font-weight: 600; }
.profile-details[open] > summary { margin-bottom: 16px; }
.motion-setting { display: flex; align-items: center; gap: 12px; margin: 16px 0; min-height: 44px; }
.motion-setting input { width: 22px; height: 22px; accent-color: var(--accent); }
.motion-hint { font-size: 14px; color: var(--text-dim); }
.word-card, .grammar-card, .quiz-stage, .quiz-card { background: var(--panel-solid); border-color: var(--line); border-radius: 16px; }
.quiz-card { animation: none; }
.quiz-instruction, .quiz-prompt-ru { font-size: 16px; }
.option-btn { min-height: 56px; padding: 16px; border-radius: 12px; font-size: 18px; }
.quiz-options { gap: 12px; }
.quiz-options-pinyin .option-btn { font: 500 20px/1.5 var(--sans); }
.quiz-back { min-height: 96px; }
.quiz-continue { min-height: 48px; }
.lesson-back { margin-bottom: 16px; display: inline-flex; gap: 8px; align-items: center; }
.tab-btn .ui-icon { width: 20px; height: 20px; margin-right: 4px; }
.hw-add { position: relative; overflow: hidden; }
.hw-add input[type='file'] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.hw-add:focus-within { outline: 3px solid var(--accent); outline-offset: 4px; }
.hw-photo { min-width: 0; }
.hw-photo img { aspect-ratio: 4/3; object-fit: cover; }
.hw-remove { min-width: 44px; min-height: 44px; }
.hw-status { display: inline-flex; align-items: center; min-height: 32px; font-size: 14px; padding: 4px 12px; border-radius: 8px; }
.game-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; }
.game-grid .game-card { margin: 0; padding: 16px; display: flex; flex-direction: column; min-width: 0; }
.game-art { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 12px; margin-bottom: 16px; }
.game-card .game-card-desc { flex: 1; font-size: 14px; }
.game-card-name { font: 700 16px/1.4 var(--sans); overflow-wrap: anywhere; }
.game-play { display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; border-radius: 12px; background: rgba(var(--accent-rgb), .1); color: var(--accent); margin-top: 16px; font-weight: 600; }
.toast img { width: 64px; height: 64px; float: left; margin-right: 12px; }
.toast.show { animation: award-light 650ms ease-out; }
@keyframes award-light { from { box-shadow: 0 0 30px rgba(var(--accent-rgb),.5); } to { box-shadow: 0 4px 24px rgba(0,0,0,.4); } }
#hanzi-rain { opacity: .2; }
body[data-route='review'] #hanzi-rain, body[data-route='lesson'] #hanzi-rain, body[data-route='game'] #hanzi-rain { opacity: .07; }
.glow, .status-online::before { animation: none; }
button, .btn-ghost, .btn-continue, [role='button'], .game-card { transition: background-color 160ms, border-color 160ms, transform 120ms; }
button:active, .btn-continue:active, .sidenav .nav-item:active { transform: scale(.98); }
@media (hover: hover) { .game-card:hover, .lesson-list-item:hover { transform: translateY(-2px); } }
body[data-motion='off'] *, body[data-motion='off'] *::before, body[data-motion='off'] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (max-width: 1180px) {
  .home-layout { grid-template-columns: minmax(0,1fr); }
  .home-aside { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
  .home-aside .panel { margin: 0; }
  .shop-grid, .badge-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 860px) {
  .topbar { padding: 16px; }
  .topbar-title .glow { font-size: 18px; }
  .topbar-stats { gap: 12px; }
  .topbar-stats .stat:not(.stat-chips), .topbar-user { display: none; }
  .body-row { display: block; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .sidenav { display: none; }
  .view-root { padding: 0; }
  .bottomnav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; padding: 8px 4px calc(8px + env(safe-area-inset-bottom)); background: var(--panel-solid); border-top: 1px solid var(--line); }
  .bottomnav .nav-item { min-width: 0; min-height: 56px; gap: 4px; padding: 6px 0; border-radius: 12px; font: 500 11px/1.25 var(--sans); }
  .bottomnav .nav-item small { display: none; }
  .bottomnav .nav-item .nav-icon { width: 22px; height: 22px; }
  .bottomnav .nav-item.active { background: rgba(var(--accent-rgb),.1); }
  .bottomnav .nav-badge { right: 8px; }
  .panel { padding: 20px; }
  h1, .hero-card h1 { font-size: 26px; }
  .shop-grid, .badge-grid, .game-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .profile-tab { padding: 10px 8px; }
  .profile-tab .ui-icon { display: none; }
  /* font-size здесь не трогаем: пусть отвечает clamp() из terminal.css на всех ширинах. */
  .title-banner-text { max-width: 50%; }
}
@media (max-width: 480px) {
  .body-row { padding-left: 12px; padding-right: 12px; }
  .panel { padding: 16px; }
  .mascot-img { height: 92px; width: 60px; }
  .mascot-panel { gap: 8px; }
  .mascot-speech { padding: 12px; }
  .mascot-line { font-size: 14px; }
  .home-aside { display: block; }
  .home-aside .panel + .panel { margin-top: 16px; }
  .hero-card .btn-continue { width: 100%; }
  .shop-item, .badge, .game-grid .game-card { padding: 12px; }
  .shop-name, .badge-name { font-size: 14px; }
  .badge-art { width: 80px; height: 80px; }
  .shop-item .btn-ghost { padding: 8px; }
  .shop-preview { min-height: 56px; }
  .me-name { font-size: 20px; }
  .lesson-list-item { flex-direction: column; align-items: stretch; }
  .lli-progress { width: 100%; }
  .tabs > button { flex: 1; padding: 10px 8px; }
  .tabs .ui-icon { display: none; }
}
@media (max-width: 380px) {
  .badge-art { width: 64px; height: 64px; }
}
/* Shared local branding; keep the full wordmark readable at narrow widths. */
.topbar-title .brand-logo { display: block; line-height: 1; }
.brand-logo img { display: block; width: 232px; height: 48px; object-fit: contain; object-position: left center; max-width: 100%; }
@media (max-width: 480px) {
  .brand-logo img { width: 188px; height: 40px; }
  .topbar-title { min-width: 0; }
}

/* Превью видов дождя в Мастерской: маленький холст, на котором идёт этот дождь. */
.rain-preview { display: block; width: 100%; max-width: 168px; height: 84px; border-radius: 10px; background: rgba(0,0,0,.28); border: 1px solid var(--line); }
.shop-zh { color: var(--accent); font-weight: 500; white-space: nowrap; }

/* На узком экране описания достижений должны оставаться внутри карточки. */
.badge-desc, .badge-chips { overflow-wrap: anywhere; }
@media (max-width: 380px) {
  .badge-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Самые узкие телефоны (320–360 px): «Повторение» не влезало в пятую часть экрана. */
@media (max-width: 360px) {
  .bottomnav .nav-item { font-size: 10px; letter-spacing: -.1px; }
}
