/* ※ TV(Chromium 69)에서도 읽혀야 한다. 새 CSS 는 쓰지 않는다 — 금지 목록은 scripts/build.mjs 가 검사한다. */
:root {
  --bg: #0e1218;
  --panel: #171d27;
  --line: #2a3342;
  --text: #eef2f7;
  --dim: #9aa7b8;
  --accent: #3b9cff;
  --ok: #37c98b;
  --bad: #ff6b6b;
  --warn: #ffc857;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
}
button:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 156, 255, 0.35); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 700; }
button.danger { background: var(--bad); border-color: var(--bad); color: #2b0606; font-weight: 700; }

input {
  font: inherit;
  color: var(--text);
  background: #0b0f15;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }

.mono { font-family: Consolas, "D2Coding", monospace; font-size: 14px; color: var(--dim); min-height: 1.5em; }
.msg { color: var(--warn); min-height: 1.5em; margin: 8px 0 0; }
.warn { background: rgba(255, 200, 87, 0.12); border: 1px solid var(--warn); border-radius: 10px; padding: 10px 14px; color: var(--warn); }
.lead { color: var(--dim); }

/* ── 폼 페이지(보내기·첫 화면) ── */
.page-form { display: block; padding: 24px 16px; }
.card {
  max-width: 560px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}
.card h1 { margin: 0 0 12px; font-size: 26px; }
.field { display: block; margin: 12px 0; color: var(--dim); font-size: 14px; }
.field input { margin-top: 4px; font-size: 18px; }
#room { font-size: 28px; letter-spacing: 6px; font-family: Consolas, monospace; }
.row { margin: 12px 0; }
.row button { margin: 0 8px 8px 0; }
.status { font-weight: 700; margin: 0 0 4px; }
.preview { width: 100%; background: #000; border-radius: 10px; margin-top: 12px; max-height: 320px; }
.links { list-style: none; padding: 0; margin: 8px 0; }
.links li { padding: 6px 10px; border-left: 4px solid var(--line); margin: 4px 0; color: var(--dim); }
.links li.link-connected { border-left-color: var(--ok); color: var(--text); }
.links li.link-failed { border-left-color: var(--bad); }
.tools { margin-top: 16px; color: var(--dim); font-size: 14px; }
.tools summary { cursor: pointer; }
.menu { list-style: none; padding: 0; margin: 16px 0 0; }
.menu li { margin: 10px 0; }
.menu a { display: block; padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; }
.menu a:focus, .menu a:hover { border-color: var(--accent); outline: none; }
.menu b { display: block; font-size: 18px; }
.menu span { color: var(--dim); font-size: 14px; }

/* ── TV 화면 ── */
.page-tv { overflow: hidden; }
.tv-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 44px;
  padding: 0 20px; line-height: 44px;
  background: rgba(14, 18, 24, 0.92); border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; z-index: 3;
}
.tv-bar span { margin-right: 24px; }
.brand { font-weight: 800; color: var(--accent); }
.bar-room { font-family: Consolas, monospace; font-size: 20px; font-weight: 700; }
.bar-count { color: var(--dim); }
.bar-link { color: var(--warn); }
.tv-help {
  position: absolute; bottom: 0; left: 0; right: 0; height: 32px; line-height: 32px;
  padding: 0 20px; font-size: 14px; color: var(--dim);
  background: rgba(14, 18, 24, 0.92); border-top: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; z-index: 3;
}
.idle {
  position: absolute; top: 44px; bottom: 32px; left: 0; right: 0;
  padding: 4vh 8vw; overflow: auto;
}
.idle-lead { font-size: 4vh; font-weight: 800; margin: 0 0 2vh; }
.idle-steps { font-size: 3vh; margin: 0; padding-left: 1.4em; }
.idle-steps li { margin-bottom: 3vh; }
.addresses { list-style: none; padding: 0; margin: 1vh 0 0; font-family: Consolas, monospace; font-size: 4vh; color: var(--accent); }
.room-code { font-family: Consolas, monospace; font-size: 16vh; font-weight: 800; letter-spacing: 1vw; line-height: 1.2; }
.idle-hint { color: var(--warn); font-size: 2.2vh; }
.ask-input { width: 12em; font-size: 4vh; letter-spacing: 0.3em; font-family: Consolas, monospace; margin-right: 12px; }

.wall {
  position: absolute; top: 44px; bottom: 32px; left: 0; right: 0;
  display: grid; grid-gap: 6px; padding: 6px;
  grid-auto-rows: 1fr;
}
.wall.cols-1 { grid-template-columns: 1fr; }
.wall.cols-2 { grid-template-columns: 1fr 1fr; }
.wall.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.wall.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.tile {
  position: relative; overflow: hidden; min-height: 0; min-width: 0;
  background: #000; border: 4px solid transparent; border-radius: 10px;
}
.tile.focus { border-color: var(--accent); }
.wall.big .tile { border-color: transparent; }
.tile video, .tile img {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000;
}
.tile video { z-index: 1; background: transparent; }
.tile-wait {
  position: absolute; top: 50%; left: 0; right: 0; margin-top: -0.75em;
  text-align: center; color: var(--dim); font-size: 2.4vh;
}
.tile-label {
  position: absolute; left: 10px; bottom: 10px; z-index: 2;
  padding: 2px 12px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.65); font-size: 2.2vh; font-weight: 700;
  max-width: 80%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile-stat {
  position: absolute; right: 10px; top: 10px; z-index: 2;
  padding: 2px 10px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.65); font-family: Consolas, monospace; font-size: 1.8vh; color: var(--ok);
}
.notice {
  position: absolute; left: 50%; bottom: 56px; z-index: 4;
  transform: translateX(-50%);
  padding: 10px 24px; border-radius: 12px;
  background: rgba(59, 156, 255, 0.95); color: #04121f; font-weight: 700; font-size: 2.4vh;
}

/* ── 진단 ── */
.page-diag { padding: 24px; overflow: auto; }
.diag { max-width: 1100px; margin: 0 auto; }
.diag h1 { margin: 0 0 8px; }
.diag-actions button { margin: 0 8px 8px 0; }
.diag-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.diag-table th, .diag-table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; word-break: break-word; }
.diag-table th { color: var(--dim); font-weight: 600; font-size: 14px; }
.diag-table td.c { white-space: nowrap; color: var(--dim); }
.diag-table tr.v-ok td:last-child { color: var(--ok); }
.diag-table tr.v-fail td:last-child { color: var(--bad); }
.diag-table tr.v-unknown td:last-child { color: var(--warn); }
.diag-stage { margin-top: 16px; }
.diag-video { width: 240px; height: 135px; background: #000; margin: 0 8px 8px 0; border-radius: 6px; }

/* ── 여러 화면 시험 ── */
.multi-grid { margin-top: 16px; }
.multi-frame { width: 420px; height: 520px; border: 1px solid var(--line); border-radius: 10px; margin: 0 10px 10px 0; background: var(--panel); }

/* ── 설치한 TV 앱의 첫 화면 ── */
.page-launch { padding: 6vh 8vw; }
.launch h1 { font-size: 5vh; margin: 0 0 1vh; }
.launch .lead { font-size: 2.4vh; }
.launch .field { font-size: 2.4vh; margin: 3vh 0 1vh; }
.launch input { font-size: 4vh; font-family: Consolas, monospace; max-width: 22em; }
.launch-status { font-size: 2.4vh; min-height: 1.5em; margin: 1vh 0 2vh; }
.launch-status.ok { color: var(--ok); }
.launch-status.bad { color: var(--bad); }
.launch-menu button { display: block; width: 100%; max-width: 36em; text-align: left; font-size: 2.8vh; margin: 0 0 1.4vh; padding: 1.6vh 2vh; }
.launch-menu button span { display: block; font-size: 1.9vh; color: var(--dim); font-weight: 400; }
.launch-menu button.primary span { color: #04121f; }

.bar-out { color: var(--ok); }

/* ── TV 교실·모둠 고르기 ── */
.place-name { font-size: 3.4vh; font-weight: 800; color: var(--accent); margin: 0 0 1vh; min-height: 1em; }
.place-hint { font-size: 2.4vh; color: var(--dim); margin: 0.6vh 0; }
.setup-btn { margin-top: 2vh; font-size: 2.2vh; }
.setup-msg { font-size: 2.6vh; color: var(--warn); min-height: 1.5em; }
.setup-school .field { display: inline-block; width: 22em; margin-right: 12px; }
.setup-school input { font-size: 3.4vh; letter-spacing: 0.2em; font-family: Consolas, monospace; }
.setup-list button, .setup-groups button { display: inline-block; margin: 0 1.2vh 1.2vh 0; font-size: 3vh; padding: 1.6vh 3vh; min-width: 12em; text-align: left; }
.setup-groups { margin-top: 2vh; border-top: 1px solid var(--line); padding-top: 2vh; }
.setup-groups button { min-width: 8em; text-align: center; }
.setup-free { color: var(--dim); }
/* ── 학생: 교실·모둠 고르기 ── */
.pick select { font: inherit; font-size: 18px; color: var(--text); background: #0b0f15; border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; margin-top: 4px; }
.pick select:focus { outline: none; border-color: var(--accent); }
.link-btn { background: none; border: none; color: var(--accent); padding: 4px 0; text-decoration: underline; }
