:root {
  --bg: #252526; --panel: #252526; --canvas: #2d2d2d; --text: #dcdcdc; --dim: #8a8a8a;
  --btn: #323234; --btn-hover: #3e3e42; --line: #3a3a3c; --accent: #0078d7;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px "Malgun Gothic", "Segoe UI", sans-serif; }
body { display: flex; flex-direction: column; overflow: hidden; }
button { background: var(--btn); color: var(--text); border: 1px solid var(--line); border-radius: 3px;
  padding: 4px 10px; font: inherit; cursor: pointer; }
button:hover:not(:disabled) { background: var(--btn-hover); }
button:disabled { color: #6e6e6e; cursor: default; }
button.on, button.on:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
kbd { color: var(--dim); margin-left: 12px; font: inherit; }

#toolbar { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.menu { position: relative; }
.menu-list { display: none; position: absolute; top: 100%; left: 0; z-index: 10; min-width: 230px;
  background: #2b2b2d; border: 1px solid var(--line); padding: 4px; }
.menu.open .menu-list { display: block; }
.menu-list button { display: flex; justify-content: space-between; width: 100%; border: 0; text-align: left; }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

#main { flex: 1; display: flex; min-height: 0; }
#panel { width: 200px; padding: 10px; display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
#panel label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#panel .hint { color: var(--dim); font-size: 11px; margin: -4px 0 0 22px; }
#panel .gap { margin-top: 14px; }
.dim { color: var(--dim); font-weight: normal; }
#bg-row { display: flex; gap: 6px; }
#bg-row button { padding: 2px 8px; }
#main-area { flex: 1; position: relative; min-width: 0; }
#main-area.drop { outline: 3px dashed var(--accent); outline-offset: -6px; }
#stage { position: absolute; inset: 0; background: var(--canvas); }
#stage[hidden], #people[hidden], .tile[hidden] { display: none; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#people { position: absolute; inset: 0; display: grid; gap: 4px; padding: 2px; background: var(--bg); }
.tile { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--canvas); }
.tile-bar { display: flex; align-items: center; gap: 4px; padding: 3px 6px; background: var(--bg); }
.tile-bar button { padding: 1px 8px; font-size: 12px; }
.tile canvas { flex: 1 1 0; min-height: 0; min-width: 0; width: 100%; display: block; }

#statusbar { display: flex; align-items: center; gap: 12px; padding: 3px 8px; border-top: 1px solid var(--line);
  white-space: nowrap; }
#msg { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#progress { width: 120px; height: 10px; background: var(--btn); border-radius: 5px; overflow: hidden; }
#progress div { width: 40%; height: 100%; background: var(--accent); animation: slide 1.1s infinite linear; }
@keyframes slide { from { margin-left: -40%; } to { margin-left: 100%; } }

.login-page { align-items: center; justify-content: center; }
.login-box { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 280px; }
.login-box h1 { margin: 0; font-size: 20px; }
.login-box input { width: 100%; padding: 8px; background: #1e1e1e; color: var(--text);
  border: 1px solid var(--line); border-radius: 3px; font: inherit; }
.login-box button { width: 100%; padding: 8px; background: var(--accent); border-color: var(--accent); color: #fff; }
.error { color: #ff8080; min-height: 1em; margin: 0; }
