:root {
  --bg: #1e1f22;
  --bg-2: #26282c;
  --bg-3: #2f3237;
  --line: #3a3d43;
  --fg: #e6e6e6;
  --fg-dim: #9aa0a6;
  --accent: #4c8bf5;
  --green: #3fb950;
  --yellow: #d29922;
  --toolbar-h: 52px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 system-ui, "Segoe UI", Roboto, Arial, sans-serif;
}

body { display: flex; flex-direction: column; overflow: hidden; }

button, input, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
}

button { cursor: pointer; }
button:hover { background: #3a3e45; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #5b96f7; }

input[type="checkbox"] { accent-color: var(--accent); vertical-align: -1px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: var(--toolbar-h);
  min-height: var(--toolbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: nowrap;
  overflow-x: auto;
}

.spacer { flex: 1 1 auto; }

.root-info { display: flex; flex-direction: column; line-height: 1.1; }
.root-name { font-weight: 600; white-space: nowrap; }
.root-stats { color: var(--fg-dim); font-size: 12px; }

.search { width: 220px; }

.chk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  color: var(--fg-dim);
  cursor: pointer;
}
.chk input { cursor: pointer; }

.range input[type="range"] { width: 100px; padding: 0; }
.val { width: 42px; text-align: right; color: var(--fg); }

.progress { color: var(--fg-dim); white-space: nowrap; }

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  overflow-y: auto;
  min-height: 0;
}

.folder-list { list-style: none; margin: 0; padding: 4px 0; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.row:hover { background: var(--bg-3); }
.row.active { background: #2f4a76; }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #55585e;
  flex: 0 0 auto;
}
.row.status-partial .dot { background: var(--yellow); }
.row.status-done .dot { background: var(--green); }
.row.status-partial .name { color: #f0d08a; }
.row.status-done .name { color: #9bdb9f; }

.name { overflow: hidden; text-overflow: ellipsis; }

.work {
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
  min-width: 0;
}

.viewer-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.thumbs {
  display: flex;
  gap: 6px;
  padding: 6px;
  min-height: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.thumbs:empty { display: none; }

.thumb {
  height: 74px;
  width: auto;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  object-fit: cover;
  background: #111;
}
.thumb.active { border-color: var(--accent); }

.viewer {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  background: #111;
  min-height: 0;
  cursor: grab;
  touch-action: none;
}
.viewer.dragging { cursor: grabbing; }

#mainImg {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  image-rendering: auto;
}

.viewer-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-dim);
}

.viewer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  flex-wrap: wrap;
}
.zoom-label { color: var(--fg-dim); width: 48px; }
.hint { color: var(--fg-dim); font-size: 12px; flex: 1 1 auto; }

.editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--bg-2);
}

.editor-head {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.folder-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-count { color: var(--fg-dim); font-size: 12px; white-space: nowrap; }

.editor-fields {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field .cap { color: var(--fg-dim); font-size: 12px; }
.field-note { color: var(--fg-dim); padding: 8px 2px; }
.field textarea {
  resize: vertical;
  min-height: 62px;
  width: 100%;
  line-height: 1.35;
}

.editor-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #000c;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  pointer-events: none;
  transition: opacity .2s;
  opacity: 0;
}
.toast.show { opacity: 1; }
