/*
 * 모베레 LMS와 같은 톤앤매너: 토큰과 컨트롤 규격은 LMS의 app/globals.css, src/styles/ui.css를 따른다.
 * 주 버튼은 네이비, 켜짐·활성은 청록, 경고·알림은 코랄. 컨트롤 모서리 8px, 표면 모서리 12px.
 */
:root {
	color-scheme: light;
	--canvas: #f4f6f9;
	--surface: #ffffff;
	--ink: #111827;
	--muted: #6b7280;
	--line: #e7eaf0;
	--accent: #0b6b60;
	--accent-bright: #0e9f8e;
	--accent-soft: #e6f6f3;
	--navy: #0f172a;
	--danger: #c2410c;
	--danger-soft: #fdeee6;
	--coral: #f0573a;
	--video: #0b0f19;
	--live: #22c55e;
	--radius-control: 8px;
	--radius-surface: 12px;
	--control-h: 36px;
	--control-h-sm: 30px;
	--control-h-lg: 44px;
	--shell-top-h: 56px;
	--motion-fast: 180ms;
}
* {
	box-sizing: border-box;
}
[hidden] {
	display: none !important;
}
html,
body {
	margin: 0;
	min-height: 100%;
}
body {
	min-width: 320px;
	background: var(--canvas);
	color: var(--ink);
	font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
	font-size: 14px;
	line-height: 1.5;
}
button,
input,
select {
	font: inherit;
}
a {
	color: var(--accent);
}
h2 {
	margin: 0 0 12px;
	font-size: 15px;
	letter-spacing: -0.2px;
}
.muted {
	color: var(--muted);
}
.status {
	margin: 0;
	color: var(--muted);
	font-size: 12px;
}
.pill {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--canvas);
	color: var(--muted);
	font-size: 11px;
	line-height: 16px;
	white-space: nowrap;
}

/* ---------- 틀: 상단 바 + 본문 ---------- */
.shell {
	display: flex;
	flex-direction: column;
	min-height: 100dvh;
}
.topbar {
	display: flex;
	flex: none;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 12px;
	min-height: var(--shell-top-h);
	padding: 8px 16px;
	border-bottom: 1px solid var(--line);
	background: var(--surface);
}
.topbar h1 {
	margin: 0;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: -0.2px;
	white-space: nowrap;
}
.topbar .muted {
	font-size: 12px;
}
.panel {
	padding: 18px;
	border: 1px solid var(--line);
	border-radius: var(--radius-surface);
	background: var(--surface);
	box-shadow: 0 1px 2px rgb(20 26 43 / 4%);
}
.row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}
.row > h2 {
	flex: 1;
	margin: 0;
}

/* ---------- 컨트롤 ---------- */
button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: var(--control-h);
	padding: 0 14px;
	border: 1px solid var(--line);
	border-radius: var(--radius-control);
	background: var(--surface);
	color: var(--ink);
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
	cursor: pointer;
	transition: background var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}
button:hover {
	border-color: #d3d9e3;
	background: #f8fafc;
}
button:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}
button.primary {
	border-color: var(--navy);
	background: var(--navy);
	color: #fff;
}
button.primary:hover {
	border-color: #1e293b;
	background: #1e293b;
}
button.danger {
	border-color: #f2c7b6;
	color: var(--danger);
}
button.danger:hover {
	border-color: #e9a98f;
	background: var(--danger-soft);
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
	outline: 2px solid var(--accent-bright);
	outline-offset: 2px;
}
input,
select {
	width: 100%;
	height: var(--control-h);
	padding: 0 12px;
	border: 1px solid var(--line);
	border-radius: var(--radius-control);
	background: var(--surface);
	color: var(--ink);
	font-size: 13px;
}
input::placeholder {
	color: #9ca3af;
}
input[type="range"] {
	height: auto;
	padding: 0;
	border: 0;
	background: none;
	accent-color: var(--accent-bright);
}
label {
	display: grid;
	gap: 6px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
}
form {
	display: grid;
	gap: 12px;
}

