/* Lingua Desk — calm, editorial workspace UI */
:root {
  --bg: #f4f2ed;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #17191e;
  --ink-2: #3a3d44;
  --muted: #6c6f76;
  --line: #e3e0d8;
  --line-2: #efece6;
  --en: #2f5da8;
  --en-soft: #e6eefa;
  --fr: #a23b4b;
  --fr-soft: #f8e7ea;
  --ok: #2e7d5b;
  --ok-soft: #e3f2ea;
  --warn: #a8701a;
  --warn-soft: #fbf0dc;
  --danger: #b4372f;
  --danger-soft: #fae6e4;
  --focus: #2f5da8;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 4px 16px rgba(20, 20, 20, .05);
  --shadow-lg: 0 10px 40px rgba(20, 20, 20, .16);
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111215; --surface: #191b1f; --surface-2: #1e2025; --ink: #ecebe6; --ink-2: #c9c8c2; --muted: #8d9097;
    --line: #2b2e34; --line-2: #24262b; --en: #7fa6e8; --en-soft: #1d2a40; --fr: #e48593; --fr-soft: #3a2026;
    --ok: #6cc59c; --ok-soft: #173126; --warn: #e2b061; --warn-soft: #362a15; --danger: #ee8079; --danger-soft: #3a1d1b;
    --focus: #7fa6e8; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111215; --surface: #191b1f; --surface-2: #1e2025; --ink: #ecebe6; --ink-2: #c9c8c2; --muted: #8d9097;
  --line: #2b2e34; --line-2: #24262b; --en: #7fa6e8; --en-soft: #1d2a40; --fr: #e48593; --fr-soft: #3a2026;
  --ok: #6cc59c; --ok-soft: #173126; --warn: #e2b061; --warn-soft: #362a15; --danger: #ee8079; --danger-soft: #3a1d1b;
  --focus: #7fa6e8; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-family: var(--serif); font-weight: 500; font-size: 30px; letter-spacing: -.02em; line-height: 1.15; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 .6em; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- Layout shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--surface-2) 247px, var(--line) 247px, var(--line) 248px, var(--bg) 248px); }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px; background: var(--surface-2); border-right: 1px solid var(--line); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--ink); color: var(--bg);
  display: grid; place-items: center; font-family: var(--serif); font-size: 17px; font-weight: 600;
}
.brand-name { font-family: var(--serif); font-size: 19px; font-weight: 500; letter-spacing: -.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 9px; text-decoration: none;
  color: var(--ink-2); font-weight: 500; font-size: 14.5px;
}
.nav a > span:not(.count) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav a:hover { background: var(--line-2); color: var(--ink); }
.nav a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.nav a .count { margin-left: auto; min-width: 20px; padding: 0 6px; height: 20px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid transparent;
}
.topbar .crumbs { font-size: 13px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.page { padding: 8px 28px 48px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 10px 0 22px; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; }
.card-head h2 { flex: 1; }
.card-body { padding: 14px 20px 18px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.sep { height: 1px; background: var(--line); margin: 14px 0; border: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600;
  font-size: 14px; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { height: 31px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.icon-only { width: 38px; padding: 0; }
.btn.sm.icon-only { width: 31px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.input.sm { height: 32px; font-size: 13.5px; border-radius: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--ink); width: 16px; height: 16px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.chip.en { background: var(--en-soft); color: var(--en); }
.chip.fr { background: var(--fr-soft); color: var(--fr); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.ink { background: var(--ink); color: var(--bg); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.en { background: var(--en); } .dot.fr { background: var(--fr); } .dot.ok { background: var(--ok); } .dot.live { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 13px; color: #fff; letter-spacing: .02em; position: relative;
}
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.avatar .online { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface); }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); text-decoration: none; }
.list-item:first-child { border-top: 0; }
a.list-item:hover .title { text-decoration: underline; text-underline-offset: 3px; }
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: 13px; color: var(--muted); }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 14px; }
.empty .icon { width: 28px; height: 28px; margin-bottom: 6px; opacity: .6; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--line-2); border-radius: 11px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 6px 13px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.stat { padding: 16px 18px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .v { font-family: var(--serif); font-size: 30px; line-height: 1.1; margin-top: 6px; letter-spacing: -.02em; }
.stat .d { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 11px; background: var(--warn-soft); color: var(--ink); font-size: 14px; }
.notice.info { background: var(--en-soft); }
.notice.ok { background: var(--ok-soft); }
.notice.danger { background: var(--danger-soft); }
.notice .icon { margin-top: 2px; }

.progress { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ink); border-radius: 3px; }

/* ---------- Next lesson hero ---------- */
.hero {
  position: relative; overflow: hidden; padding: 22px 24px; border-radius: var(--radius);
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow);
}
.hero .muted { color: color-mix(in srgb, var(--bg) 62%, var(--ink)); }
.hero h2 { font-family: var(--serif); font-size: 26px; font-weight: 500; margin: 6px 0 4px; letter-spacing: -.02em; }
.hero .btn { background: var(--bg); color: var(--ink); border-color: var(--bg); }
.hero .btn.ghost { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 30%, transparent); }
.hero .countdown { font-family: var(--serif); font-size: 44px; line-height: 1; letter-spacing: -.03em; }
.hero-glyph { position: absolute; right: -10px; bottom: -40px; font-family: var(--serif); font-size: 190px; line-height: 1; opacity: .07; pointer-events: none; user-select: none; }

