:root {
  --bg: #0f1724; --panel: #172235; --panel2: #1d2b42; --line: #2a3b57; --text: #e6edf7; --muted: #8fa3bf;
  --blue: #2f6fd6; --blue2: #4b8bf0; --amber: #e5a00d; --red: #d64545; --green: #2fae6a;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Tahoma, "Sarabun", "Noto Sans Thai", system-ui, sans-serif; }
button, input, select { font: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.err { color: #ff8b8b; min-height: 1.4em; margin: 8px 0 0; }
.brand { font-size: 18px; letter-spacing: .2px; }
.brand b { color: var(--blue2); }

button { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button:hover { border-color: var(--blue2); }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; padding: 8px 14px; }
button.danger { background: var(--red); border-color: var(--red); color: #fff; }
button.link { background: none; border: 0; color: var(--muted); padding: 2px 6px; }
button.link:hover { color: var(--text); }
select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }

/* login */
.login { height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.card label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.card input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.card input:focus { outline: none; border-color: var(--blue2); }

/* app */
.app { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 18px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top nav { display: flex; gap: 4px; }
.tab { background: none; border: 0; color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.tab.on { background: var(--panel2); color: var(--text); }
.badge { background: var(--amber); color: #000; border-radius: 9px; padding: 0 6px; font-size: 12px; margin-left: 4px; }
.me { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); display: inline-block; }
.dot.ok { background: var(--green); }

.split { flex: 1; display: flex; min-height: 0; }
.queue { width: 300px; flex: none; border-right: 1px solid var(--line); overflow-y: auto; background: var(--panel); }
.queue ul { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.req { background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 8px; padding: 10px; }
.req.taken { border-left-color: var(--green); opacity: .75; }
.req.mine { border-left-color: var(--blue2); opacity: 1; }
.req .row1 { display: flex; align-items: center; gap: 6px; }
.req .app { font-size: 11px; text-transform: uppercase; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--muted); }
.req .place { font-weight: bold; }
.req .age { margin-left: auto; font-size: 12px; color: var(--muted); }
.req .who, .req .host { font-size: 12px; color: var(--muted); }
.req .note { margin: 4px 0; white-space: pre-wrap; }
.req button { margin-top: 6px; width: 100%; }

.viewer { flex: 1; display: flex; min-width: 0; min-height: 0; }
.idle { margin: auto; }
.session { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.bar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.sinfo { font-size: 13px; }
.sinfo b { color: var(--blue2); }
.tools { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.toggle { display: flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
.stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; background: #05080d; min-height: 0; overflow: hidden; }
.stage canvas { max-width: 100%; max-height: 100%; outline: none; image-rendering: auto; background: #000; }
.stage canvas.control { cursor: crosshair; }
.stage canvas:focus { box-shadow: 0 0 0 2px var(--blue2); }
.stage-note { position: absolute; color: var(--muted); pointer-events: none; }
.rcur { position: absolute; width: 14px; height: 20px; pointer-events: none; margin: -1px 0 0 -1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 20'%3E%3Cpath d='M1 1v15l4-4 3 7 3-1-3-7h5z' fill='white' stroke='black' stroke-width='1.2' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat; }
.session:fullscreen .stage { background: #000; }

.log { flex: 1; overflow: auto; padding: 12px; }
.log table { border-collapse: collapse; width: 100%; font-size: 13px; }
.log th, .log td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.log th { color: var(--muted); font-weight: normal; position: sticky; top: 0; background: var(--bg); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; box-shadow: 0 6px 24px rgba(0,0,0,.4); z-index: 10; }

@media (max-width: 760px) {
  .split { flex-direction: column; }
  .queue { width: auto; max-height: 40%; border-right: 0; border-bottom: 1px solid var(--line); }
}
