/* LectureRoom - chalkboard green, chalk white, one chalk-yellow accent. */
:root {
  --board: #10241d;
  --board-2: #16322a;
  --board-3: #1e4036;
  --line: #2d5143;
  --chalk: #f3efe2;
  --muted: #9db4a8;
  --yellow: #f4cf57;
  --yellow-ink: #2a2204;
  --red: #e8604c;
  --ok: #6fd49b;
  --display: "Bitter", Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--board); color: var(--chalk); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { display: block; }

/* ---------------------------------------------------------------- shared */
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 20px; text-decoration: none; letter-spacing: .2px; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--yellow); color: var(--yellow-ink); display: grid; place-items: center; }
.brand.small { font-size: 18px; margin-bottom: 22px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px; border-radius: 10px; border: 1px solid var(--line); background: var(--board-3); font-weight: 600; text-decoration: none; }
.btn:hover { background: #26503f; }
.btn.accent { background: var(--yellow); color: var(--yellow-ink); border-color: var(--yellow); }
.btn.accent:hover { background: #ffdc6a; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field em { font-style: normal; opacity: .8; }
.field input, .joinbox input { width: 100%; min-height: 46px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--board-2); }
.field input::placeholder, .joinbox input::placeholder { color: #6f8a7d; }
.field input:focus, .joinbox input:focus { outline: none; border-color: var(--yellow); }

/* ---------------------------------------------------------------- home */
.home .top { max-width: 1120px; margin: 0 auto; padding: 22px 24px 0; }
.home main { max-width: 1120px; margin: 0 auto; padding: 40px 24px 64px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 56px; align-items: center; min-height: calc(100dvh - 80px); }
.home h1 { font-family: var(--display); font-size: clamp(34px, 5vw, 56px); line-height: 1.08; margin: 0 0 18px; font-weight: 700; letter-spacing: -.5px; }
.lede { font-size: 18px; color: #cfdcd4; max-width: 34em; margin: 0 0 28px; }
.notice { background: #3b3317; border: 1px solid #6e5d1e; padding: 12px 14px; border-radius: 10px; margin: 0 0 22px; font-size: 14px; max-width: 34em; }
.notice code { background: rgba(0,0,0,.25); padding: 1px 6px; border-radius: 5px; }
.start { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; max-width: 34em; }
.start .field { margin: 0; }
.joinbox { display: flex; gap: 10px; max-width: 34em; margin-top: 18px; }
.joinbox button { min-height: 46px; padding: 0 20px; border-radius: 10px; border: 1px solid var(--line); background: var(--board-3); font-weight: 600; }
.joinbox button:not(:disabled):hover { background: #26503f; }
.joinbox button:disabled { opacity: .45; cursor: not-allowed; }
.err { color: #ffa093; min-height: 22px; margin-top: 10px; font-size: 14px; }
.recent { margin-top: 18px; }
.recent h2 { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.recent a { display: inline-block; margin: 0 8px 8px 0; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; font-size: 14px; background: var(--board-2); }
.recent a:hover { border-color: var(--yellow); }

.hall { background: var(--board-2); border: 1px solid var(--line); border-radius: 18px; padding: 22px 22px 18px; }
.board { background: #0b1b15; border: 6px solid #5a4a30; border-radius: 6px; padding: 26px 18px; text-align: center; margin-bottom: 22px; box-shadow: inset 0 0 40px rgba(0,0,0,.45); }
.chalk { font-family: var(--display); font-size: clamp(18px, 2.4vw, 26px); color: var(--chalk); opacity: .92; }
.seats { display: grid; grid-template-columns: repeat(10, 1fr); gap: 12px; padding: 0 6px; }
.seats i { aspect-ratio: 1; border-radius: 50%; background: #254a3d; display: block; animation: seat-in .5s ease-out both; animation-delay: var(--d); }
.seats i:nth-child(3n) { animation-name: seat-on; }
@keyframes seat-in { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes seat-on { 0% { transform: scale(.4); opacity: 0; background: #254a3d; } 60% { transform: none; opacity: 1; background: #254a3d; } 100% { background: var(--yellow); } }
.caption { text-align: center; color: var(--muted); font-size: 14px; margin: 18px 0 0; }
@media (prefers-reduced-motion: reduce) { .seats i { animation: none; } .seats i:nth-child(3n) { background: var(--yellow); } }
@media (max-width: 860px) { .home main { grid-template-columns: 1fr; gap: 36px; min-height: 0; } .start { grid-template-columns: 1fr; } .start .btn { width: 100%; } }

/* ---------------------------------------------------------------- lobby */
body.room { overflow: hidden; }
#lobby { height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 40px; align-items: center; max-width: 1100px; margin: 0 auto; padding: 24px; }
#lobby:has(#previewBox[hidden]) { grid-template-columns: minmax(0, 480px); justify-content: center; }
.preview { position: relative; aspect-ratio: 16 / 10; background: #0b1b15; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview .off-msg { position: absolute; inset: 0; display: grid; place-items: center; background: #0b1b15; color: var(--muted); }
.preview .bar { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; justify-content: center; gap: 12px; }
.lobby-side h1 { font-family: var(--display); font-size: 32px; line-height: 1.15; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.lobby-err { color: #ffa093; min-height: 22px; font-size: 14px; margin-bottom: 8px; }
.lobby-side .btn { width: 100%; margin-top: 4px; }
.fine { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
@media (max-width: 820px) { #lobby { grid-template-columns: 1fr; align-content: center; gap: 20px; overflow-y: auto; } }

/* ---------------------------------------------------------------- controls */
.ctl { position: relative; min-width: 48px; height: 48px; padding: 0 12px; border-radius: 999px; background: var(--board-3); display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); flex: none; }
.ctl:hover { background: #26503f; }
.ctl.off { background: var(--red); border-color: var(--red); color: #fff; }
.ctl.on { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.ctl.leave { background: var(--red); border-color: var(--red); color: #fff; width: 64px; }
.ctl.leave svg { transform: rotate(135deg); }
.ctl.endall { background: transparent; border-color: var(--red); color: #ffb0a5; font-weight: 600; padding: 0 16px; }
.ctl.endall:hover { background: rgba(232, 96, 76, .15); }
.ctl.hand .emoji { font-size: 20px; line-height: 1; }
.ctl.hand .lbl { font-weight: 600; font-size: 15px; }
.ctl .count { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--yellow); color: var(--yellow-ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; }

/* ---------------------------------------------------------------- class room */
#meeting { height: 100dvh; display: flex; flex-direction: column; background: var(--board); }
#topbar { flex: none; height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; padding-top: env(safe-area-inset-top, 0); border-bottom: 1px solid var(--line); gap: 12px; }
.t-left, .t-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; letter-spacing: .6px; background: rgba(232, 96, 76, .16); color: #ffb0a5; padding: 4px 10px; border-radius: 999px; flex: none; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.cls-title { font-family: var(--display); font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count, .clock { color: var(--muted); font-size: 14px; white-space: nowrap; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.link-btn:hover { background: var(--board-2); color: var(--chalk); }
.link-btn svg { width: 18px; height: 18px; }

#banner { background: #5a3a14; text-align: center; padding: 6px; font-size: 14px; flex: none; }
#audioBanner { background: var(--yellow); color: var(--yellow-ink); font-weight: 600; padding: 8px; flex: none; }

#main-wrap { flex: 1; min-height: 0; display: flex; }
#stage { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 12px; }
#main { flex: 1; min-height: 0; position: relative; display: flex; }
#main > .tile { flex: 1; min-width: 0; }
#waiting { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); font-family: var(--display); font-size: 22px; border: 1px dashed var(--line); border-radius: 14px; }
#strip { flex: none; display: flex; gap: 10px; overflow-x: auto; }
#strip:empty { display: none; }
#strip .tile { flex: none; width: 190px; aspect-ratio: 16 / 9; cursor: pointer; }

.tile { position: relative; background: var(--board-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #0b1b15; }
.tile.screen video { object-fit: contain; background: #000; }
.tile.mirror video { transform: scaleX(-1); }
.tile.speaking { box-shadow: 0 0 0 3px var(--yellow); }
.tile .avatar { position: absolute; inset: 0; display: none; place-items: center; background: var(--board-2); }
.tile.novideo .avatar { display: grid; }
.tile .avatar span { width: 25%; min-width: 44px; max-width: 120px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: clamp(20px, 4vw, 44px); color: #18261f; }
.tile .card { position: absolute; inset: 0; display: none; place-items: center; background: var(--board-2); color: var(--muted); text-align: center; padding: 12px; }
.tile.selfshare .card { display: grid; }
.tile.selfshare video { visibility: hidden; }
.nm-bar { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); display: flex; align-items: center; gap: 6px; background: rgba(8, 20, 15, .72); padding: 3px 10px; border-radius: 999px; font-size: 13px; }
.nm-bar .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm-bar .role { background: var(--yellow); color: var(--yellow-ink); font-weight: 700; font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.nm-bar .mico svg { width: 15px; height: 15px; color: #ff9d8f; }

/* panel */
#panel { width: 350px; flex: none; border-left: 1px solid var(--line); display: flex; flex-direction: column; background: var(--board-2); min-height: 0; }
.tabs { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; padding: 14px 8px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--chalk); border-bottom-color: var(--yellow); }
.tabs .x { flex: 0 0 48px; font-size: 24px; line-height: 1; }
.badge { background: var(--yellow); color: var(--yellow-ink); font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 9px; margin-left: 4px; }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#chatList { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); font-size: 14px; text-align: center; margin-top: 20px; }
.msg { max-width: 92%; align-self: flex-start; }
.msg.mine { align-self: flex-end; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .meta b { color: var(--chalk); margin-right: 6px; }
.msg.lec .meta b { color: var(--yellow); }
.msg .txt { background: var(--board-3); padding: 7px 11px; border-radius: 12px; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.mine .txt { background: #2b5a46; }
.msg.lec .txt { border: 1px solid #6e5d1e; }
.locked-note { padding: 8px 14px; color: #ffcf9a; font-size: 13px; text-align: center; border-top: 1px solid var(--line); }
#chatForm { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
#chatForm input { flex: 1; min-width: 0; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--board); }
#chatForm input:focus { outline: none; border-color: var(--yellow); }
#chatForm input:disabled { opacity: .5; }
#chatForm button { width: 42px; border-radius: 10px; background: var(--yellow); color: var(--yellow-ink); display: grid; place-items: center; }
#chatForm button:disabled { opacity: .45; }
#chatForm svg { width: 20px; height: 20px; }

.search { padding: 10px; border-bottom: 1px solid var(--line); }
.search input { width: 100%; min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--board); }
.search input:focus { outline: none; border-color: var(--yellow); }
#peopleList { flex: 1; overflow-y: auto; padding: 6px 0; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.person:hover { background: rgba(255, 255, 255, .03); }
.person .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #18261f; flex: none; font-family: var(--display); }
.person .who { flex: 1; min-width: 0; line-height: 1.25; }
.person .who .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .who small { color: var(--muted); font-size: 12px; }
.person.hand-up { background: rgba(244, 207, 87, .08); }
.person.speaking .dot { box-shadow: 0 0 0 2px var(--yellow); }
.person .ic { font-size: 16px; }
.person .ic svg { width: 17px; height: 17px; color: #ff9d8f; }
.pbtn { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--board-3); white-space: nowrap; }
.pbtn:hover { background: #26503f; }
.pbtn.go { background: var(--yellow); color: var(--yellow-ink); border-color: var(--yellow); }
.pbtn.danger { border-color: transparent; background: transparent; color: #ffb0a5; padding: 5px 7px; }
.panel-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.more { text-align: center; color: var(--muted); font-size: 13px; padding: 10px; }

/* controls bar */
#controls { flex: none; height: 76px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 16px; padding-bottom: env(safe-area-inset-bottom, 0); border-top: 1px solid var(--line); gap: 10px; }
.center-ctl { display: flex; gap: 10px; align-items: center; }
.right-ctl { display: flex; gap: 10px; justify-content: flex-end; }
.quality select { background: var(--board-3); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 14px; }

/* toasts + goodbye */
#toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: #f3efe2; color: #14261f; padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
#goodbye { position: fixed; inset: 0; z-index: 60; background: var(--board); display: grid; place-items: center; text-align: center; padding: 24px; }
#goodbye h1 { font-family: var(--display); font-size: 34px; margin: 0 0 10px; }
#goodbye p { color: var(--muted); margin: 0 0 24px; }
#goodbye .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* small screens */
@media (max-width: 860px) {
  #panel { position: fixed; z-index: 30; left: 0; right: 0; top: 54px; bottom: 76px; width: auto; border-left: 0; }
  #strip .tile { width: 130px; }
  .t-right .clock, .t-right .link-btn .lbl { display: none; }
  .ctl.hand .lbl { display: none; }
  .ctl.endall { font-size: 13px; padding: 0 12px; }
  #controls { grid-template-columns: auto 1fr auto; padding: 0 10px; }
  .left-ctl { max-width: 120px; }
  .quality select { max-width: 120px; padding: 8px 6px; font-size: 13px; }
}
@media (max-width: 520px) { .center-ctl { gap: 6px; } .ctl { min-width: 44px; height: 44px; } .ctl.leave { width: 52px; } }