/* ---------- Auth / entry ---------- */
.entry { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(380px, 480px); }
.entry-left { padding: 40px 56px; display: flex; flex-direction: column; gap: 28px; border-right: 1px solid var(--line); }
.entry-left h1 { font-size: 46px; max-width: 640px; }
.entry-left h1 em { font-style: italic; color: var(--fr); }
.entry-left h1 em.en { color: var(--en); }
.entry-right { padding: 40px; display: flex; flex-direction: column; justify-content: center; background: var(--surface-2); }
.auth-card { width: 100%; max-width: 400px; margin: 0 auto; }
.slots-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.slot-day { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); }
.slot-day b { display: block; font-size: 13px; margin-bottom: 8px; }
.slot-day .times { display: flex; flex-wrap: wrap; gap: 5px; }
.slot-day .times span { font-size: 12.5px; padding: 2px 7px; border-radius: 6px; background: var(--line-2); font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fact { border-top: 2px solid var(--ink); padding-top: 10px; font-size: 13.5px; color: var(--ink-2); }
.fact b { display: block; font-size: 14.5px; color: var(--ink); margin-bottom: 2px; }
.type-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.type-list .t { display: flex; gap: 14px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--line); }
.type-list .t .name { font-weight: 600; flex: 1; }
.type-list .t .price { font-family: var(--serif); font-size: 18px; }

/* ---------- Booking ---------- */
.steps { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 18px; flex-wrap: wrap; }
.steps .s { display: flex; align-items: center; gap: 7px; }
.steps .n { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.steps .s.on { color: var(--ink); font-weight: 600; }
.steps .s.on .n { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.type-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.type-card { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 13px; padding: 16px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, box-shadow .15s; }
.type-card:hover { border-color: var(--ink); }
.type-card.sel { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.type-card .price { font-family: var(--serif); font-size: 22px; }
.week-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.week-nav .label { font-weight: 600; min-width: 200px; text-align: center; }
.slot-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.slot-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.slot-col .day { text-align: center; padding: 6px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.slot-col .day b { display: block; font-size: 18px; font-family: var(--serif); font-weight: 500; }
.slot-col .day span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.slot-col .day.today b { color: var(--en); }
.slot-btn { height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.slot-btn:hover { border-color: var(--ink); }
.slot-btn.sel { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.slot-col .none { font-size: 12px; color: var(--muted); text-align: center; padding: 8px 0; }

/* ---------- Calendar (week) ---------- */
.cal { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.cal-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 4px; text-align: center; }
.cal-head b { font-family: var(--serif); font-weight: 500; font-size: 20px; display: block; line-height: 1.1; }
.cal-head span { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cal-head.today b { display: grid; margin: 0 auto; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 16px; }
.cal-gutter { position: relative; border-right: 1px solid var(--line); }
.cal-gutter .h { position: absolute; right: 6px; font-size: 11px; color: var(--muted); transform: translateY(-50%); font-variant-numeric: tabular-nums; }
.cal-day { position: relative; border-right: 1px solid var(--line-2); }
.cal-day:last-child { border-right: 0; }
.cal-day .hl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line-2); }
.cal-day .avail { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--ok) 7%, transparent) 6px 7px); background-color: color-mix(in srgb, var(--ok) 5%, transparent); }
.cal-day .now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; }
.cal-day .now::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.ev {
  position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: 4px 7px; font-size: 12px; line-height: 1.3; overflow: hidden;
  cursor: pointer; border-left: 3px solid var(--ink); background: var(--line-2); text-decoration: none; z-index: 2;
}
.ev.en { border-left-color: var(--en); background: var(--en-soft); }
.ev.fr { border-left-color: var(--fr); background: var(--fr-soft); }
.ev.cancelled, .ev.late_cancel { opacity: .45; text-decoration: line-through; }
.ev.completed { opacity: .7; }
.ev b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-day .ghost-slot { position: absolute; left: 3px; right: 3px; border-radius: 7px; border: 1px dashed var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); pointer-events: none; z-index: 1; font-size: 11.5px; padding: 3px 6px; }

