/* Cabinet styles — same tokens as the public site (terracotta / ivory / petrol, The Leap-style shapes). */
:root {
  --terracotta: #B55F42; --terracotta-dark: #9A4E35; --ivory: #F5F0E6; --canvas: #FBF8F2;
  --petrol: #244C4A; --petrol-2: #2E5C59; --ink: #244C4A; --muted: #5C6E6C; --line: #E4DCCD;
  --wash-terra: #F3E2D9; --wash-petrol: #DCE8E5; --ok: #2F7D5B; --bad: #B23A3A;
  --serif: "Source Serif 4", Georgia, serif; --sans: "Inter", system-ui, sans-serif;
  --r-card: 22px; --r-sm: 12px; --r-pill: 100px; --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; }
body { margin: 0; font: 400 15px/1.5 var(--sans); color: var(--ink); background: var(--canvas); }
h1, h2, h3 { font-family: var(--serif); font-weight: 300; margin: 0 0 .4em; letter-spacing: -0.01em; }
h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.1; }
h2 { font-size: 22px; font-weight: 400; }
h3 { font-size: 20px; font-weight: 400; }
a { color: inherit; }
input, select, textarea { font: inherit; color: inherit; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(181, 95, 66, .2); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--terracotta); }
textarea { resize: vertical; }
code { background: var(--ivory); padding: 1px 6px; border-radius: 6px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: var(--r-pill); border: 1px solid var(--terracotta); background: var(--terracotta); color: #fff;
  font: 600 12px var(--sans); letter-spacing: .06em; text-transform: uppercase; text-decoration: none; cursor: pointer; transition: transform .25s var(--ease), background .2s; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--terracotta-dark); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--petrol); border-color: var(--petrol); }
