:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --border: #2a3648;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  font-size: 14px;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar .muted { color: var(--muted); font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar nav a { color: var(--accent); }
.container { padding: 1rem; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 1.25rem; margin-top: 0; }
.app-status[hidden] {
  display: none !important;
}
.app-status {
  min-height: 2.25rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 14px;
}
.app-status.ok {
  display: block;
  background: #132a1f;
  border-color: #2d6a4f;
  color: #d8f5e5;
}
.app-status.err {
  display: block;
  background: #2a1518;
  border-color: #8b3a3a;
  color: #ffd6d6;
}
.app-status.info {
  display: block;
  background: #1a2332;
  color: var(--text);
}
.muted { color: var(--muted); }
.classification-summary {
  margin: 0.35rem 0 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(61, 139, 253, 0.1);
  border-left: 3px solid var(--accent);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}
.classification-summary.muted {
  background: var(--panel);
  border-left-color: var(--border);
  color: var(--muted);
}
.toolbar {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
  margin-bottom: 1rem;
}
.toolbar label { display: flex; align-items: center; gap: 0.35rem; }
input[type="text"], select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
}
button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
}
button.secondary { background: #3a4556; }
button.danger { background: #c44; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 6px; overflow: hidden; }
th, td { padding: 0.45rem 0.6rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; }
tr[data-selected="1"] { outline: 2px solid var(--accent); }
tr:hover { background: #222c3d; cursor: pointer; }
.list-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: block;
}
.list-hover-compare {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  width: max-content;
  max-width: none;
}
.list-hover-compare img {
  flex: 0 0 auto;
  width: auto;
  height: auto;
  max-width: min(46vw, 720px);
  max-height: calc(50vh - 88px);
  object-fit: contain;
  background: #0b1018;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.list-hover-compare-arrow {
  color: var(--muted);
  font-size: 1.1rem;
  flex-shrink: 0;
}
.detail-before-wrap {
  display: inline-block;
  max-width: 100%;
  position: relative;
}
.detail-before-wrap[data-show-original-hover="1"] #img-before {
  cursor: help;
}
.detail-hover-original {
  position: fixed;
  left: 0;
  top: 0;
  width: min(40vw, 520px);
  max-width: min(40vw, calc(100vw - 16px));
  max-height: min(85vh, 90vh);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  z-index: 25;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  overflow: hidden;
  box-sizing: border-box;
}
.detail-hover-original .detail-hover-caption {
  margin: 0 0 0.35rem;
  font-size: 12px;
}
.detail-hover-original img {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: min(75vh, calc(85vh - 4rem));
  object-fit: contain;
  background: #0b1018;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.list-hover-preview.list-hover-preview--compare {
  width: max-content;
  min-width: min(34vw, 280px);
  max-width: min(96vw, 1600px);
}
.list-hover-preview {
  position: fixed;
  left: 0;
  top: 0;
  width: min(34vw, 420px);
  max-width: min(96vw, 1600px);
  max-height: 50vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  z-index: 20;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  overflow: hidden;
}
.list-hover-preview .small { font-size: 11px; }
.list-hover-preview #list-hover-preview-img {
  width: 100%;
  max-height: calc(50vh - 72px);
  object-fit: contain;
  background: #0b1018;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.pager { display: flex; gap: 0.5rem; align-items: center; margin: 0.75rem 0; }
.detail {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 1rem;
  margin-top: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
}
.detail-panel h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.detail-panel img { max-width: 100%; height: auto; border-radius: 4px; }
.candidates {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.cand-card {
  flex: 0 0 200px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  background: #141c28;
}
.cand-card img { width: 100%; height: auto; border-radius: 4px; }
.cand-card img { cursor: pointer; }
.cand-card .cand-author { margin: 0.25rem 0 0.35rem; font-size: 11px; }
.bottombar {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end;
  margin-top: 2rem;
}
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 50;
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  max-width: 90vw;
  max-height: 85vh;
  overflow: auto;
}
.modal pre { white-space: pre-wrap; word-break: break-all; font-size: 12px; }
.image-modal {
  padding: 0.4rem;
  background: transparent;
  border: none;
  max-width: 96vw;
  max-height: 96vh;
}
.image-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: start;
}
@media (max-width: 1000px) {
  .image-compare-grid { grid-template-columns: 1fr; }
}
.image-compare-grid figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.image-compare-grid figcaption {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.image-modal img {
  display: block;
  max-width: 46vw;
  max-height: 86vh;
  width: auto;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.6);
}
@media (max-width: 1000px) {
  .image-modal img { max-width: 92vw; }
}
code { font-size: 12px; }
.prompt-blocks {
  margin: 0.75rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.prompt-blocks .block-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 0.35rem;
}
.prompt-blocks textarea {
  width: 100%;
  max-width: 52rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}
.bulk-prompt-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 13px;
  color: var(--muted);
  flex: 1 1 14rem;
  min-width: 10rem;
}
.bulk-prompt-label textarea {
  width: 100%;
  min-width: 12rem;
  max-width: 36rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  resize: vertical;
}
table tbody td.row-select-cell {
  cursor: pointer;
  vertical-align: middle;
  width: 2.25rem;
  padding: 0.35rem 0.5rem;
}
table tbody td.row-select-cell .row-chk {
  cursor: pointer;
  margin: 0;
}
.refine-hint {
  margin: 0.15rem 0 0.25rem;
  font-size: 12px;
}
#btn-refine {
  align-self: flex-start;
  margin-top: 0.25rem;
}

/* Prompt notebook (right drawer) */
.prompt-notes-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}
.prompt-notes-root:not([hidden]) {
  pointer-events: auto;
}
.prompt-notes-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.prompt-notes-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(26rem, 100vw);
  height: 100%;
  max-height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.prompt-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.prompt-notes-heading {
  margin: 0;
  font-size: 1.05rem;
}
.prompt-notes-close {
  flex-shrink: 0;
  min-width: 2.25rem;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
}
.prompt-notes-hint {
  margin: 0;
  padding: 0.5rem 1rem 0.35rem;
  font-size: 12px;
  flex-shrink: 0;
}
.prompt-notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.prompt-notes-empty {
  margin: 0.5rem 0 0;
  font-size: 13px;
}
.prompt-notes-footer {
  flex-shrink: 0;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}
.prompt-note-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: #141c28;
}
.prompt-note-top {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}
.prompt-note-title {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-size: 14px;
}
.prompt-note-dates {
  font-size: 11px;
  line-height: 1.35;
}
.prompt-note-body {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
  min-height: 5rem;
}
.prompt-note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.prompt-note-actions button {
  font-size: 13px;
  padding: 0.3rem 0.55rem;
}
@media (max-width: 520px) {
  .prompt-notes-drawer {
    width: 100vw;
  }
}

.user-editor {
  margin-top: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  max-width: 42rem;
}
.ue-constraints-list {
  margin: 0.35rem 0 0.75rem;
  padding-left: 1.25rem;
  font-size: 13px;
}
.user-picker-modal {
  max-width: min(96vw, 720px);
  max-height: 85vh;
  overflow: auto;
}
.picker-list {
  max-height: 55vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0.5rem 0;
}
.picker-row {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.picker-row:last-child {
  border-bottom: none;
}
.picker-row:hover {
  background: #222c3d;
}
.picker-row-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.picker-hover {
  position: fixed;
  z-index: 60;
  width: min(34vw, 420px);
  max-height: 50vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  overflow: hidden;
}
.picker-hover img {
  width: 100%;
  max-height: calc(50vh - 72px);
  object-fit: contain;
  background: #0b1018;
  border-radius: 6px;
  border: 1px solid var(--border);
}
