/* Neutral grays throughout, so the surroundings don't skew how photo colors look. */
:root {
  color-scheme: dark;
  --bg: #1f1f1f;
  --panel: #292929;
  --panel-2: #333333;
  --line: #444444;
  --text: #ececec;
  --muted: #a8a8a8;
  --accent: #6ea8fe;
  --good: #63c98b;
  --warn: #e7b35a;
  --bad: #ef7f7f;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; font-weight: 600; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }

button, select, input, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}

button { padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #101010; font-weight: 600; }
button.danger { color: var(--bad); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
select { padding: 5px 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.muted { color: var(--muted); }

/* Sidebar */
#sidebar {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

#sidebar header, #sidebar footer { padding: 14px; }
#sidebar header { display: flex; justify-content: space-between; align-items: center; }
#sidebar footer { border-top: 1px solid var(--line); display: grid; gap: 10px; }

#job-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }

#job-list button {
  display: block;
  width: 100%;
  padding: 10px;
  margin-bottom: 4px;
  text-align: left;
  background: none;
  border-color: transparent;
}

#job-list button:hover { background: var(--panel-2); }
#job-list button.active { background: var(--panel-2); border-color: var(--line); }
.job-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.job-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.job-meta .spent { color: var(--text); }
.job-expiry { display: block; color: var(--muted); font-size: 12px; }
.job-expiry.soon { color: var(--warn); }
.total { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }

/* Main */
#main { flex: 1; min-width: 0; height: 100vh; overflow-y: auto; padding: 24px; padding-bottom: 90px; }
#banner { padding: 10px 14px; margin-bottom: 16px; border: 1px solid var(--warn); border-radius: 6px; color: var(--warn); }
#empty-state { text-align: center; margin-top: 20vh; display: grid; gap: 6px; }

.job-header { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.job-title { display: flex; align-items: center; gap: 10px; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.job-spent { text-align: right; font-variant-numeric: tabular-nums; }
.job-spent strong { display: block; font-size: 26px; font-weight: 600; line-height: 1.1; }
.job-spent small { color: var(--warn); display: block; max-width: 260px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toolbar .gap { display: flex; align-items: center; gap: 8px; }
.toolbar input[type=number] { width: 64px; padding: 5px 6px; }

.dropzone {
  display: block;
  width: 100%;
  padding: 44px 16px;
  text-align: center;
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: none;
}

.dropzone strong { display: block; font-size: 16px; margin-bottom: 4px; }

.progress { margin-bottom: 16px; }
.progress-track { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; background: var(--accent); }
.notice { margin-bottom: 16px; color: var(--muted); }

/* Sign in and team */
.login-page { align-items: center; justify-content: center; padding: 16px; }
.login-card { display: grid; gap: 8px; width: min(360px, 100%); padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.login-card h1 { margin-bottom: 10px; }
.login-card input { padding: 8px; margin-bottom: 6px; }
.login-card button { margin-top: 6px; padding: 8px; }
.login-error { color: var(--bad); }
.account { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 12px; color: var(--muted); }
.account strong { flex-basis: 100%; color: var(--text); font-size: 14px; font-weight: 600; }
.team-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.team-row .spacer { flex: 1; }
.team-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.team-add input[type=text] { flex: 1 1 140px; width: auto; margin: 0; }
dialog input[type=password] { width: 100%; padding: 8px; margin-bottom: 8px; }
.secret { display: block; padding: 10px; margin: 8px 0; font: 15px Consolas, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; user-select: all; overflow-wrap: anywhere; }

/* Dropbox */
.dropbox-import { margin-bottom: 12px; border-color: var(--accent); }
.dropbox-path { font-family: Consolas, monospace; overflow-wrap: anywhere; color: var(--muted); }
.folder-list { display: grid; gap: 4px; max-height: 42vh; overflow-y: auto; }
.folder-list button { text-align: left; background: none; border-color: transparent; }
.folder-list button:hover { background: var(--panel-2); }
.folder-note { margin: 10px 0 0; }
#dropbox-account a, #dropbox-account a button { display: block; width: 100%; }

/* Edit options */
.options-panel {
  padding: 10px 12px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.options-panel h3 { margin-bottom: 8px; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.group-options { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.toggle { padding: 3px 10px; font-size: 12px; border-radius: 12px; color: var(--muted); background: none; }
.toggle.on { color: #101010; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.toggle.custom { border-style: dashed; border-color: var(--accent); }
.toggle.on.custom { border-color: #101010; }

/* Groups */
.group {
  margin-bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.group.drag-over, .new-group-zone.drag-over { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.group-head .spacer { flex: 1; }
.chip { padding: 1px 8px; border-radius: 10px; font-size: 12px; border: 1px solid currentColor; }
.chip.done { color: var(--good); }
.chip.active { color: var(--accent); }
.chip.failed { color: var(--bad); }
.chip.stale { color: var(--warn); }
.group-error { padding: 8px 12px; color: var(--bad); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }

.group-body { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px; min-height: 80px; }

.thumb {
  position: relative;
  width: 168px;
  padding: 0;
  text-align: left;
  background: var(--panel-2);
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
}

.thumb:hover { border-color: var(--line); }
.thumb.selected { border-color: var(--accent); }
.thumb img { display: block; width: 100%; height: 112px; object-fit: contain; background: #111; pointer-events: none; }
.thumb .name { display: block; padding: 4px 6px 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .exposure { display: block; padding: 0 6px 5px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.result-card { width: 168px; padding: 0; text-align: left; background: var(--panel-2); border: 2px solid var(--good); border-radius: 6px; overflow: hidden; }
.result-card img { display: block; width: 100%; height: 112px; object-fit: contain; background: #111; }
.result-card span { display: block; padding: 4px 6px 5px; font-size: 12px; }

.divider { width: 1px; background: var(--line); margin: 0 4px; }

.new-group-zone { padding: 18px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: 8px; margin-bottom: 14px; }
.removed-section { margin-top: 20px; }
.removed-section summary { cursor: pointer; color: var(--muted); margin-bottom: 10px; }
.removed-section .thumb { cursor: default; }
.removed-section .restore { display: block; width: 100%; border: 0; border-top: 1px solid var(--line); border-radius: 0; font-size: 12px; }

/* Selection bar */
#selection-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  background: var(--panel-2);
  border: 1px solid var(--muted);
  border-radius: 8px;
  z-index: 5;
}

/* Overlays */
#drop-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 20, 20, .85);
  font-size: 22px;
  z-index: 8;
  pointer-events: none;
}

[hidden] { display: none !important; }

dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 20px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

dialog.wide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin-bottom: 10px; }
dialog p { margin-bottom: 10px; }
dialog input[type=text] { width: 100%; padding: 8px; margin-bottom: 4px; }
dialog textarea { width: 100%; height: 46vh; padding: 10px; resize: vertical; font: 13px/1.45 Consolas, monospace; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dialog-actions .spacer { flex: 1; }
.prompt-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.prompt-tabs button.active { border-color: var(--accent); color: var(--accent); }

/* Compare viewer */
#viewer {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #181818;
  z-index: 10;
}

.viewer-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.viewer-bar .spacer { flex: 1; }
.segmented { display: inline-flex; }
.segmented button { border-radius: 0; margin-left: -1px; }
.segmented button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.segmented button:last-child { border-radius: 0 6px 6px 0; }
.segmented button.active { background: var(--accent); color: #101010; border-color: var(--accent); }

.stage { position: relative; flex: 1; min-height: 0; display: flex; gap: 6px; padding: 8px; overflow: hidden; }
.pane { position: relative; flex: 1; min-width: 0; overflow: hidden; background: #111; cursor: grab; user-select: none; }
.pane.panning { cursor: grabbing; }
.pane img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; pointer-events: none; }
.pane-label { position: absolute; top: 8px; padding: 2px 8px; font-size: 12px; background: rgba(0, 0, 0, .7); border-radius: 4px; z-index: 2; pointer-events: none; }
.pane-label.left { left: 8px; }
.pane-label.right { right: 8px; }
.slider-clip { position: absolute; inset: 0; }
.slider-handle { position: absolute; top: 0; bottom: 0; width: 24px; margin-left: -12px; cursor: ew-resize; z-index: 3; touch-action: none; }
.slider-handle::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 3px #000; }
.slider-handle::after { content: "\2194"; position: absolute; top: 50%; left: -4px; width: 32px; height: 32px; margin-top: -16px; display: grid; place-items: center; color: #101010; background: #fff; border-radius: 50%; }

.viewer-foot { display: flex; flex-wrap: wrap; gap: 20px; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--line); }
.strip { display: flex; gap: 6px; align-items: center; overflow-x: auto; }
.strip-label { color: var(--muted); font-size: 12px; margin-right: 2px; }
.strip button { position: relative; padding: 0; width: 84px; flex: none; background: #111; border: 2px solid transparent; overflow: hidden; }
.strip button.active { border-color: var(--accent); }
.strip img { display: block; width: 100%; height: 54px; object-fit: contain; }
.strip small { display: block; font-size: 11px; color: var(--muted); padding: 1px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 800px) {
  body { flex-direction: column; }
  #sidebar { flex: none; height: auto; max-height: 40vh; }
  #main { height: auto; flex: 1; padding: 16px; }
}
