/* te 원격 — a control-room look: dark by default (the screens are the content), light when the
   system asks for it. Sidebar of PCs, a wall of live screens split 1/2/4/8. */
:root {
  --bg: #0e1015; --panel: #151820; --panel-2: #1b1f29; --line: #262b38; --text: #e8eaf0; --muted: #8a91a3;
  --accent: #4f8cff; --accent-2: #2f6ef0; --accent-text: #ffffff; --on: #2fd17a; --busy: #f2a93b; --off: #5b6275;
  --err: #ff6b6b; --shadow: 0 10px 30px rgb(0 0 0 / .35); --screen: #07080b;
  --font: "Pretendard", "Pretendard Variable", system-ui, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f3f5f9; --panel: #ffffff; --panel-2: #f6f7fb; --line: #e2e6ef; --text: #161a22; --muted: #687085;
          --accent: #2f6ef0; --accent-2: #1f5bd6; --on: #16a34a; --busy: #d98a0b; --off: #a3a9b8; --err: #dc2626;
          --shadow: 0 8px 24px rgb(20 30 60 / .08); --screen: #0b0d12; color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.err { color: var(--err); min-height: 1.5em; margin: 6px 0 0; font-size: 13px; }
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { padding: 11px 16px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-text); font-weight: 600; }
.primary:hover { background: var(--accent-2); }
.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; }
.ghost:hover { border-color: var(--muted); }
.ghost.sm { padding: 5px 10px; font-size: 12px; }
label { font-size: 12px; color: var(--muted); }
input[type=password] { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); color: var(--text); font-size: 15px; }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand.big { font-size: 22px; }
.logo { width: 26px; height: 26px; border-radius: 8px; flex: none; position: relative;
  background: linear-gradient(135deg, var(--accent), #8a5cff); box-shadow: 0 4px 14px rgb(79 140 255 / .35); }
.logo::after { content: ""; position: absolute; inset: 7px 6px 9px; border: 2px solid #fff; border-radius: 3px; }
.logo::before { content: ""; position: absolute; left: 9px; right: 9px; bottom: 5px; height: 2px; background: #fff; border-radius: 1px; }
.brand.big .logo { width: 34px; height: 34px; border-radius: 10px; }
.brand.big .logo::after { inset: 9px 8px 12px; }
.brand.big .logo::before { left: 12px; right: 12px; bottom: 7px; }

/* login */
#login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(60% 50% at 50% 0%, rgb(79 140 255 / .18), transparent 70%), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.login-card .muted { margin-bottom: 10px; }

/* shell */
#list { height: 100%; }
.shell { display: grid; grid-template-columns: 248px 1fr; height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px 12px; gap: 6px; min-height: 0; }
.side .brand { padding: 0 8px 14px; }
.side-h { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.count { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.side-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.side-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); text-align: left; }
.side-item:hover { background: var(--panel-2); }
.side-text { display: flex; flex-direction: column; min-width: 0; }
.side-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-sub { font-size: 11px; color: var(--muted); }
.side-item.off .side-name { color: var(--muted); }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 2px; border-top: 1px solid var(--line); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--off); }
.live-dot.on { background: var(--on); box-shadow: 0 0 0 0 rgb(47 209 122 / .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgb(47 209 122 / 0); } 100% { box-shadow: 0 0 0 0 rgb(47 209 122 / 0); } }

/* status dots */
.sdot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--off); }
.on > .sdot, .on .tile-bar .sdot, .side-item.on .sdot { background: var(--on); }
.busy > .sdot, .busy .tile-bar .sdot, .side-item.busy .sdot { background: var(--busy); }