/* ---------- 입장 화면 ---------- */
.lobby {
	width: min(440px, calc(100% - 32px));
	margin: 32px auto 0;
	padding: 28px;
	box-shadow: 0 18px 50px #173d3012;
}
.lobby h2 {
	margin: 0 0 4px;
	font-size: 20px;
	letter-spacing: -0.4px;
}
.lobby > .muted {
	margin: 0 0 16px;
	font-size: 13px;
}
.lobby input,
.lobby select {
	height: var(--control-h-lg);
	font-size: 14px;
}
.lobby form button {
	width: 100%;
	height: var(--control-h-lg);
	margin-top: 4px;
	font-size: 15px;
}
.lobby .status {
	margin: 8px 0 12px;
}
.room-list,
.participant-list,
.recording-list {
	display: grid;
	gap: 8px;
}
.room-card,
.participant-card,
.recording-card {
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: var(--radius-control);
	background: var(--surface);
}
.room-card {
	display: grid;
	justify-items: start;
	gap: 8px;
	height: auto;
	font-weight: 400;
	line-height: 1.5;
	text-align: left;
	white-space: normal;
}
.room-card.active {
	border-color: var(--accent-bright);
	background: var(--accent-soft);
}

/* ---------- 관제 화면 ---------- */
.layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 330px;
	gap: 16px;
	padding: 22px 26px 28px;
}
.layout .panel + .panel {
	margin-top: 16px;
}
.stage {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 12px;
	margin-top: 12px;
}
.side {
	display: grid;
	gap: 16px;
	align-content: start;
}
.side .panel + .panel {
	margin-top: 0;
}

/* ---------- 영상 타일 ---------- */
.tile {
	position: relative;
	min-height: 180px;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	isolation: isolate;
	border: 1px solid var(--line);
	border-radius: var(--radius-surface);
	background: var(--video);
	color: #fff;
}
.tile-placeholder {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	color: rgb(255 255 255 / 55%);
}
.tile-placeholder svg {
	width: 48px;
	height: 48px;
}
.tile video {
	position: relative;
	z-index: 1;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.tile strong {
	position: absolute;
	inset: auto 10px 10px;
	z-index: 2;
	text-shadow: 0 1px 3px #000;
}
.tile-footer {
	position: absolute;
	inset: auto 8px 6px;
	z-index: 4;
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
	font-size: 12px;
	font-weight: 600;
	text-shadow: 0 1px 3px #000;
}
.tile-name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
/* 마이크 상태: 꺼짐은 코랄 음소거 아이콘, 조용하면 테두리만 있는 마이크, 말하는 중이면 초록으로 채운 마이크. */
.tile-mic {
	display: grid;
	place-items: center;
	flex: none;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: rgb(15 23 42 / 55%);
	color: #fff;
}
.tile-mic[data-state="muted"] {
	background: var(--coral);
}
.tile-mic[data-state="speaking"] {
	color: var(--live);
	box-shadow: 0 0 0 2px rgb(34 197 94 / 55%);
}
.tile-mic[data-state="speaking"] svg rect {
	fill: currentColor;
}
.tile-mic svg {
	width: 13px;
	height: 13px;
}
.tile.screen .tile-placeholder,
.tile.screen .tile-mic {
	display: none;
}
/* 학생에게는 다른 학생의 화면을 반투명 패널로 가린다. */
.tile.blind::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 3;
	background: rgb(15 23 42 / 72%);
	backdrop-filter: blur(14px);
}

