:root {
  --bg: #1a1a1a;
  --bg-elev: #232323;
  --bg-card: #2a2a2a;
  --line: #333;
  --text: #e6e6e6;
  --muted: #888;
  --accent: #00BCB5;
  --accent-hover: #00A9A3;
  --green: #3fb950;
  --red: #f85149;
  --warn: #d29922;
  --radius: 6px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); margin-top: 8px; min-height: 1em; }

.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-screen { gap: 56px; }
#clawd-ascii {
  margin: 0; font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 8px; line-height: 1; letter-spacing: 0; user-select: none;
  text-align: left;
}
@media (max-width: 900px), (max-height: 560px) { #clawd-ascii { display: none; } }
.ca-t { color: #00bcb5; }
.ca-w { color: #e6e6e6; }
.ca-d { color: rgba(0,188,181,0.45); }
.login-card {
  background: var(--bg-elev);
  padding: 32px;
  border-radius: 8px;
  width: 320px;
  border: 1px solid var(--line);
}
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: 2px; }
.login-card p { margin: 4px 0 20px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-easter {
  margin: 14px 0 0;
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.2px;
}

input[type="email"], input[type="password"], input[type="search"] {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
}
input:focus { border-color: var(--accent); }

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
button.ghost:hover { border-color: var(--accent); }
button.primary { background: var(--accent); }
a.ghost {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
a.ghost:hover { border-color: var(--accent); }

.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 2px;
}
.brand-logo {
  height: 28px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.tabs { display: flex; flex: 1; min-width: 0; gap: 4px; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  letter-spacing: 1px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--line);
}
/* Deleted tab — red label (muted inactive, full red when selected) */
.tab[data-tab="DEL"] {
  color: #b34a45;
}
.tab[data-tab="DEL"]:hover {
  color: var(--red);
}
.tab[data-tab="DEL"].active {
  color: var(--red);
  background: var(--bg-card);
  border-color: var(--line);
}
/* Right-cluster Inbox/WORK/CriTiek/SET against the filter + search */
#tab-inbox { margin-left: auto; }
#search { flex: 1; max-width: 360px; }

/* v0.99.6 global filter/sort — discreet control left of #search */
.filter-wrap {
  position: relative;
  flex: 0 0 auto;
}
.filter-btn {
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 1px;
  font-weight: 600;
  color: var(--muted);
  border-color: var(--line);
  white-space: nowrap;
  position: relative;
}
.filter-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: transparent;
}
.filter-btn.filter-active {
  color: var(--accent);
  border-color: var(--accent);
}
.filter-btn.filter-active::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.filter-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 200px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filter-panel.hidden { display: none !important; }
.filter-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-row label {
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--muted);
  text-transform: uppercase;
}
.filter-row select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
}
.filter-row select:focus { border-color: var(--accent); }
.filter-clear {
  align-self: flex-end;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  padding: 2px 0;
}
.filter-clear:hover { color: var(--accent); }

.grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-content: start;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid transparent;
  position: relative;
  cursor: pointer;
}
.card.processing { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.card.failed     { border-color: var(--red); }
/* Claim colors — ring per assignee (box-shadow so it doesn't fight the status border-color above) */
.card.claim-ella  { box-shadow: 0 0 0 2px #9B59FF; }
.card.claim-ivan  { box-shadow: 0 0 0 2px #3B82F6; }
.card.claim-henry { box-shadow: 0 0 0 2px #22C55E; }
.card img { display: block; width: 100%; height: auto; aspect-ratio: 3/4; object-fit: cover; }
.card .meta {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--muted);
  gap: 6px;
}
.card .meta .meta-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.card .meta .meta-colorway {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.actions {
  display: flex; gap: 4px;
  flex-wrap: wrap;
  padding: 4px 6px 8px;
}
.actions button,
.actions a.action-link {
  flex: 1;
  padding: 4px;
  font-size: 11px;
  letter-spacing: 1px;
  border-radius: 4px;
}
/* WORK tab cards: CLAIM / PSD / DROPBOX / ↓ on one compact row */
.actions.work-compact {
  flex-wrap: nowrap;
  gap: 3px;
  padding: 3px 4px 6px;
}
.actions.work-compact button,
.actions.work-compact a.action-link {
  flex: 1 1 0;
  min-width: 0;
  padding: 3px 2px;
  font-size: 10px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.actions.work-compact .icon,
.actions.work-compact .dl {
  flex: 0 0 22px;
  font-size: 12px;
  padding: 2px 3px;
}
/* v0.99.5 calm ghost palette (no rainbow fills) — cards, lightbox, bulk toolbar */
.actions .sf,
.sel-toolbar .sf {
  background: transparent;
  border: 1px solid rgba(0, 188, 181, 0.55);
  color: #00BCB5;
}
.actions .sf:hover,
.sel-toolbar .sf:hover {
  background: rgba(0, 188, 181, 0.12);
  border-color: #00BCB5;
}
.actions .ads,
.sel-toolbar .ads {
  background: transparent;
  border: 1px solid var(--line);
  color: #c9c9c9;
}
.actions .ads:hover,
.sel-toolbar .ads:hover {
  border-color: #888;
  background: rgba(255, 255, 255, 0.05);
}
.actions .x,
.sel-toolbar .x {
  background: transparent;
  border: 1px solid rgba(248, 81, 73, 0.4);
  color: var(--red);
}
.actions .x:hover,
.sel-toolbar .x:hover {
  background: rgba(248, 81, 73, 0.12);
  border-color: var(--red);
}
.sel-toolbar .ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.sel-toolbar .ghost-btn:hover {
  border-color: var(--accent);
  background: transparent;
}

.empty {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}

.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  flex-direction: column;
  gap: 12px;
  padding: 32px;
}
/* Image + notes sidebar row: image and panel sit adjacent, group centered. */
.lb-stage {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  max-width: 96vw;
  max-height: 78vh;
  min-height: 0;
  width: auto;
  /* Center the image+panel group as a unit in the viewport. */
  margin-inline: auto;
}
.lb-stage.lb-stage-panel-open .lb-image-wrap,
.lb-stage.lb-stage-panel-open .lb-image-wrap img {
  max-width: min(calc(96vw - 340px), 90vw);
}
.lightbox img { max-width: 90vw; max-height: 78vh; object-fit: contain; display: block; }
.lb-image-wrap {
  position: relative;
  display: inline-block;
  /* Do not grow — keeps panel flush to the image edge (no dead gap). */
  flex: 0 1 auto;
  min-width: 0;
  max-width: 90vw;
  max-height: 78vh;
  line-height: 0;
  align-self: center;
}
.lb-image-wrap img {
  max-width: 90vw;
  max-height: 78vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.lb-markup-canvas {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
}
.lb-markup-canvas.drawing {
  pointer-events: auto;
  cursor: crosshair;
}
.lb-markup-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 90vw;
  padding: 8px 12px;
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.lb-markup-colors { display: flex; gap: 6px; }
.lb-color {
  width: 28px; height: 28px; padding: 0;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.25);
  cursor: pointer;
}
.lb-color.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--c);
}
/* Notes/markups sidebar — right of image on every tab when relevant. */
.lb-markup-panel {
  flex: 0 0 340px;
  width: 340px;
  max-width: 340px;
  max-height: 78vh;
  overflow: hidden;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #141414;
  border: 1px solid var(--line);
  /* Left edge flush against image; slight radius on free edges only. */
  border-left: none;
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  box-sizing: border-box;
  min-height: 0;
}
.lb-markup-panel.hidden {
  display: none;
}
.lb-panel-section-title {
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
  flex: 0 0 auto;
}
.lb-panel-section-title .lb-count {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.2px;
  margin-left: 4px;
}
.lb-markup-meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
  margin-top: -4px;
  flex: 0 0 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-notes-list {
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 48px;
  max-height: none;
}
.lb-notes-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
  margin-top: auto;
}
.lb-notes-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 7.5em;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  box-sizing: border-box;
}
.lb-notes-form textarea.lb-notes-required {
  border-color: var(--red, #f85149);
}
.lb-note-hint {
  font-size: 12px;
  color: var(--red, #f85149);
  line-height: 1.3;
}
.lb-notes-form .primary {
  align-self: stretch;
  padding: 10px 14px;
  font-size: 13px;
  letter-spacing: 0.4px;
}
@media (max-width: 900px) {
  .lb-stage {
    flex-direction: column;
    max-height: 82vh;
    overflow-y: auto;
    gap: 8px;
    width: 100%;
  }
  .lb-stage.lb-stage-panel-open .lb-image-wrap,
  .lb-stage.lb-stage-panel-open .lb-image-wrap img {
    max-width: 90vw;
  }
  .lb-image-wrap,
  .lb-image-wrap img {
    max-height: 48vh;
  }
  .lb-markup-panel {
    flex: 0 0 auto;
    width: 100%;
    max-width: min(420px, 90vw);
    max-height: 36vh;
    align-self: center;
    border-left: 1px solid var(--line);
    border-radius: 8px;
  }
}
/* Protocol action links styled like ghost buttons */
a.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
  cursor: pointer;
}
a.action-link.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 10px;
  font-size: 12px;
  letter-spacing: 0.5px;
  border-radius: 4px;
}
a.action-link.ghost-btn:hover {
  border-color: var(--accent, #00BCB5);
}
.card-runner-note {
  margin: 0 8px 6px;
  padding: 6px 8px;
  font-size: 12px;
  line-height: 1.35;
  color: #ffb4b4;
  background: #4a1d1d;
  border: 1px solid rgba(255, 100, 100, 0.35);
  border-radius: 4px;
  max-height: 4.2em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.meta-keywords {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 48%;
  min-width: 0;
  text-align: right;
}
.final-card .final-meta {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
}
.final-card .final-project {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
/* MARKUPS visibility toggle (lightbox action row) — ghost outline / teal fill when active */
.lb-markups-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
}
.lb-markups-btn:hover {
  border-color: #00BCB5;
}
.lb-markups-btn.active {
  background: #00BCB5;
  border-color: #00BCB5;
  color: #0d0d0d;
}
.lb-markup-list {
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 1 auto;
  max-height: 28%;
  min-height: 0;
}
.markup-row {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  background: var(--bg-card, #1c1c1c);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 4px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
}
.markup-row-head {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.markup-row-note { color: var(--text); margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.markup-del {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 20px; height: 20px; padding: 0; line-height: 1;
  font-size: 14px; border-radius: 50%;
  background: transparent; color: var(--muted);
}
.markup-del:hover { background: var(--red); color: white; }
.card-badge {
  font-size: 10px;
  letter-spacing: 1px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  background: #141414;
  color: #f0f0f0;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
/* Top-right so it doesn't collide with the select checkbox (top-left). */
.card-badges {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  gap: 4px;
  pointer-events: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 70%;
}
/* Status chips: opaque dark base; color via border + text only (v0.99.18 solid) */
.card-badge.work-todo {
  background: #141414;
  color: #00BCB5;
  border-color: #00BCB5;
}
.card-badge.work-doing {
  background: #141414;
  color: #00BCB5;
  border-color: #00BCB5;
}
.card-badge.work-review {
  background: #141414;
  color: #E8A33D;
  border-color: #E8A33D;
}
/* v0.99.19 pipeline: sent / ai_fixing / pps / final */
.card-badge.work-sent {
  background: #141414;
  color: #c9c9c9;
  border-color: #888;
}
.card-badge.work-ai-fixing {
  background: #141414;
  color: #E8A33D;
  border-color: #E8A33D;
}
/* In-flight activity indicators (sent = pulse, ai_fixing = spin). CSS-only. */
.card-badge.work-chip.has-activity {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip-activity {
  flex-shrink: 0;
  box-sizing: border-box;
  pointer-events: none;
}
.chip-activity--pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: chip-activity-pulse 1.2s ease-in-out infinite;
}
.chip-activity--spin {
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: chip-activity-spin 0.7s linear infinite;
}
@keyframes chip-activity-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}
@keyframes chip-activity-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .chip-activity--pulse,
  .chip-activity--spin {
    animation: none;
  }
  /* Static dot fallback for both pulse and spin */
  .chip-activity--spin {
    width: 6px;
    height: 6px;
    border: none;
    background: currentColor;
  }
}
.lightbox-meta .lb-work-chip {
  vertical-align: middle;
  margin: 0 1px;
}
.card-badge.work-pps {
  background: #141414;
  color: #00BCB5;
  border-color: #00BCB5;
}
.card-badge.work-done {
  background: #141414;
  color: #c9c9c9;
  border-color: #888;
}
.card-badge.work-final {
  background: #00BCB5;
  color: #0a0a0a;
  border-color: #00BCB5;
}
/* v0.99.13 work_type chips — SF teal / POST neutral on opaque base */
.card-badge.work-type-sf {
  background: #141414;
  color: #00BCB5;
  border-color: #00BCB5;
  font-size: 9px;
  letter-spacing: 0.6px;
  font-weight: 600;
}
.card-badge.work-type-post {
  background: #141414;
  color: #c9c9c9;
  border-color: #c9c9c9;
  font-size: 9px;
  letter-spacing: 0.6px;
  font-weight: 500;
}
/* v0.99.7 Dropbox origin + v0.99.14 NEEDS CAMPAIGN (shares class; both opaque) */
.card-badge.origin-chip {
  background: #141414;
  color: #b0b0b8;
  border-color: #6a6a72;
  font-size: 9px;
  letter-spacing: 0.6px;
  font-weight: 500;
}
/* NEEDS CAMPAIGN shares origin-chip class (no separate class in JS); amber via title */
.card-badge.origin-chip[title*="campaign" i],
.card-badge.origin-chip[title*="Runner"] {
  color: #E8A33D;
  border-color: #E8A33D;
}
.filter-row input[type="text"] {
  flex: 1;
  min-width: 0;
  background: var(--bg, #1a1a1c);
  color: var(--fg, #eee);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
}
.filter-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* Ephemeral toast for work-queue actions */
.van-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  letter-spacing: 0.5px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.12);
  max-width: min(520px, 92vw);
  text-align: center;
}
.van-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.van-toast.van-toast-error {
  background: rgba(90, 16, 20, 0.96);
  border-color: rgba(248, 81, 73, 0.55);
  color: #ffd7d5;
}
.lightbox .close {
  position: absolute; top: 16px; right: 16px;
  width: 44px; height: 44px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5); color: white; font-size: 26px;
  border-radius: 50%; cursor: pointer;
}
.lightbox .close:hover { background: rgba(255,255,255,0.18); }
.lightbox .lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45); color: white; font-size: 38px;
  border-radius: 50%; cursor: pointer; user-select: none;
}
.lightbox .lb-nav:hover { background: rgba(255,255,255,0.18); }
.lightbox .lb-nav.prev { left: 24px; }
.lightbox .lb-nav.next { right: 24px; }
.lightbox .lb-counter {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
  color: var(--muted); font-size: 13px;
}
.lightbox-meta { color: var(--muted); font-size: 12px; max-width: 80vw; text-align: center; }

/* Per-image action bar inside the lightbox (mirrors the card buttons). */
.lightbox-actions { display: flex; justify-content: center; max-width: 90vw; }
.lightbox-actions .actions {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 0;
}
.lightbox-actions .actions button {
  flex: 0 1 auto;
  padding: 8px 16px;
  font-size: 13px;
  letter-spacing: 1px;
  border-radius: 5px;
}

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  width: min(520px, 92vw);
  max-height: 80vh;
  display: flex; flex-direction: column;
  gap: 10px;
}
.modal-card h2 { margin: 0; font-size: 16px; letter-spacing: 1px; }

