:root {
  --bg: #fbf5f0;
  --card: #ffffff;
  --ink: #2b2233;
  --muted: #7b6f80;
  --line: #eee3db;
  --accent: #e2557a;
  --accent-soft: #fde4ec;
  --matcha: #5aa86a;
  --matcha-soft: #e5f4e2;
  --sun: #f2b53a;
  --sun-soft: #fff3d6;
  --indigo: #5b5bb7;
  --indigo-soft: #e9e8fb;
  --danger: #d6453d;
  --danger-soft: #fde6e4;
  --radius: 20px;
  --shadow: 0 2px 0 rgba(43, 34, 51, .04), 0 8px 24px rgba(43, 34, 51, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(#f1e4da 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ink);
  font: 16px/1.5 "Nunito", "Segoe UI", system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
a { color: var(--indigo); }
[hidden] { display: none !important; }

/* ---------- верхняя панель ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 20px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand small { color: var(--muted); font-weight: 700; font-size: 13px; }
.brand-jp { font-family: "Yu Gothic UI", "Hiragino Sans", "Meiryo", "Noto Sans JP", sans-serif; font-weight: 800; color: var(--ink); letter-spacing: .02em; }
.brand .brand-jp { color: var(--accent); }
#nav { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
#nav a {
  text-decoration: none; color: var(--muted); font-weight: 700;
  padding: 7px 14px; border-radius: 999px; border: 2px solid transparent; white-space: nowrap;
}
#nav a.active { color: var(--ink); border-color: var(--ink); background: #fff; }
#nav a[lang="ja"] { font-family: "Yu Gothic UI", "Hiragino Sans", "Meiryo", "Noto Sans JP", sans-serif; }
.lang-btn { font-family: "Yu Gothic UI", "Hiragino Sans", "Meiryo", "Noto Sans JP", "Nunito", sans-serif; color: var(--accent) !important; border-color: var(--accent-soft) !important; }
#nav a .count { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 700; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.loading { text-align: center; color: var(--muted); padding: 60px; }

/* ---------- общие элементы ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; border: 1px solid var(--line); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.section-title { margin: 30px 0 12px; display: flex; align-items: center; gap: 10px; }

.btn {
  appearance: none; border: 2px solid var(--ink); background: var(--ink); color: #fff;
  font: inherit; font-weight: 800; padding: 9px 18px; border-radius: 999px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); filter: none; }
.btn.good { background: var(--matcha); border-color: var(--matcha); }
.btn.pink { background: var(--accent); border-color: var(--accent); }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger-soft); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 5px 12px; font-size: 14px; }
.btn.icon { padding: 6px 12px; font-size: 18px; }

.field { display: block; font-weight: 700; font-size: 14px; }
.field > span:first-child { display: block; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 2px solid var(--line); border-radius: 12px; padding: 9px 12px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--indigo); }
textarea { min-height: 80px; resize: vertical; }
input[type=file] { font: inherit; font-size: 14px; max-width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.error-text { color: var(--danger); font-weight: 700; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 2px solid var(--line); background: #fff; font-weight: 700; cursor: pointer; user-select: none;
}
.chip input { margin: 0; accent-color: var(--accent); }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.badge.assigned { background: var(--indigo-soft); color: var(--indigo); }
.badge.submitted { background: var(--sun-soft); color: #9a6a00; }
.badge.done { background: var(--matcha-soft); color: #2f7a3e; }
.badge.overdue { background: var(--danger-soft); color: var(--danger); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button {
  font: inherit; font-weight: 700; border: 2px solid var(--line); background: #fff; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer;
}
.tabs button.active { border-color: var(--ink); color: var(--ink); }

.empty { text-align: center; color: var(--muted); padding: 30px; border: 2px dashed var(--line); border-radius: var(--radius); background: rgba(255,255,255,.6); }

/* ---------- сердечки и прогресс ---------- */
.hearts { font-size: 20px; letter-spacing: 1px; line-height: 1; }
.hearts.big { font-size: 30px; letter-spacing: 3px; }
.progress { height: 12px; background: #f3ecf6; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, #f7b6cb, #b9a2ea); border-radius: 999px; transition: width .6s; }

/* ---------- карточки учеников ---------- */
.pet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.pet-card {
  display: block; text-decoration: none; color: inherit; background: #fff; border-radius: var(--radius);
  border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; transition: transform .15s;
}
.pet-card:hover { transform: translateY(-3px); }
.pet-card .art svg { display: block; width: 100%; height: auto; }
.pet-card .body { padding: 12px 14px 14px; }
.pet-card .student { font-weight: 800; font-size: 18px; }
.pet-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.pet-card .badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- панель питомца ---------- */
.pet-layout { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .pet-layout { grid-template-columns: 1fr; } }
.pet-panel { padding: 0; overflow: hidden; }
.pet-panel .art svg { display: block; width: 100%; height: auto; }
.pet-panel .info { padding: 18px 20px 20px; }
.pet-panel .nick { font-size: 26px; font-weight: 800; }
.pet-panel .species { color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.jp { font-family: "Yu Gothic UI", "Hiragino Sans", "Meiryo", sans-serif; color: var(--accent); }
.pet-panel .progress-label { font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
.pet-panel .tip { margin-top: 10px; font-size: 14px; background: var(--sun-soft); border-radius: 12px; padding: 8px 12px; }
.pet-panel .tip.max { background: var(--indigo-soft); }

.rules { display: grid; gap: 10px; }
.rules div { display: flex; gap: 10px; align-items: flex-start; }
.rules .ic { font-size: 22px; line-height: 1.2; }

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-size: 13px; white-space: nowrap; margin-left: auto; padding-left: 8px; }

.species-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.species-pick label { cursor: pointer; border: 2px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; text-align: center; font-weight: 700; font-size: 13px; }
.species-pick label svg { display: block; width: 100%; height: auto; }
.species-pick label span { display: block; padding: 4px; }
.species-pick input { position: absolute; opacity: 0; pointer-events: none; }
.species-pick label:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.species-pick .random { display: flex; align-items: center; justify-content: center; flex-direction: column; font-size: 32px; min-height: 120px; }

.credentials { background: var(--matcha-soft); border-radius: 14px; padding: 12px 16px; }
.credentials code { font-size: 17px; background: #fff; padding: 2px 8px; border-radius: 8px; }

/* ---------- иены и магазин ---------- */
.yen { display: inline-block; font-weight: 800; color: #9a6a00; background: var(--sun-soft); border: 2px solid #f6dc9a; border-radius: 999px; padding: 1px 10px; white-space: nowrap; }
.wallet.big .yen { font-size: 24px; padding: 4px 18px; }
.shop-layout { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
.shop-preview { position: sticky; top: 80px; }
@media (max-width: 820px) {
  .shop-layout { grid-template-columns: 1fr; }
  .shop-preview { position: static; max-width: 300px; margin: 0 auto; width: 100%; }
}
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
@media (max-width: 600px) { .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.shop-item { background: #fff; border: 2px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.shop-item.worn { border-color: var(--matcha); }
.shop-item .art svg { display: block; width: 100%; height: auto; }
.shop-item .body { padding: 10px 12px 12px; display: flex; flex-direction: column; flex: 1; }
.shop-item .body .row { margin-top: auto !important; padding-top: 8px; gap: 6px; }
.shop-item .name { font-weight: 800; line-height: 1.25; }

/* ---------- расписание ---------- */
input[type=date], input[type=time] {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.week-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.week-nav b { font-size: 17px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: start; }
.day { background: rgba(255,255,255,.75); border: 1px solid var(--line); border-radius: 16px; padding: 8px; min-height: 160px; display: flex; flex-direction: column; gap: 6px; }
.day.today { background: #fff; border: 2px solid var(--accent); box-shadow: var(--shadow); }
.day.past { opacity: .7; }
.day-head { display: flex; align-items: baseline; gap: 6px; padding: 2px 4px 4px; }
.day-head span:first-child { font-weight: 800; color: var(--muted); }
.day-head b { font-size: 20px; }
.day.today .day-head b { color: var(--accent); }
.day-add { margin-left: auto; border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; border-radius: 8px; padding: 0 6px; }
.day-add:hover { background: var(--accent-soft); color: var(--accent); }
.day-empty { color: #c0b5c4; font-size: 13px; text-align: center; padding: 14px 0; }
.lesson {
  display: flex; flex-direction: column; gap: 1px; text-align: left; width: 100%;
  font: inherit; font-size: 13px; color: var(--ink); cursor: pointer;
  background: color-mix(in srgb, var(--c) 12%, #fff); border: 0; border-left: 4px solid var(--c);
  border-radius: 10px; padding: 6px 8px;
}
.lesson:hover { background: color-mix(in srgb, var(--c) 20%, #fff); }
.lesson .time { font-weight: 800; }
.lesson .who { font-weight: 700; color: var(--c); }
.lesson .what { color: var(--muted); overflow-wrap: anywhere; }
.lesson .st { font-size: 12px; font-weight: 800; }
.lesson.done { border-left-color: var(--matcha); background: var(--matcha-soft); }
.lesson.done .st { color: #2f7a3e; }
.lesson.cancelled { opacity: .55; background: #f4f1ee; border-left-color: #c9c0c8; }
.lesson.cancelled .time, .lesson.cancelled .what { text-decoration: line-through; }
.lesson.cancelled .st { color: var(--danger); }
@media (max-width: 900px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .day-empty { padding: 4px 0; text-align: left; padding-left: 6px; }
}
.modal.lesson-modal { max-width: 560px; text-align: left; max-height: calc(100vh - 32px); overflow: auto; }
.lesson-day { margin-bottom: 14px; }
.lesson-day h3 { margin-bottom: 4px; }
.lesson-day h3::first-letter { text-transform: uppercase; }
.lesson-day h3.today-label { color: var(--accent); }
.lesson-row { display: flex; gap: 14px; align-items: flex-start; padding: 10px 0 10px 12px; border-left: 4px solid var(--c); margin-top: 8px; border-radius: 4px; }
.lesson-row .time { font-weight: 800; white-space: nowrap; min-width: 92px; }
.lesson-row.cancelled { opacity: .6; }
.lesson-row.cancelled .time, .lesson-row.cancelled b { text-decoration: line-through; }

/* ---------- онлайн-урок ---------- */
.call-status { font-weight: 800; font-size: 14px; padding: 6px 14px; border-radius: 999px; background: var(--indigo-soft); color: var(--indigo); white-space: nowrap; }
.call-status.ok { background: var(--matcha-soft); color: #2f7a3e; }
.call-status.wait { background: var(--sun-soft); color: #9a6a00; }
.call-status.bad { background: var(--danger-soft); color: var(--danger); }
.call-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.stage { padding: 12px; }
.stage-tabs { margin-bottom: 10px; }
.videos { display: flex; flex-direction: column; gap: 10px; }
.video-tile { position: relative; background: #2b2233; border-radius: 16px; overflow: hidden; aspect-ratio: 4 / 3; }
.video-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-tile.self video { transform: scaleX(-1); }
.tile-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 10px; color: #e9e3ee; font-weight: 700; font-size: 14px; background: linear-gradient(135deg, #3b3150, #2b2233); }
.tile-label { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.5); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.call-controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ctl { font: inherit; font-size: 20px; width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--line); background: #fff; cursor: pointer; }
.ctl:hover { border-color: var(--ink); }
.ctl.off { background: var(--danger-soft); border-color: var(--danger); position: relative; }
.ctl.off::after { content: ''; position: absolute; left: 12px; right: 12px; top: 50%; height: 3px; background: var(--danger); transform: rotate(-45deg); border-radius: 2px; }
.ctl.on { background: var(--matcha-soft); border-color: var(--matcha); }
.ctl:disabled { opacity: .4; cursor: default; }
.ctl.end { width: auto; border-radius: 999px; padding: 0 18px; font-size: 15px; font-weight: 800; background: var(--danger); border-color: var(--danger); color: #fff; }
@media (max-width: 960px) {
  .call-grid { grid-template-columns: 1fr; }
  .videos { order: -1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .videos .call-controls, .videos #mediaHint, .videos .music-panel, .videos .music-remote { grid-column: 1 / -1; }
}
.board-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tool-group { display: flex; gap: 4px; padding: 4px; background: #faf6f2; border: 1px solid var(--line); border-radius: 14px; align-items: center; }
.tool { font: inherit; font-size: 18px; width: 38px; height: 38px; border-radius: 10px; border: 2px solid transparent; background: transparent; cursor: pointer; display: inline-grid; place-items: center; }
.tool:hover { background: #fff; }
.tool.active { background: #fff; border-color: var(--ink); }
.tool.size span { display: block; background: var(--ink); border-radius: 50%; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: var(--sw); cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.board-box { position: relative; width: 100%; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); touch-action: none; background: #fff; }
.board-box canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.board-del { position: absolute; transform: translateX(-50%); z-index: 3; font: inherit; font-size: 13px; font-weight: 800; color: #fff; background: var(--danger); border: 2px solid #fff; border-radius: 999px; padding: 5px 14px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.25); white-space: nowrap; }
.board-del:hover { filter: brightness(1.1); }
.drop-hint { position: absolute; inset: 0; display: none; place-items: center; background: rgba(91, 91, 183, .12); border: 3px dashed var(--indigo); border-radius: 12px; font-weight: 800; color: var(--indigo); pointer-events: none; }
.drop-hint.show { display: grid; }
.board-text-input { position: absolute; min-width: 120px; border: 2px dashed var(--indigo); background: rgba(255,255,255,.9); padding: 0 4px; margin: 0; line-height: 1.25; resize: none; overflow: hidden; border-radius: 6px; outline: none; }
#screenPane video { width: 100%; border-radius: 12px; background: #1d1824; display: block; max-height: 70vh; }
/* сцена: доска / экран / камера крупно, на весь экран */
.stage-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.stage-head .stage-tabs { margin: 0; }
#camPane video, #screenPane video { width: 100%; border-radius: 12px; background: #1d1824; display: block; max-height: 70vh; object-fit: contain; }
video.mirror { transform: scaleX(-1); }
.tile-zoom { position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border-radius: 10px; border: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 18px; cursor: pointer; opacity: .85; }
.tile-zoom:hover { opacity: 1; background: rgba(0,0,0,.65); }
.stage:fullscreen, .stage.fake-full { background: #fff; padding: 14px; overflow: auto; border-radius: 0; }
.stage:-webkit-full-screen { background: #fff; padding: 14px; overflow: auto; }
.stage.fake-full { position: fixed; inset: 0; z-index: 60; margin: 0; }
.stage:fullscreen .board-box, .stage.fake-full .board-box { width: min(100%, calc((100vh - 250px) * 1.6)); margin: 0 auto; }
.stage:fullscreen .board-hint, .stage.fake-full .board-hint { display: none; }
.stage:fullscreen #camPane video, .stage:fullscreen #screenPane video,
.stage.fake-full #camPane video, .stage.fake-full #screenPane video { max-height: calc(100vh - 110px); height: calc(100vh - 110px); }
.board-hint { margin-top: 6px; }

/* камера собеседника поверх сцены в полноэкранном режиме */
.stage { position: relative; }
.pip { position: absolute; right: 20px; bottom: 20px; z-index: 6; display: flex; flex-direction: column; gap: 6px; cursor: grab; touch-action: none; user-select: none; }
.pip.dragging { cursor: grabbing; }
.pip-tile { position: relative; width: 240px; border-radius: 14px; overflow: hidden; background: #2b2233; box-shadow: 0 8px 28px rgba(0,0,0,.35); border: 2px solid #fff; }
.pip-tile video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.pip-tile span { position: absolute; left: 8px; bottom: 6px; background: rgba(0,0,0,.5); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.pip-hide { position: absolute; top: -10px; right: -10px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; background: var(--ink); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; z-index: 1; }
.pip-show { position: absolute; right: 20px; bottom: 20px; z-index: 6; font: inherit; font-weight: 800; font-size: 14px; border: 0; border-radius: 999px; padding: 8px 16px; background: var(--ink); color: #fff; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
@media (max-width: 700px) { .pip-tile { width: 140px; } }

/* 🎵 аудио для всех */
.music-panel { padding: 12px 14px; display: grid; gap: 8px; }
.music-pick { justify-self: start; cursor: pointer; }
.music-name { overflow-wrap: anywhere; }
.music-row { flex-wrap: nowrap; }
.music-row input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.music-time { white-space: nowrap; color: var(--muted); }
.music-remote { background: var(--indigo-soft); border-radius: 14px; padding: 10px 12px; display: grid; gap: 6px; font-size: 14px; }
.music-remote .row { flex-wrap: nowrap; }
.music-remote input[type=range] { flex: 1; min-width: 0; accent-color: var(--indigo); }

/* история звонков */
.call-history { display: grid; }
.ch-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.ch-row:last-child { border-bottom: 0; }
.ch-row.live { background: var(--matcha-soft); border-radius: 12px; padding-left: 8px; padding-right: 8px; }
.live-dot { color: var(--danger); font-weight: 800; }
.ch-date { display: grid; font-size: 14px; } .ch-date span { color: var(--muted); font-size: 13px; }
.ch-main { display: grid; min-width: 0; } .ch-main b { overflow-wrap: anywhere; }
.ch-dur { font-weight: 800; white-space: nowrap; color: var(--indigo); }
@media (max-width: 600px) { .ch-row { grid-template-columns: 90px minmax(0, 1fr) auto; } .ch-row > :last-child { grid-column: 2 / -1; justify-self: start; } }

/* 📂 старые доски */
.modal.library-modal { max-width: min(1100px, 100%); width: 100%; text-align: left; display: grid; gap: 10px; max-height: calc(100vh - 32px); overflow: auto; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.lib-card { border: 1px solid var(--line); border-radius: 16px; padding: 10px; display: grid; gap: 6px; background: #fffdfb; }
.lib-prev { aspect-ratio: 16 / 10; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: grid; place-items: center; background: #fff; }
.lib-prev canvas { width: 100%; height: 100%; display: block; }
.lib-name { font-weight: 800 !important; padding: 5px 8px !important; border-color: transparent !important; background: transparent !important; }
.lib-name:hover, .lib-name:focus { border-color: var(--line) !important; background: #fff !important; }
.lib-card .row { gap: 6px; }

/* снимки экрана и история досок */
.screen-actions { margin-top: 8px; gap: 8px; }
.boards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.board-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.board-prev { display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 10; border: 0; border-bottom: 1px solid var(--line); background: #fff; padding: 0; cursor: zoom-in; }
.board-prev canvas { width: 100%; height: 100%; display: block; }
.board-card .body { padding: 10px 14px 14px; display: grid; gap: 4px; }
.modal.board-modal { max-width: min(1200px, 100%); width: 100%; text-align: left; display: grid; gap: 10px; }
.board-big { display: grid; place-items: center; min-height: 200px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.board-big canvas { width: 100%; height: auto; display: block; }

/* доски-слепки */
.pages-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.pages-list { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; max-width: 100%; flex: 1 1 260px; }
.page-thumb { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; color: var(--muted); }
.page-thumb canvas { width: 96px; height: 60px; border-radius: 8px; border: 1px solid var(--line); display: block; background: #fff; }
.page-thumb span { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-thumb.active { border-color: var(--accent); color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.page-thumb:disabled { cursor: default; }
.page-thumb:disabled:not(.active) { opacity: .75; }
.page-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.remote-tiles { display: grid; gap: 10px; }
.remote-tiles:empty { display: none; }
.remote-tiles.many { grid-template-columns: 1fr 1fr; }
.remote-tiles.many .video-tile .tile-empty { font-size: 12px; }
.video-tile .tile-empty small { font-weight: 400; opacity: .8; }
.calls-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .calls-layout { grid-template-columns: 1fr; } }
.link-room { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 8px; background: #fffdfb; }
.link-input { flex: 1; min-width: 0; font-size: 13px !important; color: var(--muted) !important; }
.call-bar { display: grid; gap: 1px; }
.call-bar-item { display: flex; align-items: center; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 8px 16px; background: var(--matcha-soft); border-bottom: 2px solid var(--matcha); font-size: 15px; }
.call-bar-item > span { text-align: center; }
.ring-modal { max-width: 340px; }
.ring-icon { font-size: 54px; animation: ring 1s ease-in-out infinite; display: inline-block; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-18deg); } 20%, 40% { transform: rotate(18deg); } 50% { transform: rotate(0); } }
.toast.with-action { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.toast.with-action button { font: inherit; font-weight: 800; border: 0; border-radius: 999px; padding: 4px 14px; background: #fff; color: var(--ink); cursor: pointer; }
.call-banner { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); background: var(--matcha-soft); border: 2px solid var(--matcha); border-radius: 18px; padding: 12px 16px; margin-bottom: 18px; font-size: 17px; animation: pop .3s ease-out; }
.call-banner > span:first-of-type { flex: 1; }

/* ---------- домашние задания ---------- */
.hw-list { display: grid; gap: 14px; }
.hw { background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--indigo); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow); }
.hw.submitted { border-left-color: var(--sun); }
.hw.done { border-left-color: var(--matcha); }
.hw.overdue { border-left-color: var(--danger); }
.hw .meta { color: var(--muted); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.hw .desc { white-space: pre-wrap; margin-top: 10px; }
.hw .box { margin-top: 12px; border-radius: 12px; padding: 10px 14px; background: #faf7f4; }
.hw .box.answer { background: var(--sun-soft); }
.hw .box.comment { background: var(--indigo-soft); }
.hw .box .label { font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
.hw .box .txt { white-space: pre-wrap; }
.hw .actions { margin-top: 14px; display: grid; gap: 10px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.files a.file { display: inline-flex; gap: 6px; align-items: center; padding: 5px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 14px; font-weight: 700; }
.files img { max-height: 140px; max-width: 220px; border-radius: 10px; border: 1px solid var(--line); display: block; }
.files audio { max-width: 100%; }
details.more > summary { cursor: pointer; font-weight: 700; color: var(--muted); margin: 10px 0; }

/* ---------- вход ---------- */
.auth { max-width: 420px; margin: 40px auto; text-align: center; }
.auth .card { text-align: left; }
.auth .hero svg { width: 180px; border-radius: 28px; box-shadow: var(--shadow); }
.auth h1 { margin: 14px 0 4px; }

/* ---------- уведомления и модалка ---------- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: pop .25s ease-out; }
.toast.error { background: var(--danger); }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }

.modal-bg { position: fixed; inset: 0; background: rgba(43,34,51,.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 24px; padding: 24px; max-width: 360px; width: 100%; text-align: center; animation: pop .3s ease-out; }
.modal svg { width: 220px; border-radius: 20px; }

/* ---------- анимации питомца ---------- */
.pet-svg .bob { animation: bob 3.2s ease-in-out infinite; transform-origin: 100px 182px; transform-box: view-box; }
.pet-svg .flicker { animation: flicker 1.6s ease-in-out infinite; }
.pet-svg .twinkle { animation: twinkle 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.pet-svg .bob.mood-great { animation: hop 1.8s ease-in-out infinite; }
.pet-svg .bob.mood-hungry { animation-duration: 2.4s; }
.pet-svg .bob.mood-sad { animation: bob 5s ease-in-out infinite; }
.pet-svg .bob.mood-sleep { animation: sleepy 4.5s ease-in-out infinite; }
.pet-svg .float { animation: float 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: scale(1.025, .975); } }
@keyframes hop { 0%, 55%, 100% { transform: translateY(0) scale(1, 1); } 20% { transform: translateY(-7px) scale(.98, 1.03); } 40% { transform: translateY(0) scale(1.04, .96); } }
@keyframes sleepy { 0%, 100% { transform: scale(1.04, .9); } 50% { transform: scale(1.06, .88); } }
@keyframes float { 50% { transform: translateY(-3px); } }
.mood { display: inline-flex; gap: 6px; align-items: center; font-weight: 800; font-size: 14px; border-radius: 999px; padding: 3px 12px; margin-bottom: 10px; background: var(--matcha-soft); color: #2f7a3e; }
.mood.ok { background: var(--indigo-soft); color: var(--indigo); }
.mood.hungry { background: var(--sun-soft); color: #9a6a00; }
.mood.sad, .mood.sleep { background: var(--danger-soft); color: var(--danger); }
@keyframes flicker { 50% { opacity: .55; } }
@keyframes twinkle { 50% { opacity: .3; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .pet-svg * { animation: none !important; } }

@media (max-width: 600px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand small { display: none; }
  #nav a { padding: 5px 12px; font-size: 15px; }
}
@media (max-width: 980px) {
  .who { margin-left: auto; }
  #nav { order: 3; flex-basis: 100%; gap: 4px; }
  h1 { font-size: 24px; }
  .card { padding: 16px; }
}

/* Японский интерфейс: японские подписи-дубли в заголовках и под названиями вещей уже не нужны. */
body.lang-ja h1 > .jp,
body.lang-ja .shop-item .jp,
body.lang-ja .ru-only { display: none; }

/* 📝 прошедшие уроки: тема, описание, доски */
.ch-topic { font-weight: 700; color: var(--indigo); overflow-wrap: anywhere; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.lesson-notes { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.lesson-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.lesson-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
  color: inherit; text-decoration: none; display: grid; transition: transform .15s, box-shadow .15s; }
.lesson-card:hover { transform: translateY(-2px); }
.lc-prev { aspect-ratio: 16 / 10; display: grid; place-items: center; border-bottom: 1px solid var(--line); background: #fffdfb; overflow: hidden; }
.lc-prev canvas { width: 100%; height: 100%; display: block; }
.lc-icon { font-size: 44px; opacity: .5; }
.lesson-card .body { padding: 10px 14px 14px; display: grid; gap: 4px; }
.lc-notes { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }

/* листание истории питомца */
.log li[hidden] { display: none; }
.log-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }

/* сворачиваемые блоки (история питомца, домашка) */
details.fold > summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; min-height: 36px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; }
details.fold > summary .badge { font-size: 13px; }
.fold-btn { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 700; color: var(--muted); }
details.fold > summary:hover .fold-btn { color: var(--ink); border-color: var(--ink); }
.fold-arrow { font-size: 14px; line-height: 1; transition: transform .2s; }
details.fold:not([open]) .fold-arrow { transform: rotate(-90deg); }
details.fold[open] .fold-closed, details.fold:not([open]) .fold-open { display: none; }
details.fold[open] > .fold-body { margin-top: 12px; }
details.fold, .fold-body { min-width: 0; max-width: 100%; }
.fold-body .hw-list { grid-template-columns: minmax(0, 1fr); }
details.fold.section { margin: 30px 0 12px; }
.fold-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.fold-title .badge { flex: none; background: var(--accent-soft); color: var(--accent); font-weight: 800; }

/* ученик: «Пока нет активного урока» */
.no-lesson { max-width: 520px; margin: 40px auto; text-align: center; justify-items: center; }
.no-lesson-icon { font-size: 52px; }
.no-lesson p { margin: 0; }

/* ---------- телефон: компактная шапка ---------- */
@media (max-width: 600px) {
  .topbar { position: static; padding: 6px 10px 4px; gap: 4px 8px; }
  .brand { font-size: 17px; }
  .who { gap: 6px; font-size: 13px; }
  .who .btn.small { padding: 4px 10px; font-size: 13px; }
  #whoName { display: none; }
  .bell-text { display: none; }
  #nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 0 10px 2px; gap: 2px; }
  #nav::-webkit-scrollbar { display: none; }
  #nav a { padding: 4px 11px; font-size: 14px; flex: none; }
  main { padding-top: 14px; }
}

/* ---------- телефон: урок на весь экран ---------- */
@supports (height: 100dvh) {
  .stage.fake-full #camPane video, .stage.fake-full #screenPane video { max-height: calc(100dvh - 110px); height: calc(100dvh - 110px); }
}
@media (max-width: 600px) {
  .stage.fake-full { padding: 8px; }
  .stage.fake-full .stage-head { margin-bottom: 6px; gap: 6px; }
  .stage-tabs button { padding: 5px 10px; font-size: 14px; }
  .stage.fake-full .screen-actions { display: none; }
  .stage.fake-full #camPane video, .stage.fake-full #screenPane video { height: calc(100dvh - 64px); max-height: calc(100dvh - 64px); }
  .board-hint { display: none; }
}
.rotate-hint { display: none; }
@media (max-width: 600px) and (orientation: portrait) {
  .stage.fake-full .rotate-hint { display: block; text-align: center; margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
  .stage.fake-full #screenPane video { height: auto; max-height: calc(100dvh - 100px); }
}