/* ---------- 통화 창: 위 썸네일 줄 · 큰 화면 · 아래 버튼 그룹 · 오른쪽 채팅 ---------- */
.call-mode .shell {
	height: 100dvh;
}
.call {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: auto minmax(0, 1fr) auto;
	gap: 10px;
	flex: 1;
	min-height: 0;
	padding: 12px 16px 16px;
}
/* 채팅창을 펼치면 오른쪽 열을 채팅창이 쓰고, 큰 화면과 버튼 그룹은 같은 폭으로 줄어든다. 접으면 둘 다 전체 폭이 된다. */
.call.chat-open {
	grid-template-columns: minmax(0, 1fr) 320px;
}
.thumbs {
	grid-row: 1;
	grid-column: 1 / -1;
	display: flex;
	justify-content: center;
	gap: 10px;
	min-height: 0;
	/* 선택 테두리의 빛이 스크롤 영역에 잘리지 않게 여백을 둔다. */
	padding: 8px;
	margin: -8px -8px 0;
	overflow-x: auto;
}
.thumbs.many {
	justify-content: flex-start;
}
.thumbs .tile {
	flex: 0 0 176px;
	min-height: 0;
	border-radius: var(--radius-control);
}
.thumbs .tile-placeholder svg {
	width: 32px;
	height: 32px;
}
.thumbs .tile.selectable {
	cursor: pointer;
	transition: border-color var(--motion-fast);
}
.thumbs .tile.selectable:hover {
	border-color: var(--accent-bright);
}
/* 큰 화면에 올라가 있는 썸네일은 초록색으로 빛나는 테두리. */
.thumbs .tile.selected {
	border-color: var(--live);
	box-shadow: 0 0 0 2px var(--live), 0 0 10px 1px rgb(34 197 94 / 70%);
}
.main-stage {
	grid-row: 2;
	grid-column: 1;
	position: relative;
	min-height: 0;
	overflow: hidden;
	isolation: isolate;
	border: 1px solid var(--line);
	border-radius: var(--radius-surface);
	background: var(--video);
}
.main-stage .tile {
	position: absolute;
	inset: 0;
	min-height: 0;
	aspect-ratio: auto;
	border: 0;
	border-radius: 0;
}
.main-stage .tile video {
	object-fit: contain;
}
.main-stage .tile-placeholder svg {
	width: 72px;
	height: 72px;
}
.main-stage .tile-footer {
	inset: auto 68px 12px 14px;
	font-size: 14px;
}
.main-stage .tile-mic {
	width: 26px;
	height: 26px;
}
.main-stage .tile-mic svg {
	width: 15px;
	height: 15px;
}
.main-stage:fullscreen {
	border: 0;
	border-radius: 0;
}
/* 큰 화면 오른쪽 아래의 전체 화면 버튼. 영상 위에 놓이므로 어두운 반투명 바탕을 쓴다. */
.stage-action {
	position: absolute;
	right: 12px;
	bottom: 10px;
	z-index: 6;
	border-color: transparent;
	background: rgb(15 23 42 / 55%);
	color: #fff;
}
.stage-action:hover {
	border-color: transparent;
	background: rgb(15 23 42 / 80%);
}
.stage-empty {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	margin: 0;
	color: rgb(255 255 255 / 60%);
}
.controls {
	grid-row: 3;
	grid-column: 1;
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 8px 12px;
	border: 1px solid var(--line);
	border-radius: var(--radius-surface);
	background: var(--surface);
	box-shadow: 0 1px 2px rgb(20 26 43 / 4%);
}
.icon-button {
	position: relative;
	display: inline-grid;
	place-items: center;
	flex: none;
	width: var(--control-h-lg);
	height: var(--control-h-lg);
	padding: 0;
	color: #374151;
}
.icon-button svg {
	width: 20px;
	height: 20px;
}
.icon-button.small {
	width: var(--control-h-sm);
	height: var(--control-h-sm);
	border-color: transparent;
	background: transparent;
	color: var(--muted);
}
.icon-button.small:hover {
	border-color: transparent;
	background: var(--canvas);
	color: var(--ink);
}
.icon-button.small svg {
	width: 18px;
	height: 18px;
}
/* 꺼진 카메라·마이크는 코랄 계열 경고색, 켜진 화면 공유·배경 효과는 청록 활성색. */
.icon-button.off {
	border-color: #f2c7b6;
	background: var(--danger-soft);
	color: var(--danger);
}
.icon-button.recording {
	border-color: var(--coral);
	background: var(--coral);
	color: #fff;
}
.icon-button.active,
.icon-button[aria-expanded="true"] {
	border-color: var(--accent-soft);
	background: var(--accent-soft);
	color: var(--accent);
}
/* 채팅을 접어 둔 동안 새 메시지가 오면 점으로 알린다. */
.icon-button.unread::after {
	content: "";
	position: absolute;
	top: 6px;
	right: 6px;
	width: 9px;
	height: 9px;
	border: 2px solid var(--surface);
	border-radius: 50%;
	background: var(--coral);
}
.audio-panel {
	position: absolute;
	left: 50%;
	bottom: calc(100% + 10px);
	z-index: 10;
	transform: translateX(-50%);
	display: grid;
	gap: 12px;
	max-width: calc(100vw - 24px);
	box-shadow: 0 24px 60px rgb(15 23 42 / 20%);
}
.volume {
	grid-template-columns: 104px minmax(100px, 160px) 44px;
	align-items: center;
	gap: 10px;
	white-space: nowrap;
}
.volume span {
	color: var(--ink);
	font-variant-numeric: tabular-nums;
}
.chat-panel {
	grid-row: 2 / 4;
	grid-column: 2;
	z-index: 5;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	min-height: 0;
	overflow: hidden;
	border: 1px solid var(--line);
	border-radius: var(--radius-surface);
	background: rgb(255 255 255 / 86%);
	backdrop-filter: blur(10px);
}
.chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 8px 8px 14px;
	border-bottom: 1px solid var(--line);
}
.chat-panel h2 {
	margin: 0;
	font-size: 14px;
}
.chat {
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-height: 0;
	overflow-y: auto;
	padding: 14px;
	background: rgb(244 246 249 / 70%);
}
.message {
	align-self: flex-start;
	max-width: 86%;
	padding: 8px 12px;
	border-radius: 12px 12px 12px 2px;
	background: var(--surface);
	font-size: 13px;
	line-height: 1.5;
	overflow-wrap: anywhere;
}
.message small {
	display: block;
	margin-bottom: 2px;
	color: var(--muted);
	font-size: 11px;
}
.message.me {
	align-self: flex-end;
	border-radius: 12px 12px 2px 12px;
	background: var(--navy);
	color: #fff;
}
.message.me small {
	color: rgb(255 255 255 / 70%);
}
.message.me a {
	color: #fff;
}
.composer {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 10px 12px;
	border-top: 1px solid var(--line);
	background: var(--surface);
}
.composer input {
	flex: 1;
	min-width: 0;
	margin: 0 4px;
	border: 0;
	background: var(--canvas);
}
.composer .icon-button.small {
	width: var(--control-h);
	height: var(--control-h);
}
/* 채팅창을 접었을 때 큰 화면 오른쪽 위에 남는 펼치기 버튼. */
.chat-expand {
	grid-row: 2;
	grid-column: 1;
	justify-self: end;
	align-self: start;
	z-index: 5;
	margin: 10px;
}
.call-notice {
	position: absolute;
	inset: 0;
	z-index: 20;
	display: grid;
	place-items: center;
	padding: 16px;
	background: rgb(20 24 34 / 45%);
}
.dialog {
	width: min(420px, 100%);
	padding: 22px;
	border-radius: var(--radius-surface);
	background: var(--surface);
	box-shadow: 0 24px 60px rgb(15 23 42 / 20%);
	text-align: center;
}
.dialog p {
	margin: 0 0 16px;
	font-size: 15px;
	font-weight: 600;
}
.dialog .row {
	justify-content: center;
}

@media (max-width: 900px) {
	.layout {
		grid-template-columns: 1fr;
		padding: 16px;
	}
	.side {
		order: -1;
	}
	/* 좁은 창에서는 열을 나누지 않고 채팅이 큰 화면 위에 반투명으로 겹친다. */
	.call.chat-open {
		grid-template-columns: minmax(0, 1fr);
	}
	.chat-panel {
		grid-row: 2;
		grid-column: 1;
		justify-self: end;
		width: min(320px, 100%);
	}
}
@media (prefers-reduced-motion: reduce) {
	button,
	.thumbs .tile.selectable {
		transition: none;
	}
}