/* ---------- Chat ---------- */
.chat { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - 150px); min-height: 460px; overflow: hidden; }
.chat-threads { border-right: 1px solid var(--line); overflow-y: auto; }
.thread { display: flex; gap: 10px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--line-2); align-items: center; text-decoration: none; }
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--line-2); }
.thread .last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.msg { max-width: min(560px, 80%); padding: 8px 12px; border-radius: 14px; background: var(--line-2); align-self: flex-start; word-wrap: break-word; white-space: pre-wrap; font-size: 14.5px; }
.msg.mine { align-self: flex-end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 4px; }
.msg:not(.mine) { border-bottom-left-radius: 4px; }
.msg .t { display: block; font-size: 11px; opacity: .6; margin-top: 2px; text-align: right; }
.msg .tag { display: block; font-size: 11px; opacity: .65; margin-bottom: 2px; }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); padding: 10px 0 4px; }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 40px; max-height: 140px; height: 40px; padding: 9px 12px; }
.typing { font-size: 12px; color: var(--muted); padding: 0 18px 6px; height: 18px; }

/* ---------- Modal / toast / dropdown ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(15, 15, 18, .42); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 4px; }
.modal-head h2 { flex: 1; font-family: var(--serif); font-weight: 500; font-size: 22px; }
.modal-body { padding: 12px 22px 8px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 22px 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.toasts { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; animation: rise .2s; cursor: pointer; }
.toast.error { background: var(--danger); color: #fff; }
.toast b { display: block; }
.popover { position: absolute; z-index: 60; right: 0; top: calc(100% + 8px); width: 380px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.popover .list-item { padding: 12px 16px; border-top: 1px solid var(--line-2); }
.popover .list-item.unread { background: color-mix(in srgb, var(--en-soft) 55%, transparent); }
.bell { position: relative; }
.bell .badge { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 800; display: grid; place-items: center; }

/* ---------- Flashcards ---------- */
.flash { perspective: 1200px; max-width: 560px; margin: 0 auto; }
.flash-card { min-height: 260px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; cursor: pointer; }
.flash-card .term { font-family: var(--serif); font-size: 38px; letter-spacing: -.02em; line-height: 1.15; }
.flash-card .tr { font-size: 20px; margin-top: 14px; font-weight: 600; }
.flash-card .ex { margin-top: 10px; color: var(--muted); font-style: italic; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.grades .btn { height: 52px; flex-direction: column; gap: 0; line-height: 1.15; }
.grades .btn small { font-weight: 500; font-size: 11.5px; opacity: .7; }

/* ---------- Classroom ---------- */
.room { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-rows: 54px 1fr; background: var(--bg); }
.room-top { display: flex; align-items: center; gap: 12px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.room-top .title { font-weight: 700; }
.room-top .timer { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13px; padding: 4px 9px; border-radius: 7px; background: var(--line-2); }
.room-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 0; }
.room-stage { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; min-width: 0; }
.stage-area { position: relative; min-height: 0; padding: 12px; display: flex; gap: 12px; }
.videos { display: flex; flex-direction: column; gap: 10px; width: 260px; flex: none; }
.room.focus-video .videos { flex: 1; width: auto; flex-direction: row; }
.room.focus-video .board-wrap { display: none; }
.room.focus-video .video-tile { flex: 1; aspect-ratio: auto; }
.video-tile { position: relative; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: #0e0f12; display: grid; place-items: center; }
.video-tile video { width: 100%; height: 100%; object-fit: cover; background: #0e0f12; }
.video-tile.screen video { object-fit: contain; }
.video-tile.self video { transform: scaleX(-1); }
.video-tile.self.screen video { transform: none; }
.video-tile .label { position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px; color: #fff; font-size: 12px; font-weight: 600; background: rgba(0,0,0,.45); padding: 3px 8px; border-radius: 6px; }
.video-tile .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #9a9ca3; font-size: 13px; text-align: center; padding: 10px; }
.video-tile .placeholder .avatar { margin: 0 auto 8px; }
.video-tile .level { position: absolute; right: 8px; bottom: 8px; width: 6px; height: 22px; border-radius: 3px; background: rgba(255,255,255,.2); overflow: hidden; display: flex; align-items: flex-end; }
.video-tile .level i { width: 100%; background: #6cc59c; }
.board-wrap { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.board-tools { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.board-tools .tool { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.board-tools .tool:hover { background: var(--line-2); }
.board-tools .tool.active { background: var(--ink); color: var(--bg); }
.board-tools .swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.board-tools .swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.board-tools .vsep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.board-canvas { position: relative; flex: 1; min-height: 0; background: var(--line-2); touch-action: none; overflow: hidden; }
.board-paper { position: absolute; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); background-image: radial-gradient(circle, #e4e1da 1px, transparent 1.2px); background-size: 24px 24px; }
.board-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.board-canvas .cursor { position: absolute; pointer-events: none; z-index: 5; font-size: 11px; font-weight: 700; color: #fff; background: var(--fr); padding: 1px 6px; border-radius: 6px; transform: translate(8px, 8px); transition: left .08s linear, top .08s linear; }
.board-canvas .cursor::before { content: ''; position: absolute; left: -9px; top: -9px; width: 10px; height: 10px; border-radius: 50%; background: var(--fr); box-shadow: 0 0 0 4px color-mix(in srgb, var(--fr) 30%, transparent); }
.board-canvas textarea.wb-text { position: absolute; z-index: 6; border: 1px dashed #888; background: rgba(255,255,255,.9); color: #111; resize: none; padding: 2px 4px; font-family: var(--font); line-height: 1.25; min-width: 120px; min-height: 30px; outline: none; }
.room-controls { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface); }
.ctl { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.ctl:hover { background: var(--line-2); }
.ctl.off { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctl.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.ctl.leave { width: auto; padding: 0 20px; border-radius: 23px; background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 700; display: flex; gap: 8px; }
.room-side { border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.room-side .tabs { margin: 10px; align-self: flex-start; }
.side-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-pane .msgs { padding: 12px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 14px 14px; }
.vocab-live .item { padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.vocab-live .item b { font-weight: 700; }
.conn-state { font-size: 12px; display: flex; align-items: center; gap: 6px; }

/* ---------- Misc ---------- */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.avail-editor .day-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); align-items: start; }
.avail-editor .intervals { display: flex; flex-direction: column; gap: 6px; }
.avail-editor .interval { display: flex; gap: 6px; align-items: center; }
.avail-editor .interval input { width: 132px; }
.secret { font-family: var(--mono); font-size: 15px; letter-spacing: .08em; padding: 10px 12px; background: var(--line-2); border-radius: 9px; word-break: break-all; user-select: all; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--line-2), var(--line), var(--line-2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.loading { padding: 50px; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .bar i { width: 100%; max-width: 34px; background: var(--ink); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bars .bar span { font-size: 11px; color: var(--muted); }
.mobile-nav { display: none; }
.md-body p:last-child { margin-bottom: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
  .room-body { grid-template-columns: minmax(0, 1fr) 300px; }
  .videos { width: 200px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar { display: none; }
  .mobile-nav {
    display: flex; position: fixed; z-index: 40; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line);
    justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; text-decoration: none; color: var(--muted); padding: 4px 6px; position: relative; }
  .mobile-nav a.active { color: var(--ink); font-weight: 700; }
  .mobile-nav a .count { position: absolute; top: 0; right: 4px; min-width: 15px; height: 15px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 9.5px; display: grid; place-items: center; padding: 0 3px; }
  .page { padding: 4px 16px 90px; }
  .topbar { padding: 10px 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  h1 { font-size: 25px; }
  .entry { grid-template-columns: 1fr; }
  .entry-left { padding: 28px 18px; border-right: 0; border-bottom: 1px solid var(--line); order: 2; }
  .entry-left h1 { font-size: 32px; }
  .entry-right { padding: 28px 16px; order: 1; }
  .facts { grid-template-columns: 1fr; }
  .slot-grid { grid-template-columns: repeat(7, minmax(84px, 1fr)); overflow-x: auto; }
  .cal-wrap { overflow-x: auto; }
  .cal { min-width: 760px; }
  .chat { grid-template-columns: 1fr; height: calc(100vh - 190px); }
  .chat.has-thread .chat-threads { display: none; }
  .chat:not(.has-thread) .chat-main { display: none; }
  .room-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 40vh; }
  .room-side { border-left: 0; border-top: 1px solid var(--line); }
  .stage-area { flex-direction: column; padding: 8px; }
  .videos { width: auto; flex-direction: row; }
  .video-tile { flex: 1; aspect-ratio: 16 / 10; }
  .kv { grid-template-columns: 1fr; }
  .avail-editor .day-row { grid-template-columns: 1fr; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
