:root {
  --bg: #1b1d21;
  --panel: #24272c;
  --panel-2: #2c3036;
  --line: #3a3f47;
  --text: #e6e8eb;
  --muted: #9aa1ab;
  --accent: #4c9bff;
  --danger: #e25555;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button, select, input, textarea {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 5px; padding: 4px 8px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
a { color: var(--accent); }

#app { display: grid; grid-template-columns: 290px 1fr 300px; height: 100vh; }
aside { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); overflow-y: auto; }
.panel-head {
  padding: 8px 10px; font-weight: 600; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 6px;
}
.panel-head .toggle { margin-left: auto; font-weight: 400; color: var(--muted); }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.filters input { grid-column: 1 / -1; }
.filters select, .filters input { min-width: 0; width: 100%; }
#img-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#img-list li {
  padding: 6px 10px; border-bottom: 1px solid #2a2d33; cursor: pointer;
  display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center;
}
#img-list li:hover { background: var(--panel-2); }
#img-list li.current { background: #2d3d55; }
#img-list .id { font-size: 11px; color: var(--muted); }
#img-list .n { font-size: 11px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #555; }
.dot.in_progress { background: #e8b92a; }
.dot.done { background: #3aa655; }
.dot.skip { background: #777; outline: 1px solid #aaa; }

#center { display: flex; flex-direction: column; min-width: 0; }
#topbar {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
#img-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.tools { display: flex; gap: 4px; }
#stage { position: relative; flex: 1; min-height: 0; background: #111; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#hint {
  position: absolute; left: 10px; bottom: 10px; padding: 4px 8px; border-radius: 4px;
  background: rgba(0,0,0,.6); color: #ddd; font-size: 12px; pointer-events: none;
}
#hint:empty { display: none; }

.img-meta { padding: 8px 10px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.img-meta label { display: grid; gap: 3px; color: var(--muted); }
.img-meta textarea { resize: vertical; }
#roi-list { list-style: none; margin: 0; padding: 0; }
#roi-list li {
  padding: 6px 10px; border-bottom: 1px solid #2a2d33; display: grid;
  grid-template-columns: 12px 1fr auto; gap: 6px; align-items: center; cursor: pointer;
}
#roi-list li.selected { background: #2d3d55; }
#roi-list .sw { width: 12px; height: 12px; border-radius: 3px; }
#roi-list .cat { font-weight: 500; }
#roi-list .sub { font-size: 11px; color: var(--muted); grid-column: 2 / 4; }
#roi-list input.note { grid-column: 2 / 4; font-size: 12px; padding: 2px 6px; }
#roi-list button.del { padding: 0 6px; color: var(--danger); background: none; border: none; font-size: 15px; }
#legend { padding: 8px 10px; display: grid; gap: 4px; }
#legend span.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

#picker {
  position: fixed; z-index: 20; width: 300px; max-height: 420px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
#picker[hidden] { display: none; }
#picker-filter { margin: 8px; }
#picker-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#picker-list li { padding: 5px 10px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
#picker-list li.grp { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; cursor: default; padding-top: 8px; }
#picker-list li.hl { background: var(--accent); color: #fff; }
#picker-list .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
#picker-list .code { margin-left: auto; font-size: 11px; color: var(--muted); }
#picker-list li.hl .code { color: #e0ecff; }
.picker-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-top: 1px solid var(--line); }

#help { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30; display: grid; place-items: center; }
#help[hidden] { display: none; }
.help-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px 20px; max-width: 640px; }
.help-card h2 { margin: 0 0 10px; font-size: 16px; }
.help-card td { padding: 3px 12px 3px 0; vertical-align: top; }
.help-card td:first-child { white-space: nowrap; color: var(--accent); }

/* model prediction layer */
.pred-ctl { padding: 8px 10px; display: grid; gap: 6px; border-bottom: 1px solid var(--line); }
.pred-ctl select { width: 100%; min-width: 0; }
#pred-classes { list-style: none; margin: 0; padding: 4px 0; border-bottom: 1px solid var(--line); }
#pred-classes li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 3px 10px; cursor: default; font-size: 12px; }
#pred-classes li:hover { background: #2d3d55; }
#pred-classes .sw { width: 11px; height: 11px; border-radius: 3px; }
#pred-tip {
  position: absolute; z-index: 5; pointer-events: none; max-width: 320px; padding: 7px 9px; border-radius: 6px;
  background: rgba(20, 22, 26, .92); border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(0,0,0,.5); font-size: 12px; line-height: 1.45;
}
#pred-tip[hidden] { display: none; }
#pred-tip .t-cls { font-size: 13px; display: flex; align-items: center; gap: 6px; }
#pred-tip .t-cls .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
#pred-tip .t-top { color: #c8ccd2; }
