:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #1d2433;
  --muted: #6b7280;
  --line: #e7e2d9;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0f7;
  --warm: #c8553d;
  --ok: #2f7d4f;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.55; }
a { color: var(--accent); }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0.4em 0 0.5em; }
h2 { font-size: 1.25rem; margin: 1.6em 0 0.6em; }
h3 { font-size: 1.05rem; margin: 0 0 0.5em; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--ink); }
nav a:hover { color: var(--accent); }
form.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
.linklike:hover { color: var(--ink); }

main.wrap { padding-top: 24px; padding-bottom: 48px; min-height: 70vh; }
.footer { color: var(--muted); font-size: 0.85rem; padding-bottom: 32px; }

/* buttons */
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  padding: 10px 18px; border-radius: 999px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: 6px 14px; font-size: 0.9rem; }
.btn.danger { color: var(--warm); border-color: var(--warm); }
nav .btn { color: var(--accent-ink); }

.badge { display: inline-block; background: var(--warm); color: #fff; border-radius: 999px; font-size: 0.75rem;
  padding: 0 7px; margin-left: 6px; font-weight: 700; vertical-align: 1px; }
.pill { background: var(--accent-soft); padding: 2px 10px; border-radius: 999px; font-size: 0.85rem; }

.flash { background: var(--accent-soft); border: 1px solid #c5dbea; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 18px; }
.error { background: #fbe9e5; border: 1px solid #efc2b7; color: #8a2f1c; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.right { text-align: right; }
.empty { color: var(--muted); background: var(--surface); border: 1px dashed var(--line); padding: 18px; border-radius: var(--radius); }
.note { color: var(--muted); font-style: italic; }
.strike { text-decoration: line-through; }

/* cards & lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.linkcard { text-decoration: none; color: inherit; }
.linkcard:hover { border-color: var(--accent); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stats { display: flex; gap: 18px; color: var(--muted); }
.stats strong { color: var(--ink); font-size: 1.2rem; }

.slot-booked { border-left: 4px solid var(--ok); }
.slot-open { border-left: 4px solid var(--accent); }
.slot-closed { border-left: 4px solid var(--line); opacity: 0.7; }

/* forms */
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.92rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.narrow { max-width: 560px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; margin-top: 14px; }
.add-slots summary { cursor: pointer; }
.add-slots { margin-bottom: 8px; }
.link-form { display: flex; gap: 6px; }
.link-form input { width: 260px; max-width: 60vw; padding: 6px 10px; }

.auth { max-width: 420px; margin: 20px auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.auth h1 { margin-top: 0; }

/* booking */
.day { margin-top: 22px; }
.slots { display: flex; flex-wrap: wrap; gap: 10px; }
.slot { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.slot summary { list-style: none; padding: 10px 16px; cursor: pointer; font-weight: 600; }
.slot summary::-webkit-details-marker { display: none; }
.slot:hover { border-color: var(--accent); }
.slot[open] { flex-basis: 100%; border-color: var(--accent); }
.slot form { padding: 0 16px 16px; }

/* messages */
.thread { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.messages { max-height: 55vh; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.messages .empty { border: 0; padding: 0; }
.msg { max-width: 78%; }
.msg.mine { align-self: flex-end; text-align: right; }
.bubble { display: inline-block; text-align: left; background: #f1eee8; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.mine .bubble { background: var(--accent); color: #fff; }
.meta { font-size: 0.75rem; color: var(--muted); margin-top: 3px; }
.composer { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { flex: 1; resize: vertical; }
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 28px; }
.two-col h2 { margin-top: 0.4em; }

/* landing */
.hero { display: grid; grid-template-columns: 3fr 2fr; gap: 36px; align-items: center; padding: 30px 0 40px; }
.hero h1 { font-size: 2.6rem; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; color: var(--warm); font-weight: 700; margin: 0; }
.lead { font-size: 1.12rem; color: #374151; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.hero-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px 26px; box-shadow: 0 10px 30px rgba(29, 36, 51, 0.06); }
.hero-card ol { padding-left: 20px; margin: 0; }
.hero-card li { padding: 4px 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.prose { max-width: 680px; }

@media (max-width: 760px) {
  .hero, .two-col, .grid3 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
  .msg { max-width: 92%; }
  .link-form input { width: 100%; }
}

/* ---------- v2: schedule, statuses, series ---------- */
.lead-s { margin: 4px 0 0; }
.banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
.banner.warn { background: #fff7e8; border: 1px solid #f0d9ad; }
.banner.pending { display: block; background: #fff7e8; border: 1px solid #f0d9ad; }
.banner.pending summary { cursor: pointer; padding: 4px 0; }
.pending-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.pending-actions form { margin: 0; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 8px 0 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat-n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-l { color: var(--muted); font-size: 0.82rem; }

.tag { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 0.78rem; font-weight: 600; margin: 3px 4px 0 0; }
.st-reserved { background: #fff7e8; color: #7a4a06; border: 1px solid #f0d9ad; }
.st-confirmed { background: #e5f2ea; color: #1d4d31; }
.st-done { background: #ecebe7; color: #4a4f59; }
.st-cancelled { background: #fdf1ee; color: #8a2f1c; }
.st-paid { background: #e5f2ea; color: #1d4d31; }
.st-unpaid { background: #fdf1ee; color: #8a2f1c; }
.st-plain { background: var(--accent-soft); color: var(--accent); }
.lesson.st-row-reserved { border: 2px dashed #c27a12; background: #fffcf6; }
.ok-text { color: var(--ok); }
.bad-text { color: #a8402a; }

/* week view */
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-label { font-weight: 700; color: var(--ink); text-decoration: none; min-width: 150px; text-align: center; }
.week-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.week-grid { display: grid; gap: 6px; min-width: 640px; }
.day-head { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; font: inherit; cursor: pointer; text-align: left; display: flex; flex-direction: column; min-height: 48px; color: var(--ink); }
.day-head.today { border-color: var(--accent); }
.day-head:hover { border-color: var(--accent); }
.time-label { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.85rem; padding-top: 12px; }
.cell { min-height: 50px; border-radius: 10px; box-sizing: border-box; font-size: 0.85rem; position: relative; display: flex; flex-direction: column; justify-content: center; padding: 6px 8px; }
.empty-cell { background: transparent; }
.cell.slot { padding: 0; }
.cell.slot label { display: flex; flex-direction: column; justify-content: center; padding: 6px 28px 6px 8px; min-height: 50px; cursor: pointer; font-weight: 400; font-size: 0.85rem; gap: 0; border-radius: 10px; }
.cell.slot input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slot-open label { border: 1px solid #8fb4d0; background: #f3f8fc; color: var(--accent); }
.slot-closed label { border: 1px solid #e2ddd4; background: #efece6; color: #6b6458; }
.cell.slot:has(input:checked) label { background: var(--accent); color: #fff; border-color: var(--accent); }
.cell.slot:has(input:focus-visible) label { outline: 3px solid #9cc3e0; }
.cell .edit { position: absolute; top: 4px; right: 6px; text-decoration: none; color: inherit; font-size: 0.9rem; padding: 2px 4px; }
.cell.slot:has(input:checked) .edit { color: #fff; }
.cell.booked { text-decoration: none; color: inherit; }
.st-cell-confirmed { background: #e5f2ea; border: 1px solid var(--ok); color: #1d4d31; }
.st-cell-reserved { background: #fff7e8; border: 2px dashed #c27a12; color: #7a4a06; }
.st-cell-done { background: #ecebe7; border: 1px solid #cfccc5; color: #4a4f59; }
.cell.past { background: transparent; border: 1px dashed var(--line); color: #a39c90; }
.action-bar { position: sticky; bottom: 12px; margin-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: #1d2433; color: #fff; border-radius: 12px; padding: 10px 12px 10px 18px; opacity: 0.85; z-index: 4; }
.action-bar.active { opacity: 1; box-shadow: 0 8px 24px rgba(29, 36, 51, 0.25); }
.btn.light { background: #fff; color: #1d2433; border-color: #fff; }
.btn.outline-light { background: transparent; color: #fff; border-color: #8d97a8; }
.linklike.light { color: #c9d1dd; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 0.82rem; margin: 14px 0; }
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.sw-open { border: 1px solid #8fb4d0; background: #f3f8fc; }
.sw-closed { background: #efece6; border: 1px solid #e2ddd4; }
.sw-reserved { border: 2px dashed #c27a12; background: #fff7e8; }
.sw-confirmed { background: #e5f2ea; border: 1px solid var(--ok); }
.sw-done { background: #ecebe7; border: 1px solid #cfccc5; }

/* forms */
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 700; font-size: 1.02rem; margin-bottom: 8px; padding: 0; }
.num { display: inline-flex; width: 24px; height: 24px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); align-items: center; justify-content: center; font-size: 0.8rem; margin-right: 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { flex-direction: row; font-weight: 600; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid #d9d3c8; background: #fff; cursor: pointer; }
.chip input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip input:focus-visible + span { outline: 3px solid #9cc3e0; }
.chip-btn { min-height: 40px; min-width: 44px; border-radius: 999px; border: 1px solid #d9d3c8; background: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.inline-fields { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stepper { display: inline-flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.stepper input { width: 70px; text-align: center; font-weight: 700; font-size: 1.1rem; }
.step { width: 40px; height: 40px; border-radius: 999px; border: 1px solid #d9d3c8; background: #fff; font-size: 1.2rem; cursor: pointer; }
.override-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 44px; }
.override-row .check, .day-name { min-width: 130px; font-weight: 600; }
.two-col-even { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; align-items: start; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.pv { border: 1px solid #c5dbea; background: #f3f8fc; border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.pv span { color: var(--muted); font-size: 0.8rem; }
.timeoff { background: var(--bg); border-radius: 10px; padding: 8px 12px; }

/* booking */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 8px; flex-wrap: wrap; }
.tab { padding: 10px 16px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.tab.active { color: var(--accent); border-color: var(--accent); }
.date-list { display: flex; flex-direction: column; gap: 6px; max-height: 620px; overflow-y: auto; padding-right: 4px; }
.date-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; border-radius: 10px; padding: 10px 12px; }
.date-row.ok { background: #f1f8f3; border: 1px solid #cfe5d7; }
.date-row.bad { background: #fdf1ee; border: 1px solid #f0cfc6; }
.date-row .mark { font-weight: 700; font-size: 1.1rem; }
.date-row.ok .mark { color: var(--ok); }
.date-row.bad .mark { color: #a8402a; }
.alt { flex-direction: row; align-items: center; gap: 8px; margin-left: auto; font-size: 0.9rem; background: #fff; border: 1px solid #c5dbea; border-radius: 999px; padding: 6px 12px; cursor: pointer; color: var(--accent); }
.alt:has(input:checked) { background: var(--accent); color: #fff; }
.series { margin: 18px 0; }
.series .list { margin-top: 10px; }
.past-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.student-stats { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
details.more { position: relative; }
details.more summary { list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
.more-panel { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
@media (max-width: 760px) {
  .override-row .check, .day-name { min-width: 100px; }
  .student-stats { justify-content: flex-start; }
}
details.more summary.btn { display: inline-flex; align-items: center; white-space: nowrap; }
.linklike.accent { color: var(--accent); font-weight: 600; }
.linklike.accent:hover { text-decoration: underline; }

/* ---------- v3: messenger ---------- */
main.wrap:has(.inbox), main.wrap:has(.lesson-root) { max-width: 1400px; }
.chat-page { max-width: 820px; margin: 0 auto; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.chat-title { margin: 0; font-size: 1.5rem; }
.online { color: var(--ok); font-weight: 600; }
.chat-app { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; height: min(72vh, 760px); overflow: hidden; }
.chat-app.compact { border: 0; border-radius: 0; height: 100%; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #fcfbf8; }
.chat-loading, .chat-empty { text-align: center; margin: auto; }
.day-sep { align-self: center; color: var(--muted); font-size: 0.75rem; background: #f1eee8; border-radius: 999px; padding: 2px 12px; margin: 6px 0; }
.msg { max-width: 78%; display: flex; flex-direction: column; align-items: flex-start; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.bubble { background: #f1eee8; padding: 9px 13px; border-radius: 16px 16px 16px 5px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; max-width: 100%; }
.msg.mine .bubble { background: var(--accent); color: #fff; border-radius: 16px 16px 5px 16px; }
.msg.mine .bubble a { color: #fff; }
.bubble.media { padding: 4px; }
.chat-img { display: block; max-width: min(320px, 100%); max-height: 320px; border-radius: 12px; }
.bubble audio { display: block; width: 260px; max-width: 100%; }
.msg-text { padding: 2px 4px; }
.bubble.media .msg-text { padding: 6px 8px 4px; }
.file-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(255,255,255,0.85); border-radius: 10px; color: var(--ink); text-decoration: none; }
.file-ico { background: #b93a22; color: #fff; font-weight: 700; font-size: 0.7rem; border-radius: 6px; padding: 6px 6px; }
.chat-typing { min-height: 20px; padding: 0 16px; color: var(--muted); font-size: 0.85rem; font-style: italic; background: #fcfbf8; }
.chat-composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--line); background: #fff; }
.chat-composer textarea { flex: 1; resize: none; border-radius: 14px; min-height: 44px; max-height: 160px; }
.icon-btn { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--accent); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { border-color: var(--accent); }
.chat-recording { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); background: #fff7f5; }
.rec-dot { width: 12px; height: 12px; border-radius: 999px; background: #c8553d; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.uploading { align-self: flex-end; }

.inbox { display: flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; min-height: 600px; }
.inbox-list { flex: 1 1 260px; max-width: 320px; border-right: 1px solid var(--line); max-height: 80vh; overflow-y: auto; }
.inbox-chat { flex: 999 1 480px; min-width: 0; padding: 14px; display: flex; flex-direction: column; }
.inbox-chat .chat-app { flex: 1; }
.inbox-item { display: flex; gap: 10px; align-items: center; padding: 12px 14px; color: inherit; text-decoration: none; border-left: 3px solid transparent; }
.inbox-item:hover { background: var(--bg); }
.inbox-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.avatar { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 999px; background: #c9dceb; color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.inbox-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.inbox-row { display: flex; justify-content: space-between; gap: 6px; }
.inbox-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .inbox-list { max-width: none; border-right: 0; border-bottom: 1px solid var(--line); max-height: 200px; }
  .chat-app { height: 70vh; }
  .msg { max-width: 90%; }
}

/* ---------- v3: lesson page ---------- */
.lesson-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: #1d2433; color: #fff; border-radius: 12px; padding: 10px 14px; }
.lesson-bar-info { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.lesson-bar-info span { color: #c9d1dd; }
.lesson-bar .presence { color: #9fd3b4; font-size: 0.85rem; }
.live-tag { background: #c8553d; color: #fff !important; border-radius: 999px; padding: 1px 10px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; }
.notes-tag { background: #4a5568; color: #fff !important; border-radius: 999px; padding: 1px 10px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; }
.board-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 0; }
.color-pick, .size-pick { display: inline-flex; gap: 6px; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 999px; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
#board-voice.recording { background: #fdf1ee; color: #b93a22; border-color: #b93a22; }
.lesson-layout { display: flex; gap: 14px; flex-wrap: wrap; align-items: stretch; }
.board-wrap { flex: 999 1 640px; min-width: 0; height: 75vh; overflow: auto; border: 1px solid #e2ddd4; border-radius: 12px; background: #fff; }
.board { position: relative; min-width: 1400px; min-height: 900px; background-image: radial-gradient(#ddd6c8 1px, transparent 1px); background-size: 24px 24px; cursor: text; }
.lesson-chat { flex: 1 1 280px; max-width: 360px; height: 75vh; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.lesson-chat-head { padding: 10px 14px; font-weight: 700; border-bottom: 1px solid var(--line); }
.lesson-chat .chat-app { flex: 1; min-height: 0; }
.bi { position: absolute; min-width: 80px; cursor: default; }
.bi-text textarea { width: 100%; box-sizing: border-box; border: 1px dashed transparent; background: transparent; resize: none; overflow: hidden; padding: 4px 6px; font: inherit; font-size: 18px; line-height: 1.45; border-radius: 6px; min-height: 34px; }
.bi:hover textarea, .bi.editing textarea { border-color: #8fb4d0; background: rgba(243, 248, 252, 0.6); }
.bi.editing textarea:focus { outline: none; }
.bi img { display: block; width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.bi audio { width: 100%; }
.bi-image { resize: horizontal; overflow: hidden; }
.bi-voice, .bi-file { overflow: hidden; }
.bi-handle, .bi-del { position: absolute; top: -26px; width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line); background: #fff; font-size: 14px; line-height: 1; cursor: grab; opacity: 0; transition: opacity 0.15s; z-index: 2; padding: 0; }
.bi-handle { left: 0; touch-action: none; }
.bi-del { left: 30px; cursor: pointer; color: #b93a22; }
.bi:hover .bi-handle, .bi:hover .bi-del, .bi.editing .bi-handle, .bi.editing .bi-del, .bi-handle:focus, .bi-del:focus { opacity: 1; }
.bi.dragging { opacity: 0.8; }
.bi-image .bi-handle, .bi-image .bi-del, .bi-voice .bi-handle, .bi-voice .bi-del, .bi-file .bi-handle, .bi-file .bi-del { top: 4px; }
.bi-image .bi-handle, .bi-voice .bi-handle, .bi-file .bi-handle { left: 4px; }
.bi-image .bi-del, .bi-voice .bi-del, .bi-file .bi-del { left: 34px; }
.bi-who { position: absolute; right: 0; top: -20px; background: var(--ok); color: #fff; font-size: 11px; font-weight: 700; border-radius: 6px 6px 6px 0; padding: 1px 6px; opacity: 0; transition: opacity 0.2s; pointer-events: none; white-space: nowrap; }
.bi.remote .bi-who { opacity: 1; }
.bi.remote textarea { border-color: var(--ok); }
@media (max-width: 760px) {
  .board-wrap, .lesson-chat { height: 60vh; }
  .lesson-chat { max-width: none; }
  .bi-handle, .bi-del { opacity: 1; }
}

/* ---------- v3: notifications ---------- */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 16px 0; }
.channel { display: flex; flex-direction: column; gap: 8px; }
.channel.on { border: 2px solid var(--ok); }
.table-wrap { overflow-x: auto; }
table.prefs { width: 100%; min-width: 560px; border-collapse: collapse; }
table.prefs th, table.prefs td { padding: 10px 8px; border-top: 1px solid var(--line); text-align: center; }
table.prefs thead th { border-top: 0; color: var(--muted); font-size: 0.85rem; }
table.prefs tbody th { text-align: left; font-weight: 600; }
table.prefs input[type=checkbox] { width: 20px; height: 20px; }
.inline-select { margin-left: 8px; padding: 4px 8px; font-size: 0.9rem; }
[hidden] { display: none !important; }
.chat-app.compact .chat-composer, .chat-page .chat-composer { flex-wrap: wrap; }
.chat-app.compact .chat-composer textarea { order: -1; flex: 1 1 100%; }
.chat-app.compact .chat-composer .btn { margin-left: auto; }
@media (max-width: 520px) {
  .chat-composer { flex-wrap: wrap; }
  .chat-composer textarea { order: -1; flex: 1 1 100%; }
  .chat-composer .btn { margin-left: auto; }
}
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; font-size: 0.8rem; font-weight: 700; }
.lang-switch a { padding: 4px 9px; color: var(--muted); text-decoration: none; }
.lang-switch a.active { background: var(--accent); color: #fff; }

/* ---------- v4: messages fit the screen ---------- */
.chat-who { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.back-to-list { display: none; font-size: 1.8rem; line-height: 1; text-decoration: none; padding: 0 10px 0 0; }
body.chat-mode { height: 100vh; height: var(--app-h, 100dvh); display: flex; flex-direction: column; overflow: hidden; }
body.chat-mode .topbar { position: static; flex: 0 0 auto; }
body.chat-mode main.wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding-top: 14px; padding-bottom: 14px; }
body.chat-mode .flash { flex: 0 0 auto; }
body.chat-mode .chat-page, body.chat-mode .inbox { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; }
body.chat-mode .chat-page { flex-direction: column; }
body.chat-mode .chat-app { height: auto; flex: 1 1 auto; min-height: 0; }
body.chat-mode .inbox { min-height: 0; flex-wrap: nowrap; }
body.chat-mode .inbox-list { max-height: none; overflow-y: auto; }
body.chat-mode .inbox-chat { min-height: 0; }
@media (max-width: 760px) {
  body.chat-mode .topbar-inner { min-height: 0; padding-top: 6px; padding-bottom: 6px; gap: 4px 12px; }
  body.chat-mode .brand { font-size: 1rem; }
  body.chat-mode nav { gap: 4px 14px; font-size: 0.95rem; }
  body.chat-mode main.wrap { padding: 0; }
  body.chat-mode .flash { margin: 8px; }
  body.chat-mode .chat-head { padding: 8px 12px; margin: 0; flex-wrap: nowrap; }
  body.chat-mode .chat-title { font-size: 1.15rem; }
  body.chat-mode .chat-app { border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; }
  body.chat-mode .chat-composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  body.chat-mode .inbox { border: 0; border-radius: 0; flex-direction: column; }
  body.chat-mode .inbox-list { flex: 1 1 auto; border-bottom: 0; }
  body.chat-mode .inbox-chat { padding: 0; flex: 1 1 auto; }
  body.chat-mode .inbox.has-sel .inbox-list { display: none; }
  body.chat-mode .inbox:not(.has-sel) .inbox-chat { display: none; }
  body.chat-mode .back-to-list { display: inline-block; }
  body.chat-mode .chat-head .row-actions .btn { padding: 5px 10px; font-size: 0.85rem; }
  body.chat-mode .chat-scroll { padding: 12px 10px; }
  body.chat-mode .chat-composer textarea { font-size: 16px; } /* no iOS zoom */
}

/* ---------- v4: review fixes ---------- */
.prose h1, h1 { overflow-wrap: break-word; }
@media (max-width: 480px) { h1 { font-size: 1.55rem; } }
@media (max-width: 760px) { input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; } }
.lang-switch a { min-height: 32px; display: inline-flex; align-items: center; padding: 4px 11px; }
@media (pointer: coarse) {
  .lang-switch a { min-height: 40px; padding: 4px 13px; }
  .topbar nav > a, .topbar nav .linklike { padding: 8px 0; display: inline-block; }
}
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 64px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--accent); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; padding: 8px; }
.hint { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 400; margin-top: 4px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 22px 0; }
.facts .card strong { display: block; font-size: 1.05rem; }
.about { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.about img { width: 140px; height: 140px; object-fit: cover; border-radius: 999px; }
.about > div { flex: 1 1 280px; }
h2.h3 { font-size: 1.05rem; margin: 0 0 0.5em; }
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; }
  .topbar nav { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; white-space: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav > * { flex: 0 0 auto; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; }
  .tab { padding: 10px 12px; }
  body.chat-mode .brand { display: none; }
  body.chat-mode .chat-head .btn.ghost[href="/notifications"] { display: none; }
}
.tz-note { background: #fff8e6; border: 1px solid #f0dca8; color: #6b4e00; padding: 8px 12px; border-radius: var(--radius); margin-bottom: 14px; font-size: 0.9rem; }
.tz-line { color: var(--muted); font-size: 0.875rem; margin: 4px 0 14px; }
.plain { list-style: none; padding: 0; margin: 0 0 8px; } .plain li { padding: 2px 0; }

/* ---------- v5: booking day picker, next lesson, prices ---------- */
.day-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; margin: 8px 0 6px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.day-chip { flex: 0 0 auto; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; min-width: 78px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-decoration: none; line-height: 1.25; }
.day-chip .dc-wd { font-size: 0.8rem; color: var(--muted); text-transform: capitalize; }
.day-chip .dc-d { font-size: 1rem; white-space: nowrap; }
.day-chip .dc-n { font-size: 0.72rem; color: var(--ok); }
.day-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.day-chip.active .dc-wd, .day-chip.active .dc-n { color: #e6f0f7; }
section.day h2.h3 { margin-top: 10px; }
.next-lesson { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; border-left: 5px solid var(--accent); margin-bottom: 14px; }
.next-lesson.live { border-left-color: var(--warm); background: #fffaf7; }
.danger-text { color: var(--warm) !important; }
details.show-all { margin-top: 10px; }
details.show-all > summary { list-style: none; cursor: pointer; padding: 6px 0; }
details.show-all > summary::-webkit-details-marker { display: none; }
details.show-all[open] > summary { margin-bottom: 8px; }
.price-sum { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 12px; margin: 0; }
details.more > summary.linklike { cursor: pointer; padding: 6px 4px; }
.tconv { opacity: 0.75; font-size: 0.85em; white-space: nowrap; }
.pay-info { margin: 0 0 14px; } .pay-info > summary { cursor: pointer; }
.cur-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; }
.cur-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cur-row input[type=number] { width: 110px; padding: 6px 8px; }
.tz-dialog { border: 0; border-radius: 18px; padding: 22px; max-width: 420px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.tz-dialog::backdrop { background: rgba(29,36,51,0.45); }
.tz-choice { display: flex; flex-direction: column; align-items: flex-start; text-align: left; border-radius: 14px; width: 100%; color: var(--ink); }
.tz-choice strong { color: var(--accent); }
.tz-dialog select { max-width: 100%; flex: 1; }
.msg.pending { opacity: 0.6; } .msg.pending.failed { opacity: 1; } .msg.pending.failed .bubble { background: #b93a22; } .msg.pending.failed .meta { color: #b93a22; }
.uploading { align-self: flex-end; display: flex; flex-direction: column; gap: 4px; min-width: 180px; } .uploading progress { width: 100%; }
.slot-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font: inherit; cursor: pointer; min-height: 44px; } .slot-btn:hover { border-color: var(--accent); }
.book-sum { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin: 0; }
.danger-zone { margin-top: 16px; } .danger-zone > summary { cursor: pointer; }
.hero-v2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: center; }
.hero-photo { margin: 0; }
.hero-photo img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 24px; display: block; }
.steps { list-style: none; padding: 0; margin: 26px 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.steps strong { flex: 0 0 28px; height: 28px; border-radius: 999px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 0.9rem; }
.first-lesson { margin: 14px 0; border-left: 5px solid var(--ok); }
@media (max-width: 760px) {
  .hero-v2 { grid-template-columns: 1fr; gap: 18px; }
  .hero-photo { max-width: 340px; }
}

/* ---------- v6: bottom tab bar on phones ---------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255,255,255,0.97); border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); backdrop-filter: blur(8px); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; min-height: 52px; color: var(--muted); text-decoration: none; font-size: 0.7rem; position: relative; }
  .tabbar a.active { color: var(--accent); font-weight: 700; }
  .tabbar .badge { position: absolute; top: 2px; left: 55%; margin: 0; }
  body.has-tabbar .topbar nav > a, body.has-tabbar .topbar nav > form.inline { display: none; }
  body.has-tabbar .topbar-inner { flex-wrap: nowrap; min-height: 52px; }
  body.has-tabbar .brand { display: block !important; }
  /* messages page: the bar is part of the screen, not on top of the composer */
  body.chat-mode.has-tabbar { padding-bottom: 0; }
  body.chat-mode .tabbar { position: static; flex: 0 0 auto; }
}
.tb-ico { display: inline-flex; height: 24px; }
.remind-nudge { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; background: #fffaf0; border-color: #f0dca8; } .remind-picks { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: 6px; }

/* ---------- emoji picker ---------- */
.chat-composer { position: relative; }
.emoji-btn { font-size: 20px; }

.emoji-panel { position: absolute; bottom: calc(100% + 6px); left: 8px; z-index: 30; width: min(340px, calc(100% - 16px)); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); padding: 6px; }
.emoji-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 4px; }
.emoji-tab { background: none; border: 0; font-size: 18px; padding: 4px 8px; border-radius: 8px; cursor: pointer; }
.emoji-tab.active { background: var(--accent-soft); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 200px; overflow-y: auto; }
.emoji { background: none; border: 0; font-size: 22px; line-height: 1; padding: 6px 0; border-radius: 8px; cursor: pointer; }
.emoji:hover, .emoji:focus-visible { background: var(--bg); }
.bubble.sticker, .msg.mine .bubble.sticker { background: none !important; padding: 0; }
.chat-sticker { display: block; width: 140px; height: 140px; }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; max-height: 240px; overflow-y: auto; }
.sticker-pick { background: none; border: 0; padding: 2px; border-radius: 10px; cursor: pointer; }
.sticker-pick:hover, .sticker-pick:focus-visible { background: var(--bg); }
.sticker-pick img { width: 100%; height: auto; display: block; }
@media (max-width: 520px) { .emoji-panel { left: 4px; right: 4px; width: auto; } }

/* ---------- v7: lesson canvas ---------- */
main.wrap:has(.lesson-root) { max-width: none; padding: 8px 12px 0; }
.lesson-root { display: flex; flex-direction: column; gap: 6px; height: calc(100dvh - 60px - 12px); position: relative; }
.lesson-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: nowrap; padding: 5px 10px; border-radius: 10px; font-size: 0.9rem; min-height: 0; }
.lesson-bar-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: nowrap; overflow: hidden; }
.lb-title { font-weight: 700; color: #fff; min-width: 40px; max-width: 40vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline: none; border-radius: 4px; padding: 1px 4px; }
.lb-title[contenteditable]:hover, .lb-title[contenteditable]:focus { background: rgba(255,255,255,0.12); }
.lb-title:empty::before { content: attr(data-placeholder); color: #8b96a8; font-weight: 400; }
.lb-when, .lb-with { color: #c9d1dd; white-space: nowrap; }
.lb-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.lb-btn { display: inline-flex; align-items: center; gap: 4px; color: #fff; background: rgba(255,255,255,0.1); border: 0; border-radius: 8px; padding: 5px 9px; font: inherit; font-size: 0.85rem; cursor: pointer; text-decoration: none; list-style: none; }
.lb-btn:hover { background: rgba(255,255,255,0.2); }
.lb-more { position: relative; }
.lb-more > summary::-webkit-details-marker { display: none; }
.lb-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); padding: 6px; display: flex; flex-direction: column; min-width: 250px; }
.lb-menu > a, .lb-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; font: inherit; color: var(--ink); text-decoration: none; cursor: pointer; }
.lb-menu > a:hover, .lb-menu button:hover { background: var(--bg); }
.lb-menu form { margin: 0; }
.board-tools { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto; padding: 2px 0; scrollbar-width: thin; }
.tool-group { display: inline-flex; gap: 2px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 2px; flex: 0 0 auto; }
.tool { min-width: 34px; height: 34px; border: 0; background: none; border-radius: 8px; font: inherit; font-size: 15px; cursor: pointer; color: var(--ink); padding: 0 6px; }
.tool:hover { background: var(--bg); }
.tool[aria-pressed="true"] { background: var(--accent); color: #fff; }
.tool.recording { background: #fdf1ee; color: #b93a22; }
.board-tools .swatch { width: 24px; height: 24px; margin: 0 2px; border-width: 2px; }
.zoom-val { min-width: 52px; font-size: 13px; }
.lesson-layout { flex: 1; min-height: 0; display: flex; gap: 10px; }
.board-wrap { flex: 1; min-width: 0; height: auto; position: relative; overflow: hidden; touch-action: none; border: 1px solid #e2ddd4; border-radius: 12px; background-color: #fff;
  background-image: radial-gradient(#ddd6c8 1px, transparent 1px); background-size: 24px 24px; cursor: text; user-select: none; -webkit-user-select: none; }
.lesson-root[data-tool="draw"] .board-wrap, .lesson-root[data-tool="hl"] .board-wrap { cursor: crosshair; }
.lesson-root[data-tool="erase"] .board-wrap { cursor: cell; }
.board-wrap.panning { cursor: grabbing; }
.board { position: absolute; left: 0; top: 0; width: 0; height: 0; min-width: 0; min-height: 0; transform-origin: 0 0; background: none; cursor: inherit; }
.ink-layer { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; z-index: 100000; }
.ink-layer path { pointer-events: none; }
.lesson-root[data-tool="erase"] .ink-layer path.ink { pointer-events: stroke; }
.bi { position: absolute; min-width: 40px; }
.bi-body { min-height: 32px; padding: 4px 8px; font-size: 18px; line-height: 1.45; outline: none; border: 1px dashed transparent; border-radius: 6px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; cursor: text; }
.bi:hover .bi-body, .bi.selected .bi-body { border-color: #c5d8e6; }
.bi.editing .bi-body { border-color: #8fb4d0; background: rgba(243, 248, 252, 0.7); }
.bi.remote .bi-body { border-color: var(--ok); }
.bi-bar { position: absolute; top: -38px; left: 0; display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; z-index: 5; }
.bi:hover .bi-bar, .bi.selected .bi-bar, .bi.editing .bi-bar { opacity: 1; }
.bi .bi-handle, .bi .bi-del { position: static; opacity: 1; width: 32px; height: 32px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: #fff; padding: 0; box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
.bi .bi-handle { background: var(--accent); color: #fff; border-color: var(--accent); cursor: grab; touch-action: none; }
.bi .bi-handle:active { cursor: grabbing; }
.bi .bi-del { font-size: 14px; cursor: pointer; }
.bi-resize { position: absolute; right: -6px; bottom: -6px; width: 16px; height: 16px; border-radius: 4px; background: var(--accent); border: 2px solid #fff; cursor: ew-resize; opacity: 0; touch-action: none; z-index: 5; }
.bi:hover .bi-resize, .bi.selected .bi-resize { opacity: 1; }
.bi.dragging { opacity: 0.85; }
.bi-who { top: -22px; right: 0; left: auto; }
.bi-image img { display: block; width: 100%; border-radius: 8px; border: 1px solid var(--line); pointer-events: none; }
.bi-image, .bi-voice, .bi-file, .bi-pdf { overflow: visible; resize: none; }
.bi-marker { min-width: 0; }
.bi-marker-label { background: #ffd23f; color: #3a2e00; font-weight: 700; padding: 4px 12px; border-radius: 999px 999px 999px 4px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,0.15); font-size: 15px; }
.bi-pdf { background: #fff; }
.pdf-head { display: block; font-size: 13px; padding: 4px 6px; color: var(--accent); }
.pdf-pages canvas { display: block; margin: 0 0 10px; box-shadow: 0 1px 6px rgba(0,0,0,0.18); background: #fff; }
.ctx-menu { position: absolute; z-index: 2000; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 34px rgba(0,0,0,0.18); padding: 6px; min-width: 220px; max-width: 320px; display: flex; flex-direction: column; }
.ctx-menu button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 0.95rem; cursor: pointer; color: var(--ink); }
.ctx-menu button:hover, .ctx-menu button:focus-visible { background: var(--bg); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.cm-colors { display: flex; gap: 4px; padding: 6px 8px; }
.cm-colors .swatch { width: 26px; height: 26px; }
.markers-panel { position: absolute; top: 10px; right: 10px; z-index: 1000; width: min(320px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); padding: 12px; user-select: text; }
.mp-close { position: absolute; top: 6px; right: 6px; border: 0; background: none; font-size: 16px; cursor: pointer; }
.mp-page { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.mp-page.current .mp-title { font-weight: 700; }
.mp-title { color: var(--ink); text-decoration: none; }
.mp-tag { background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 1px 6px; font-size: 0.8rem; font-weight: 700; }
.mp-marker { padding-left: 10px; font-size: 0.9rem; color: var(--ink); text-decoration: none; }
.mp-marker:hover, .mp-title:hover { text-decoration: underline; }
.board-toast { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 9px 16px; border-radius: 999px; z-index: 3000; font-size: 0.9rem; max-width: 90%; box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
.lesson-chat { flex: 0 0 320px; max-width: 320px; height: auto; display: flex; flex-direction: column; }
.lesson-chat-head { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; background: #fff; border: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; font: inherit; font-weight: 700; cursor: default; }
.lc-toggle { display: none; }
.lesson-chat .chat-app { flex: 1; min-height: 0; }
.fs-exit { position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 3000; width: 48px; height: 48px; border-radius: 999px; border: 0; background: rgba(29,36,51,0.85); color: #fff; font-size: 20px; box-shadow: 0 6px 18px rgba(0,0,0,0.3); cursor: pointer; }
.lesson-root.is-fs { position: fixed; inset: 0; z-index: 1500; height: 100dvh; padding: 6px; background: var(--bg); }
body.board-fs { overflow: hidden; }
body.board-fs .topbar, body.board-fs .tabbar { display: none !important; }
.plan-root .lesson-bar { background: #3d4a5e; }
@media (pointer: coarse) {
  .bi .bi-bar { top: -44px; }
  .bi .bi-handle, .bi .bi-del { width: 38px; height: 38px; }
  .bi:hover .bi-bar { opacity: 0; }
  .bi.selected .bi-bar, .bi.editing .bi-bar { opacity: 1; }
  .bi-resize { width: 22px; height: 22px; right: -10px; bottom: -10px; }
}
@media (max-width: 760px) {
  main.wrap:has(.lesson-root) { padding: 4px 4px 0; }
  .lesson-root { height: calc(100dvh - 52px - 64px - env(safe-area-inset-bottom) - 6px); gap: 4px; }
  .lesson-bar { padding: 3px 6px; border-radius: 8px; font-size: 0.8rem; }
  .lb-when, .lb-with, .lb-label { display: none; }
  .lb-title { max-width: 46vw; }
  .lb-btn { padding: 4px 7px; }
  .live-tag, .notes-tag { font-size: 0.65rem; padding: 1px 6px; }
  .tool { min-width: 32px; height: 32px; }
  .board-tools #board-status { display: none; }
  .lesson-layout { display: block; position: relative; }
  .board-wrap { height: 100%; }
  /* chat: a strip at the bottom with the newest message; tap to open */
  .lesson-chat { position: absolute; left: 6px; right: 6px; bottom: 6px; max-width: none; z-index: 900; border-radius: 14px; box-shadow: 0 6px 22px rgba(0,0,0,0.18); background: #fff; }
  .lesson-chat-head { cursor: pointer; padding: 6px 12px; border-radius: 14px 14px 0 0; font-size: 0.85rem; }
  .lc-toggle { display: inline; }
  .lesson-chat.has-new .lesson-chat-head { background: #fff6e8; }
  .lesson-chat .chat-app { height: auto; }
  .lesson-chat:not(.open) .chat-scroll { max-height: 54px; overflow: hidden; padding: 4px 10px; }
  .lesson-chat:not(.open) .chat-scroll .day-sep, .lesson-chat:not(.open) .chat-typing { display: none; }
  .lesson-chat:not(.open) .chat-composer { padding: 4px 6px 6px; }
  .lesson-chat:not(.open) .chat-composer .icon-btn { display: none; }
  .lesson-chat:not(.open) .chat-composer textarea { min-height: 36px; padding: 6px 10px; }
  .lesson-chat.open { top: 20%; }
  .lesson-chat.open .lc-toggle { transform: rotate(180deg); }
  .lesson-chat.open .chat-app { flex: 1; }
  .lesson-root.is-fs .lesson-chat:not(.open) { display: none; }
  .lesson-root.is-fs { height: 100dvh; }
}

/* ---------- vocabulary ---------- */
.vocab-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.vocab-add input { flex: 1 1 180px; }
.vocab-list { display: flex; flex-direction: column; gap: 6px; }
.vocab-row { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.vocab-row > summary { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; cursor: pointer; list-style: none; align-items: center; }
.vocab-row > summary::-webkit-details-marker { display: none; }
.vw { font-weight: 700; }
.vbox { color: var(--ok); letter-spacing: 1px; font-size: 0.75rem; white-space: nowrap; }
.vocab-row[open] { border-color: var(--accent); }
.vocab-row form { margin-top: 8px; }
.trainer { max-width: 640px; margin: 0 auto; }
.flash-card { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; margin: 14px 0; cursor: pointer; gap: 6px; }
.big-word { font-size: 2rem; font-weight: 800; margin: 0; }
.answer { font-size: 1.5rem; margin: 6px 0 0; }
.type-answer { font-size: 1.2rem; text-align: center; max-width: 320px; width: 100%; }
.trainer-btns { justify-content: center; }
.trainer-btns .btn { min-width: 150px; min-height: 48px; }
@media (max-width: 760px) { .vocab-row > summary { grid-template-columns: 1fr 1fr; } .vbox { grid-column: 1 / -1; } }
.site-menu { position: fixed; }
.site-toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1d2433; color: #fff; padding: 9px 16px; border-radius: 999px; z-index: 5000; font-size: 0.9rem; max-width: 90%; box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
[data-menu] { -webkit-touch-callout: none; }
/* lesson pages use the whole screen: no site header, a back arrow in the lesson bar */
body:has(.lesson-root) .topbar { display: none; }
body:has(.lesson-root) .tz-note, body:has(.lesson-root) main > .flash { display: none; }
.lesson-root { height: calc(100dvh - 12px); }
.tabbar a span:not(.badge):not(.tb-ico) { white-space: nowrap; }
@media (max-width: 760px) {
  .lesson-root { height: calc(100dvh - 64px - env(safe-area-inset-bottom) - 6px); }
  .tabbar a { font-size: 0.66rem; }
  .lesson-chat:not(.open) .chat-empty { display: none; }
  .lesson-chat:not(.open) .chat-scroll { max-height: 44px; min-height: 0; padding: 2px 10px; }
  .lesson-chat:not(.open) .chat-scroll:empty { display: none; }
  .lesson-chat:not(.open) .chat-composer { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; }
  .lesson-chat:not(.open) .chat-composer textarea { flex: 1; min-width: 0; }
  .lesson-chat:not(.open) .chat-composer .btn { padding: 8px 14px; min-height: 36px; }
  .lesson-chat:not(.open) .msg .bubble { padding: 4px 10px; font-size: 0.85rem; }
  .lesson-chat:not(.open) .msg .meta { display: none; }
}
@media (max-width: 760px) {
  .lesson-chat:not(.open) .chat-app.compact .chat-composer { flex-wrap: nowrap; }
  .lesson-chat:not(.open) .chat-app.compact .chat-composer textarea { order: 0; flex: 1 1 auto; }
  .lesson-chat:not(.open) .chat-app.compact .chat-composer .btn { margin-left: 0; }
}

/* ---------- v8: design system pass ---------- */
:root { --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --shadow: 0 6px 20px rgba(29,36,51,0.08); }
.wrap { max-width: 1080px; padding: 0 var(--s4); }
main.wrap { padding-top: var(--s4); padding-bottom: var(--s6); }
h1 { font-size: 1.6rem; margin: 0 0 var(--s3); }
h2 { font-size: 1.15rem; margin: var(--s5) 0 var(--s2); }
section { margin-bottom: var(--s4); }
.card { padding: var(--s3) var(--s4); }
.list { gap: var(--s2); }
.stats-row { gap: var(--s2); margin: var(--s2) 0 var(--s3); }
.stat { padding: var(--s2) var(--s3); }
.page-head { gap: var(--s2) var(--s3); margin-bottom: var(--s3); align-items: center; }
.row.card { padding: 10px 14px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn, .tool, .slot-btn, .day-chip, .tab { transition: background-color 0.12s, border-color 0.12s, filter 0.12s; }
.btn:active { transform: translateY(1px); }
.flash { position: sticky; top: 68px; z-index: 4; box-shadow: var(--shadow); animation: flash-in 0.25s ease-out; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
/* sticky page headers and action bars */
.sticky-head { position: sticky; top: 60px; z-index: 3; background: var(--bg); padding: var(--s2) 0; margin-top: calc(-1 * var(--s2)); }
.sticky-actions { position: sticky; bottom: 0; z-index: 3; display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: var(--s3) 0 var(--s2); }
.card .sticky-actions { background: linear-gradient(to top, var(--surface) 70%, transparent); }
.tabs { position: sticky; top: 60px; z-index: 3; background: var(--bg); }
.page-head .tabs { position: static; }
.day-strip { position: sticky; top: 60px; z-index: 3; background: var(--bg); }
/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.fin { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
table.fin th, table.fin td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
table.fin thead th { position: sticky; top: 0; background: #f4f1ea; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
table.fin tfoot th { background: #f4f1ea; border-bottom: 0; }
table.fin tbody tr:hover { background: #fbfaf7; }
table.fin td:nth-child(n+2), table.fin th:nth-child(n+2) { text-align: right; }
table.fin-edit td:nth-child(2), table.fin-edit th:nth-child(2), table.fin-edit td:nth-child(3), table.fin-edit th:nth-child(3) { text-align: left; }
input.num { width: 96px; text-align: right; padding: 6px 8px; }
table.fin select { padding: 6px 8px; }
.filter-bar { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: flex-end; margin-bottom: var(--s3); }
.filter-bar label { display: flex; flex-direction: column; gap: 2px; font-size: 0.8rem; color: var(--muted); flex: 1 1 130px; }
.filter-bar input, .filter-bar select { padding: 7px 10px; }
.bad-text { color: #b93a22; } .ok-text { color: var(--ok); }
.st-free { background: #e8eefc; color: #2a3f8f; } .st-claim { background: #fff3cf; color: #6b4e00; }
.is-archived { opacity: 0.65; }
/* payment */
.pay-row { cursor: pointer; } .pay-row input { width: 20px; height: 20px; vertical-align: -4px; margin-right: 6px; }
.pay-method { padding: var(--s2) 0; border-bottom: 1px solid var(--line); } .pay-method:last-of-type { border-bottom: 0; }
.pay-nudge { background: #f3f8fc; border-color: #c5dbea; }
/* home */
.free-badge { display: inline-block; background: #e5f2ea; color: #1d4d31; border-radius: var(--radius); padding: 8px 12px; font-weight: 600; margin: 0 0 var(--s3); }
.quals { list-style: none; padding: 0; margin: var(--s2) 0 0; display: grid; gap: 4px; }
.video-wrap { position: relative; aspect-ratio: 16 / 9; max-width: 560px; margin-top: var(--s3); border-radius: var(--radius); overflow: hidden; background: #000; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.review { margin: 0; } .review blockquote { margin: 0 0 var(--s2); } .review figcaption { color: var(--muted); font-size: 0.9rem; }
.center-cta { text-align: center; margin: var(--s5) 0; }
a.slot-btn { display: inline-block; text-decoration: none; color: var(--ink); }
.grid3 { margin-bottom: var(--s3); }
/* lesson manager */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s3); }
.plan-card { display: flex; flex-direction: column; gap: var(--s2); }
.plan-card.tpl { border-left: 4px solid #ffd23f; }
.plan-open { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); }
.plan-kind { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.inline-fields { display: flex; gap: var(--s3); flex-wrap: wrap; } .inline-fields > label { flex: 1 1 160px; }
@media (max-width: 760px) {
  .wrap { padding: 0 var(--s3); }
  h1 { font-size: 1.35rem; }
  .sticky-head, .tabs, .day-strip { top: 52px; }
  .flash { top: 58px; }
  .sticky-actions { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .sticky-actions .btn { flex: 1 1 auto; text-align: center; }
  main.wrap { padding-bottom: var(--s5); }
}
.msg-orig { margin-top: 4px; font-size: 0.8rem; opacity: 0.85; } .msg-orig summary { cursor: pointer; }
.orig-text { text-decoration: line-through; text-decoration-color: rgba(185,58,34,0.7); white-space: pre-wrap; margin-top: 2px; }
.chat-editing { display: flex; justify-content: space-between; gap: 8px; padding: 4px 12px; background: #fff6e8; border-top: 1px solid #f0dca8; font-size: 0.85rem; }
.fmt-btn { font-size: 15px; }
@media (pointer: coarse) { .fmt-btn { display: none; } }
.chat-app.compact .fmt-btn { display: none; }
.msg { -webkit-touch-callout: none; }
.flash { position: static; box-shadow: none; }
.bi-ex { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 17px; line-height: 1.9; user-select: text; }
.ex-gap { font: inherit; padding: 1px 6px; border: 0; border-bottom: 2px solid var(--accent); border-radius: 4px 4px 0 0; background: var(--accent-soft); width: auto; display: inline-block; }
.ex-gap.ex-ok { background: #e5f2ea; border-color: var(--ok); } .ex-gap.ex-bad { background: #fbe9e5; border-color: #b93a22; }
.ex-sol { color: var(--ok); font-weight: 700; }
.ex-q { margin: 8px 0; } .ex-opt { display: block; padding: 2px 8px; border-radius: 8px; cursor: pointer; }
.ex-opt.ex-ok { background: #e5f2ea; } .ex-opt.ex-bad { background: #fbe9e5; text-decoration: line-through; }
.ex-foot { display: flex; gap: 12px; align-items: center; margin-top: 8px; line-height: 1.4; }
.ex-dialog { max-width: 560px; } .ex-dialog textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 14px; }
