* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #181a1b;
  color: #e8e6e3;
}
#app { height: 100%; }
h1 { font-size: 1.3rem; } h2 { font-size: 1.05rem; margin: 0.4em 0; } h3 { font-size: 1rem; } h4 { margin: 0.5em 0 0.3em; }
a { color: #7cb8f7; }
code { background: #26292b; padding: 1px 5px; border-radius: 4px; }
input, select {
  background: #232627; color: inherit; border: 1px solid #3c4043; border-radius: 6px; padding: 6px 8px;
}
input[type="color"] { padding: 1px; width: 36px; height: 26px; }
input[type="checkbox"] { width: auto; }
input[type="range"] { width: 100%; padding: 0; }
label { display: flex; flex-direction: column; gap: 4px; }

.btn {
  background: #2c3032; color: inherit; border: 1px solid #43484b; border-radius: 6px;
  padding: 6px 12px; cursor: pointer; font: inherit;
}
.btn:hover { background: #383d40; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: #2d5d8e; border-color: #3a76b5; }
.btn-primary:hover { background: #366ea8; }
.btn-danger { background: #7a2d2d; border-color: #a04343; }
.btn-danger:hover { background: #934040; }
.btn-small { padding: 3px 9px; font-size: 12.5px; }

.row { display: flex; align-items: center; flex-direction: row; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.right { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: #9a9a93; }
.pad { padding: 10px 16px; }
.banner { background: #5d4a1f; padding: 8px 16px; }

.topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  background: #202324; border-bottom: 1px solid #33383b;
}
.brand { font-weight: 600; }
.page { max-width: 1100px; margin: 0 auto; }

.tabbar { display: flex; gap: 2px; }
.tab { background: none; border: none; color: #9a9a93; padding: 6px 12px; cursor: pointer; font: inherit; border-radius: 6px; }
.tab.selected { color: #e8e6e3; background: #2c3032; }

.table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.table th, .table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid #2c3032; vertical-align: top; }
.table th { color: #9a9a93; font-weight: 500; }
.row-inactive { opacity: 0.5; }
.row-bad td { background: #3a2626; }
.assignment-row { margin: 2px 0; }
.codeblock { background: #232627; padding: 8px 12px; border-radius: 6px; overflow-x: auto; }

.spec-card { background: #202324; border-radius: 10px; padding: 12px 16px; margin: 12px 0; }

.tile-list { display: flex; flex-direction: column; gap: 4px; }
.tile-row {
  display: flex; align-items: center; gap: 12px; padding: 7px 12px;
  background: #202324; border-radius: 8px;
}
.tile-name { flex: 1; font-weight: 500; }

.login-wrap { display: flex; height: 100%; align-items: center; justify-content: center; }
.login-card {
  display: flex; flex-direction: column; gap: 12px; width: 300px;
  background: #202324; padding: 28px; border-radius: 12px; border: 1px solid #33383b;
}
.form-error { color: #f28b82; min-height: 1.2em; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #232627; border: 1px solid #3c4043; border-radius: 12px;
  padding: 20px 24px; max-width: 420px; width: 90%;
  max-height: 88vh; overflow-y: auto;
}
.modal:has(.help) { max-width: 640px; }
.help-section h3 { margin: 14px 0 4px; color: #b8c4cc; }
.help-table { border-collapse: collapse; width: 100%; }
.help-table td { padding: 4px 8px 4px 0; vertical-align: top; border-bottom: 1px solid #2c3032; }
.help-key { white-space: nowrap; font-weight: 600; color: #7cb8f7; width: 1%; padding-right: 14px; }
.modal form { display: flex; flex-direction: column; gap: 10px; }
.pw-box { display: flex; gap: 10px; align-items: center; background: #181a1b; padding: 10px 14px; border-radius: 8px; }
.pw-box code { font-size: 1.15em; background: none; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: #2d5d8e; color: #fff; padding: 9px 18px; border-radius: 8px;
  opacity: 0; transition: all 0.25s; z-index: 200; max-width: 80vw;
}
.toast-error { background: #93403f; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- editor ---------- */
.editor-canvas {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  touch-action: none; display: block;
}
.editor-canvas[data-mode="draw"], .editor-canvas[data-mode="paint"] { cursor: crosshair; }
.editor-canvas[data-mode="delete"] { cursor: pointer; }
.editor-canvas[data-mode="reclass"] { cursor: pointer; }
.editor-canvas[data-mode="move"] { cursor: grab; }

.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hud > * { pointer-events: auto; }

.hamburger {
  position: absolute; top: 10px; left: 10px; width: 40px; height: 40px;
  border-radius: 50%; border: 1px solid #43484b; background: rgba(32,35,36,0.92);
  color: #e8e6e3; font-size: 18px; cursor: pointer;
}
.statusbar {
  position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; align-items: center;
  flex-wrap: wrap; justify-content: flex-end; max-width: 70vw;
}
.chip {
  background: rgba(32,35,36,0.92); border: 1px solid #43484b; border-radius: 14px;
  padding: 4px 12px; font-size: 12.5px;
}
.chip-name { font-weight: 600; }
.chip-warn { border-color: #b58a2e; color: #ecc35e; }
.chip-bad { border-color: #a04343; color: #f28b82; }
.chip-ro { border-color: #b58a2e; color: #ecc35e; }
.chip-clickable { cursor: pointer; }

.classbar {
  position: absolute; left: 10px; top: 64px; display: flex; flex-direction: column;
  gap: 7px; align-items: center;
}
.classdot {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.25);
  cursor: pointer; padding: 0;
}
.classdot.selected { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.28); }
.classdot-small { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 8px; vertical-align: -2px; }
.toolbtn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid #43484b;
  background: rgba(32,35,36,0.92); color: #e8e6e3; cursor: pointer; font-size: 16px;
}
.toolbtn.selected { background: #2d5d8e; border-color: #3a76b5; }
.sep { height: 8px; }

.menu-panel {
  position: absolute; top: 58px; left: 10px; width: 320px; max-width: calc(100vw - 20px);
  max-height: calc(100vh - 76px); overflow-y: auto;
  background: rgba(28,31,32,0.97); border: 1px solid #3c4043; border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.menu-panel.hidden { display: none; }
.menu-panel .classbar-offset { margin-left: 46px; }
.menu-row { display: flex; flex-direction: column; gap: 4px; }
.menu-row.row { flex-direction: row; align-items: center; gap: 8px; }
.menu-classes { display: flex; flex-direction: column; gap: 2px; }
.menu-class {
  display: flex; align-items: center; text-align: left; background: none; border: none;
  color: inherit; padding: 5px 8px; border-radius: 6px; cursor: pointer; font: inherit;
}
.menu-class:hover { background: #2c3032; }
.menu-class.selected { background: #2d5d8e; }
.menu-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.keyshelp { font-size: 11.5px; }

@media (max-width: 700px) {
  .classbar { top: auto; bottom: 12px; left: 10px; flex-direction: row; flex-wrap: wrap; max-width: calc(100vw - 20px); }
  .menu-panel { top: 58px; }
  .statusbar { max-width: calc(100vw - 70px); }
}