.btn.ghost:hover:not(:disabled) { background: var(--petrol); color: var(--ivory); }
.btn.ghost.light { color: var(--ivory); border-color: rgba(245, 240, 230, .5); }
.btn.small { padding: 6px 14px; font-size: 11px; }
.icon { background: none; border: 0; cursor: pointer; padding: 4px 8px; border-radius: 8px; font-size: 15px; color: inherit; }
.icon:hover { background: var(--ivory); }
.link-btn { background: none; border: 0; color: var(--terracotta); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }
.small-link { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 6px; }
.small-link:hover { color: var(--terracotta); }
.danger-link { background: none; color: var(--bad); border-color: transparent; margin-top: 24px; }
.muted { color: var(--muted); }
.small, small { font-size: 13px; }
.error { color: var(--bad); margin: 0; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.tag { display: inline-block; font: 600 11px var(--sans); letter-spacing: .06em; text-transform: uppercase; padding: 4px 10px; border-radius: var(--r-pill); background: var(--wash-terra); color: var(--terracotta-dark); vertical-align: middle; }
.tag.warn { background: #FBEBC8; color: #8A5A00; }
.badge { display: inline-block; margin-top: 10px; background: var(--terracotta); color: #fff; border-radius: var(--r-pill); padding: 3px 10px; font-size: 12px; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed var(--line); border-radius: var(--r-card); }

/* layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--petrol); color: var(--ivory); padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.side-logo { display: flex; align-items: center; gap: 8px; font: 300 17px var(--serif); text-decoration: none; padding: 0 8px 20px; white-space: nowrap; }
.side-logo i { color: #E8A58C; }
.side-toggle { display: none; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { padding: 10px 14px; border-radius: var(--r-pill); text-decoration: none; font: 600 12px var(--sans); letter-spacing: .07em; text-transform: uppercase; opacity: .8; }
.side nav a.active, .side nav a:hover { background: var(--petrol-2); opacity: 1; }
.side-user { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(245, 240, 230, .15); display: grid; gap: 4px; }
.side-user small { opacity: .7; margin-bottom: 8px; }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head.sticky { position: sticky; top: 0; z-index: 5; background: var(--canvas); padding: 10px 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.narrow { max-width: 760px; }

.seg { display: inline-flex; background: var(--ivory); border-radius: var(--r-pill); padding: 4px; gap: 2px; margin-bottom: 16px; }
.seg button { border: 0; background: none; padding: 8px 16px; border-radius: var(--r-pill); cursor: pointer; font: 500 13px var(--sans); color: var(--muted); }
.seg button.on { background: #fff; color: var(--petrol); box-shadow: 0 2px 8px -4px rgba(0, 0, 0, .25); }
.seg.small button { padding: 6px 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); padding: 22px; text-decoration: none; transition: transform .35s var(--ease), box-shadow .35s var(--ease); }
.card:hover { transform: translateY(-4px); box-shadow: 0 20px 34px -26px rgba(36, 76, 74, .5); }
.card h3 { margin-top: 12px; }
.card p { margin: 0; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px 22px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.class-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
.class-grid .chat-panel { grid-column: 1 / -1; }
.lesson-row, .person { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--ivory); flex-wrap: wrap; }
.lesson-row .grow small, .person .grow small { display: block; }
.lesson-row .num { width: 26px; height: 26px; border-radius: 50%; background: var(--ivory); display: grid; place-items: center; font-size: 12px; }
.lock { border: 1px solid var(--line); background: var(--ivory); border-radius: var(--r-pill); padding: 5px 12px; cursor: pointer; font-size: 12px; }
.lock.on { background: var(--wash-petrol); border-color: var(--petrol); color: var(--petrol); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--wash-petrol); color: var(--petrol); display: grid; place-items: center; font: 400 17px var(--serif); flex: none; }
.table .person.row { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; margin-bottom: 8px; }
.event-line { margin: 6px 0; }

/* forms + modal */
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field > span { font: 600 11px var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.list-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pick-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 12px; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.inline select { width: auto; padding: 6px 10px; }
.modal-bg { position: fixed; inset: 0; background: rgba(20, 35, 34, .45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .2s; }
.modal { background: var(--canvas); border-radius: var(--r-card); padding: 22px 24px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; animation: rise .3s var(--ease); }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.invite-box { background: var(--wash-petrol); border-radius: var(--r-sm); padding: 14px 16px; }
.invite-box p { margin-top: 0; }
.steps-list { padding-left: 20px; color: var(--muted); }
.course-pick { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 14px; margin-bottom: 8px; background: #fff; }
.course-pick summary { cursor: pointer; display: flex; gap: 10px; align-items: center; padding: 4px 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--petrol); color: var(--ivory); padding: 12px 22px; border-radius: var(--r-pill); z-index: 60; animation: rise .3s var(--ease); box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .4); }
.toast.bad { background: var(--bad); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--ivory); }
.auth-card { background: var(--canvas); border-radius: var(--r-card); padding: 34px 32px; width: min(420px, 100%); display: grid; gap: 12px; text-align: left; box-shadow: 0 30px 60px -40px rgba(36, 76, 74, .5); }
.auth-card img { justify-self: center; }
.auth-card h1 { text-align: center; font-size: 32px; }

/* lesson room + blocks */
.room-top { margin-bottom: 14px; }
.room-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.room-tools .seg { margin: 0; }
.progress-pill { background: var(--wash-petrol); color: var(--petrol); border-radius: var(--r-pill); padding: 6px 12px; font-size: 13px; }
.room-body { display: grid; grid-template-columns: 210px 1fr; gap: 20px; align-items: start; }
.room-body.with-chat { grid-template-columns: 210px 1fr 320px; }
.sections { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 12px; }
.sections button { text-align: left; border: 0; background: none; padding: 9px 14px; border-radius: var(--r-sm); cursor: pointer; font: inherit; color: var(--muted); }
.sections button.on { background: var(--wash-terra); color: var(--terracotta-dark); }
.sections button.add { color: var(--terracotta); }
.room-content { background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); padding: 24px 26px; min-width: 0; }
.room-content.solo { max-width: 860px; }
.room-block { padding: 14px 0; border-bottom: 1px solid var(--ivory); }
.room-block:last-of-type { border-bottom: 0; }
.room-chat { position: sticky; top: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px; }
.teacher-note { margin-top: 8px; display: flex; gap: 8px; align-items: center; }
.block-title { font: 600 14px var(--sans); margin: 0 0 10px; }
.rich { font-size: 16px; }
.carousel img { max-width: 100%; max-height: 420px; border-radius: var(--r-sm); display: block; }
.carousel-nav { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
audio, video { width: 100%; max-width: 640px; border-radius: var(--r-sm); }
.frame { position: relative; width: 100%; aspect-ratio: 16 / 10; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); }
.frame.video { aspect-ratio: 16 / 9; max-width: 720px; }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.words { border-collapse: collapse; width: 100%; }
.words td { padding: 8px 10px; border-bottom: 1px solid var(--ivory); }
.words tr.known { opacity: .5; }
.hanzi { font: 400 22px var(--serif); color: var(--petrol); }
.hanzi.big { font-size: 64px; }
.pinyin { color: var(--terracotta); }
.question { font-size: 17px; margin: 0 0 10px; }
.options { display: grid; gap: 8px; max-width: 520px; }
.option { text-align: left; padding: 12px 16px; border-radius: var(--r-sm); border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; transition: border-color .2s; }
.option:hover:not(:disabled) { border-color: var(--terracotta); }
.option.ok { border-color: var(--ok); background: #E4F2EA; }
.option.bad { border-color: var(--bad); background: #F8E3E3; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { border: 1px solid var(--petrol); background: #fff; color: var(--petrol); border-radius: var(--r-pill); padding: 6px 14px; cursor: pointer; font: 500 15px var(--sans); }
.chip.filled { background: var(--petrol); color: var(--ivory); }
.gap-text { font-size: 18px; line-height: 2.2; }
.gap { min-width: 70px; border: 0; border-bottom: 2px solid var(--terracotta); background: var(--wash-terra); border-radius: 6px 6px 0 0; padding: 2px 10px; cursor: pointer; font: inherit; }
.gap-input, .gap-select { width: auto; min-width: 80px; display: inline-block; padding: 4px 8px; font-size: 16px; }
.row-actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.res { font-size: 13px; font-weight: 600; }
.res.ok { color: var(--ok); }
.res.bad { color: var(--bad); }
.res.wait { color: var(--muted); }
.match { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 0 clamp(40px, 10vw, 120px); max-width: 620px; }
.match-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.match-col { display: grid; gap: 8px; }
.match-item { padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; cursor: pointer; font: 16px var(--sans); text-align: left; position: relative; }
.match-item.sel { border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(181, 95, 66, .25); }
.order-built { min-height: 46px; display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; border: 1px dashed var(--line); border-radius: var(--r-sm); margin-bottom: 10px; align-items: center; }

/* chat */
.chat { display: flex; flex-direction: column; height: 420px; }
.chat-msgs { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px; }
.msg { background: var(--ivory); border-radius: 14px 14px 14px 4px; padding: 8px 12px; max-width: 85%; align-self: flex-start; }
.msg.mine { background: var(--wash-petrol); border-radius: 14px 14px 4px 14px; align-self: flex-end; }
.msg small { display: block; color: var(--muted); font-size: 11px; }
.msg p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg img { max-width: 220px; max-height: 220px; border-radius: 10px; margin-top: 4px; display: block; }
.chat-input { display: flex; gap: 6px; align-items: center; padding-top: 8px; }
.chat-input .icon { cursor: pointer; }

/* editor */
.title-input { font: 300 30px var(--serif); border: 0; border-bottom: 1px dashed var(--line); border-radius: 0; padding: 4px 0; background: transparent; }
.editor-body { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.editor-main { min-width: 0; }
.section-head { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.section-head input { font: 400 20px var(--serif); }
.section-head select { width: auto; }
.edit-block { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 14px 18px; margin-bottom: 14px; position: relative; }
.edit-block-head { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--terracotta-dark); }
.add-between { position: absolute; left: 50%; bottom: -13px; transform: translateX(-50%); font-size: 11px; border: 1px solid var(--line); background: var(--canvas); border-radius: var(--r-pill); padding: 2px 10px; cursor: pointer; opacity: 0; transition: opacity .2s; z-index: 2; }
.edit-block:hover .add-between { opacity: 1; }
.add-block { width: 100%; justify-content: center; border-style: dashed; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.type-card { display: grid; gap: 6px; text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; cursor: pointer; font: 14px var(--sans); transition: transform .25s var(--ease), border-color .2s; }
.type-card:hover { transform: translateY(-2px); border-color: var(--terracotta); }
.type-card span { font-size: 22px; color: var(--terracotta); }
.file-url { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.thumb { width: 54px; height: 40px; object-fit: cover; border-radius: 6px; }

/* schedule */
.week-grid { display: grid; grid-template-columns: 56px repeat(7, minmax(110px, 1fr)); grid-auto-rows: minmax(45px, auto); background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); overflow: auto; max-height: 72vh; }
.wk-corner, .wk-day { position: sticky; top: 0; z-index: 1; background: var(--ivory); }
.week-grid > div { border-right: 1px solid var(--ivory); border-bottom: 1px solid var(--ivory); min-height: 44px; padding: 4px; }
.wk-day { background: var(--ivory); font: 600 12px var(--sans); text-align: center; padding: 10px 4px !important; text-transform: capitalize; }
.wk-day.today { background: var(--wash-terra); color: var(--terracotta-dark); }
.wk-hour { color: var(--muted); font-size: 12px; text-align: right; }
.wk-event { display: block; width: 100%; text-align: left; background: var(--petrol); color: var(--ivory); border: 0; border-radius: 8px; padding: 4px 8px; font-size: 12px; margin-bottom: 3px; cursor: pointer; }
.wk-event:hover { background: var(--terracotta); }

/* dictionary training */
.flash-wrap { display: grid; justify-items: center; gap: 12px; padding: 20px 0; }
.flashcard { width: min(360px, 100%); aspect-ratio: 4 / 3; background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); display: grid; place-content: center; gap: 8px; cursor: pointer; font-size: 22px; box-shadow: 0 20px 40px -30px rgba(36, 76, 74, .6); transition: transform .3s var(--ease); }
.flashcard:hover { transform: translateY(-3px); }
.flashcard.static { cursor: default; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; z-index: 20; }
  .side-logo { padding: 0; }
  .side-toggle { display: block; margin-left: auto; color: var(--ivory); font-size: 22px; }
  .side nav, .side-user { display: none; width: 100%; }
  .side.open nav, .side.open .side-user { display: flex; }
  .side-user { flex-direction: column; }
  .class-grid, .room-body, .room-body.with-chat, .editor-body { grid-template-columns: 1fr; }
  .sections { position: static; flex-direction: row; overflow-x: auto; }
  .sections button { white-space: nowrap; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .room-content { padding: 18px 16px; }
  .match { gap: 0 36px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