.colorway-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius);
}
.colorway-row {
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
}
.colorway-row:hover { background: var(--bg-card); }
.colorway-row.selected { background: var(--accent); color: white; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* v0.99.19 Send-to-work modal (dark card, dim backdrop, ~360px) */
.send-work-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
}
.send-work-card {
  background: #141414;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: min(360px, 92vw);
  padding: 22px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
.send-work-card h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 1px;
  font-weight: 600;
  color: var(--text);
}
.send-work-text {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--muted);
}
.send-work-choice {
  width: 100%;
  padding: 12px 14px;
  font-size: 13px;
  letter-spacing: 1.2px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}
.send-work-choice.send-work-sf {
  color: #00BCB5;
  border: 1px solid #00BCB5;
}
.send-work-choice.send-work-sf:hover {
  background: rgba(0, 188, 181, 0.12);
}
.send-work-choice.send-work-post {
  color: #c9c9c9;
  border: 1px solid #6a6a72;
}
.send-work-choice.send-work-post:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: #c9c9c9;
}
.send-work-cancel {
  width: 100%;
  margin-top: 2px;
  padding: 8px;
  font-size: 12px;
  letter-spacing: 1px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
}
.send-work-cancel:hover {
  color: var(--text);
  background: transparent;
}

/* PPS reject reason (one-line) — reuses send-work modal shell */
.reject-reason-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 13px;
  background: var(--bg, #0d0d0d);
  color: var(--text, #eee);
  border: 1px solid var(--line, #333);
  border-radius: 6px;
}
.reject-reason-input:focus {
  outline: none;
  border-color: var(--accent, #00BCB5);
}
.reject-reason-err {
  margin: 0;
  color: var(--red, #f85149) !important;
}
.reject-reason-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.meta-extras {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* PPS REJECT — red outline ghost */
.actions .work-reject,
.actions .ghost-btn.work-reject {
  color: var(--red);
  border-color: var(--red);
  background: transparent;
}
.actions .work-reject:hover,
.actions .ghost-btn.work-reject:hover {
  background: rgba(248, 81, 73, 0.12);
  border-color: var(--red);
}

/* v0.2 additions */
.version-tag {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 1px;
  margin-left: 6px;
}
.small { font-size: 12px; }
#user-email { margin-left: 8px; }

.actions .ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.actions .ghost-btn:hover { border-color: var(--accent); }
.actions .icon {
  flex: 0 0 32px;
  font-size: 14px;
  padding: 4px 6px;
}
/* Download icon — only filled accent button in the action bar */
.actions .dl,
.actions .ghost-btn.dl {
  background: #00BCB5;
  border: 1px solid #00BCB5;
  color: #0d0d0d;
}
.actions .dl:hover,
.actions .ghost-btn.dl:hover {
  background: #00A9A3;
  border-color: #00A9A3;
  color: #0d0d0d;
}

/* v0.99.5 Lightroom-style 1–3 star row */
.star-row {
  display: inline-flex;
  gap: 1px;
  align-items: center;
  line-height: 1;
  user-select: none;
}
.star-row .star {
  background: transparent;
  border: none;
  padding: 0 1px;
  margin: 0;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: #555;
  flex: 0 0 auto;
}
.star-row .star.filled {
  color: #00BCB5;
}
.star-row .star:hover {
  background: transparent;
  color: #00BCB5;
}
.meta .star-row { flex-shrink: 0; }
.lightbox-stars {
  display: flex;
  justify-content: center;
  margin-top: 2px;
}
.lightbox-stars .star-row .star {
  font-size: 18px;
  padding: 0 3px;
}

.placeholder { background: var(--bg-elev); min-height: 220px; }
.placeholder-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
  pointer-events: none;
}
.card.deleted { opacity: 0.7; }
.card.deleted .meta { color: var(--warn); }

#main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.view { flex: 1; overflow-y: auto; }

#arw-generator,
#style-generator {
  max-width: 900px;
  margin: 16px auto 4px;
  width: calc(100% - 32px);
}
#arw-generator.hidden,
#style-generator.hidden { display: none; }

/* ARW Generate panel — slim single-row toolbar */
#arw-generator.gen-toolbar {
  max-width: none;
  margin: 8px 16px 4px;
  width: auto;
  padding: 8px 10px;
  gap: 4px;
}
#arw-generator .gen-form-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#arw-generator .gen-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
#arw-generator .gen-bar select,
#arw-generator .gen-bar input[type="text"],
#arw-generator .gen-bar input[type="number"] {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  height: 36px;
  line-height: 1.2;
}
#arw-generator .gen-bar select:focus,
#arw-generator .gen-bar input:focus {
  border-color: var(--accent);
  outline: none;
}
#arw-generator .gen-bar #gen-mode {
  flex: 0 0 auto;
  width: 110px;
  min-width: 100px;
}
#arw-generator .gen-bar #gen-prompt {
  flex: 1 1 180px;
  min-width: 140px;
}
#arw-generator .gen-bar #gen-count {
  flex: 0 0 auto;
  width: 64px;
  min-width: 56px;
}
#arw-generator .gen-bar #gen-ratio {
  flex: 0 0 auto;
  width: 140px;
  min-width: 120px;
}
#arw-generator .gen-bar button {
  align-self: center;
  flex: 0 0 auto;
  white-space: nowrap;
  height: 36px;
  padding: 0 14px;
}
#arw-generator #gen-result:empty {
  display: none;
}
#arw-generator #gen-result {
  margin: 0;
  min-height: 0;
  line-height: 1.3;
}
.load-status {
  text-align: center;
  padding: 16px;
}
#load-sentinel { height: 1px; }
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel h2 { margin: 0; font-size: 14px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.panel button { align-self: flex-start; }
.panel textarea {
  width: 100%;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
.panel textarea:focus { border-color: var(--accent); outline: none; }

.gen-form { display: flex; flex-direction: column; gap: 12px; }
.gen-form .row { display: flex; gap: 12px; flex-wrap: wrap; }
.gen-form .row .field { flex: 1; min-width: 140px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 11px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.field input, .field select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }

.admin-only.hidden { display: none !important; }

.del-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  margin: 0 0 12px 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.del-toolbar button {
  padding: 6px 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.diag-pre {
  background: #111;
  color: var(--text);
  padding: 12px;
  border-radius: var(--radius);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 500px;
  overflow: auto;
  margin-top: 10px;
}

/* Style Images — 3 persistent garment buckets (drag/drop, paste, click). */
.style-buckets {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.style-bucket {
  position: relative;
  flex: 1 1 120px;
  max-width: 180px;
  aspect-ratio: 3/4;
  background: var(--bg-card);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.style-bucket:hover { border-color: var(--accent); }
.style-bucket.dragover { border-color: var(--accent); background: rgba(0, 188, 181, 0.12); }
.style-bucket.active { border-color: var(--accent); }
.style-bucket.filled { border-style: solid; cursor: default; }
.style-bucket img { width: 100%; height: 100%; object-fit: cover; display: block; }
.style-bucket .bucket-hint {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  padding: 6px;
}
.style-bucket .bucket-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 24px; height: 24px;
  line-height: 1;
  padding: 0;
  font-size: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  display: flex; align-items: center; justify-content: center;
}
.style-bucket .bucket-remove:hover { background: var(--red); }

/* v0.7: processor health banner */
.health-banner {
  padding: 8px 16px;
  font-size: 13px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.health-banner.danger { background: #4a1d1d; color: #ffb4b4; }
.health-banner.warn   { background: #4a3a16; color: #ffe1a8; }

/* v0.7: bulk selection */
.card-select {
  position: absolute;
  top: 6px; left: 6px;
  width: 20px; height: 20px;
  z-index: 3;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
  accent-color: var(--accent);
}
.card:hover .card-select,
.card-select:checked { opacity: 1; }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }

.sel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  margin: 0 0 12px 0;
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
.sel-toolbar .sel-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sel-toolbar button { padding: 6px 12px; font-size: 12px; letter-spacing: 0.5px; }

/* v0.7: source ↔ output compare overlay */
.compare {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.94);
  z-index: 70;
  display: flex; align-items: center; justify-content: center;
  gap: 16px;
  padding: 48px 24px;
  flex-wrap: wrap;
}
.compare .close {
  position: absolute; top: 16px; right: 16px;
  width: 44px; height: 44px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5); color: white; font-size: 26px;
  border-radius: 50%; cursor: pointer;
}
.compare .close:hover { background: rgba(255,255,255,0.18); }
.compare-pane {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  max-width: 46vw;
}
.compare-pane img { max-width: 46vw; max-height: 82vh; object-fit: contain; }
.compare-label { color: var(--muted); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }

/* v0.7: threaded notes */
.notes-thread {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 40vh; overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}
.note-row {
  position: relative;
  background: var(--bg-card);
  border-radius: 4px;
  padding: 6px 26px 6px 8px;
}
.note-head { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.lb-notes-list .note-body { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.note-body { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.note-del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; padding: 0; line-height: 1;
  font-size: 14px; border-radius: 50%;
  background: transparent; color: var(--muted);
}
.note-del:hover { background: var(--red); color: white; }