/* main */
.main { min-width: 0; min-height: 0; overflow-y: auto; padding: 22px max(16px, 2.2vw) 28px; display: flex; flex-direction: column; gap: 18px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.top-text { display: flex; flex-direction: column; gap: 4px; }
.seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.seg button { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.g { display: grid; gap: 2px; width: 18px; height: 13px; }
.g b { background: currentColor; border-radius: 1.5px; opacity: .85; }
.g1 { grid-template-columns: 1fr; }
.g2 { grid-template-columns: 1fr 1fr; }
.g4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.g8 { grid-template-columns: repeat(4, 1fr); grid-template-rows: 1fr 1fr; gap: 1.5px; }
.seg button[aria-pressed="true"] .g b { background: var(--accent); opacity: 1; }

/* the wall */
.grid { display: grid; gap: 14px; }
.grid[data-split="1"] { grid-template-columns: 1fr; max-width: min(100%, calc((100vh - 170px) * 16 / 9)); }
.grid[data-split="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid[data-split="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: min(100%, calc((100vh - 200px) * 16 / 9)); }
.grid[data-split="8"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { position: relative; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; transition: border-color .15s, transform .15s, box-shadow .15s; }
.tile:not(.empty):not(.off):hover { border-color: var(--accent); box-shadow: var(--shadow); }
.tile-hit { all: unset; display: block; cursor: pointer; }
.tile.off .tile-hit { cursor: default; }
.screen-wrap { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--screen); }
.screen-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; transition: filter .3s, opacity .3s; }
.veil { position: absolute; inset: 0; display: grid; place-items: center; padding: 0 22px; text-align: center; color: #9aa1b2; font-size: 12px;
  background: repeating-linear-gradient(135deg, rgb(255 255 255 / .02) 0 10px, transparent 10px 20px); }
.tile.stale img { filter: grayscale(1); opacity: .5; }
.tile.stale .screen-wrap::after { content: "화면 멈춤"; position: absolute; top: 10px; right: 10px; font-size: 11px; color: #fff;
  background: rgb(0 0 0 / .55); padding: 2px 8px; border-radius: 6px; }
.tile.busy .screen-wrap::before { content: "사용 중"; position: absolute; z-index: 1; top: 10px; left: 10px; font-size: 11px; font-weight: 700;
  color: #1a1204; background: var(--busy); padding: 2px 8px; border-radius: 6px; }
.tile-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; min-width: 0; }
.tname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tmeta { color: var(--muted); font-size: 12px; white-space: nowrap; margin-right: auto; }
.go { border: 0; border-radius: 8px; padding: 5px 12px; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 600;
  opacity: 0; transition: opacity .15s; }
.tile:hover .go, .go:focus-visible { opacity: 1; }
.grid[data-split="8"] .tile-bar { padding: 7px 10px; }
.grid[data-split="8"] .tmeta { display: none; }
.tile.empty { border-style: dashed; background: transparent; aspect-ratio: auto; }
.tile.empty .empty-text { aspect-ratio: 16 / 9; display: grid; place-content: center; gap: 4px; text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px; }
.tile.empty small { font-size: 11px; opacity: .8; }
.pager { display: flex; justify-content: center; gap: 6px; }
.pg { min-width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-variant-numeric: tabular-nums; }
.pg.cur { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.empty { text-align: center; padding: 40px 16px; }

/* dialog */
dialog { border: 0; padding: 0; background: transparent; color: var(--text); width: min(380px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(4 6 10 / .6); backdrop-filter: blur(3px); }
.dlg { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0 12px; color: var(--text); font-size: 13px; }
.row { display: flex; gap: 8px; justify-content: flex-end; }

/* session */
#session { position: fixed; inset: 0; background: #000; }
#stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#screen { display: block; outline: none; cursor: default; }
/* Top menu: only a small arrow tab until opened */
#topbar { position: absolute; top: 0; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column;
  align-items: center; z-index: 5; max-width: 100vw; }
.tb-panel { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: rgb(18 20 26 / .95);
  color: #e8eaf0; border: 1px solid #2a2f3c; border-top: 0; border-radius: 0 0 12px 12px; font-size: 13px;
  white-space: nowrap; max-width: 100vw; overflow-x: auto; box-shadow: 0 6px 24px rgb(0 0 0 / .45); }
.tb-panel[hidden] { display: none; }
.tb-panel .ghost { color: #e8eaf0; border-color: #3a4050; }
.tb-panel .ghost.danger { color: #ff8a8a; border-color: #5a3036; }
.tb-panel .muted { color: #a3a9b6; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
#sessName { font-weight: 600; }
.tb-tab { width: 46px; height: 18px; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: rgb(18 20 26 / .55); color: #cfd4de; border: 1px solid rgb(255 255 255 / .12); border-top: 0;
  border-radius: 0 0 10px 10px; opacity: .55; transition: opacity .15s, background .15s; }
.tb-tab:hover, .tb-tab:focus-visible, #topbar.open .tb-tab { opacity: 1; background: rgb(18 20 26 / .95); }
#topbar.open .tb-tab svg { transform: rotate(180deg); }
.tb-tab.pulse { animation: tbpulse 1.2s ease-in-out 2; }
@keyframes tbpulse { 50% { opacity: 1; background: #3b6cff; } }
.status { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); color: #ddd; font-size: 15px;
  text-align: center; max-width: 90vw; white-space: pre-line; }

/* narrow screens: sidebar on top, wall in fewer columns */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .side .brand { padding: 0 4px 6px; }
  .side-list { flex-direction: row; overflow-x: auto; flex: none; }
  .side-item { width: auto; white-space: nowrap; }
  .side-foot { border-top: 0; padding: 4px; }
  .grid[data-split="2"], .grid[data-split="4"] { grid-template-columns: 1fr; }
  .grid[data-split="8"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .go { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .live-dot.on { animation: none; } * { transition: none !important; } }
