:root {
  --bg: #0c121c;
  --panel: #141c2b;
  --text: #e8e4d9;
  --muted: #9aa3b0;
  --border: #2a3548;
  --accent: #d4af37;
  --keep: #3d8b6e;
  --reject: #a35d5d;
  --maybe: #b8860b;
  --font: "Segoe UI", system-ui, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --panel-w: 22rem;
  --strip-h: 5.2rem;
  --hero-scale: 1;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

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

.skip-link {
  position: absolute;
  left: -999px;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; z-index: 20; }

.top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  min-height: 2.8rem;
  flex: 0 0 auto;
  overflow: hidden;
}
.brand {
  font-family: var(--serif);
  color: var(--accent);
  white-space: nowrap;
  letter-spacing: 0.12em;
  font-size: 0.95rem;
  flex: 0 0 auto;
}
.meta {
  flex: 1;
  color: var(--muted);
  font-size: 0.95rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.progress { color: var(--accent); font-size: 0.9rem; }
.saved { color: var(--accent); font-size: 0.95rem; }
.zoom-row, .help-btn, .hide-rejects {
  flex: 0 0 auto;
}
.zoom-row {
  display: flex;
  gap: 0.3rem;
}
.zoom-row button.active { border-color: var(--accent); color: var(--accent); }
#smallerBtn.active { border-color: var(--accent); color: var(--accent); }
.zoom-row button,
.help-btn,
.sweep button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  min-height: 2.1rem;
  cursor: pointer;
}
.hide-rejects {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.who { color: var(--muted); font-size: 0.9rem; }
.tally { margin: 0 0 0.7rem; font-size: 0.9rem; color: var(--muted); }
.tally.lean-keep { color: #b7e0cf; }
.tally.lean-reject { color: #f0c4c4; }
.tally.lean-split { color: var(--accent); }
.lock-msg {
  margin: 0 0 0.7rem;
  font-size: 0.9rem;
  color: #f0c4c4;
}
.lock-msg[hidden] { display: none; }
.form-error {
  margin: 0 0 0.7rem;
  font-size: 0.9rem;
  color: #f0c4c4;
}
.form-error[hidden] { display: none; }

.more-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 18, 0.72);
  z-index: 30;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3.4rem 0.8rem 1rem;
}
.more-backdrop[hidden] { display: none; }
.more-card {
  width: min(22rem, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.05rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.more-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.15rem;
}
.more-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: auto;
}
.login-card {
  width: min(26rem, calc(100% - 2rem));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem 1.3rem 1.6rem;
}
.login-card h1 {
  font-family: var(--serif);
  font-size: 1.6rem;
  margin: 0.2rem 0 0.5rem;
}
.login-lead { color: var(--muted); margin: 0 0 1rem; }
.login-go {
  margin-top: 0.8rem;
  width: 100%;
  min-height: 2.5rem;
  background: #101825;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.login-error { color: #f0c4c4; margin: 0.7rem 0 0; }

.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  grid-template-rows: minmax(0, 1fr);
}

.work {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 2rem;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #070b12;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  container-type: size;
}
.stage img {
  max-width: calc(100cqw * var(--hero-scale));
  max-height: calc(100cqh * var(--hero-scale));
  width: auto;
  height: auto;
  object-fit: contain;
  border: 3px solid transparent;
  border-radius: 2px;
}
.stage img.sweep-on {
  border-color: #c0392b;
  box-shadow: 0 0 0 1px #c0392b;
}

.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 999px;
  background: rgba(20, 28, 43, 0.8);
  color: var(--text);
  font-size: 1.6rem;
  cursor: pointer;
}
.nav.prev { left: 0.6rem; }
.nav.next { right: 0.6rem; }

.lightbox-close {
  display: none;
  position: fixed;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 60;
  width: 2.7rem;
  height: 2.7rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: rgba(12, 18, 28, 0.94);
  color: var(--accent);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 3px rgba(12, 18, 28, 0.55);
}
body.lightbox-open .lightbox-close {
  display: flex !important;
}

.strip-bar {
  flex: 0 0 auto;
  height: auto;
  border-top: 1px solid var(--border);
  background: #101825;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.sweep-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  flex: 0 0 auto;
}
.sweep {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem 0;
  flex: 0 0 auto;
}
.people-sweep {
  border-left: 1px solid var(--border);
  margin-left: 0.15rem;
  padding-left: 0.7rem;
}
.sweep-label { color: var(--muted); font-size: 0.8rem; margin-right: 0.2rem; }
.people-sweep-names {
  color: var(--accent);
  font-size: 0.8rem;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.people-sweep-names:empty { display: none; }
#sweepToggle.active,
#peopleSweepToggle.active {
  border-color: #c0392b;
  color: #f0c4c4;
  box-shadow: 0 0 0 1px #c0392b;
}
#peopleFieldset.people-sweep-on {
  border-color: #c0392b;
  box-shadow: 0 0 0 1px #c0392b;
}
.sweep button.active[data-paint="keep"] { border-color: var(--keep); color: #b7e0cf; }
.sweep button.active[data-paint="maybe"] { border-color: var(--maybe); color: var(--accent); }
.sweep button.active[data-paint="reject"] { border-color: var(--reject); color: #f0c4c4; }

.strip {
  display: flex;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem 0.4rem;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  min-width: 0;
  flex: 0 0 var(--strip-h);
  height: var(--strip-h);
  max-height: var(--strip-h);
  touch-action: pan-x;
}
.strip .cell {
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;
  border: 2px solid transparent;
  height: 4.6rem;
  padding: 0;
  background: transparent;
}
.strip .cell img {
  height: 100%;
  width: auto;
  display: block;
  opacity: 0.8;
}
.strip .cell.current { border-color: var(--accent); }
.strip .cell.is-cover { box-shadow: inset 0 0 0 2px var(--muted); }
.strip .cell.current img { opacity: 1; }
.strip .cell.sweep-on {
  border-color: #c0392b;
  box-shadow: 0 0 0 1px #c0392b;
}
.strip .mark {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  font-size: 0.7rem;
  line-height: 1.15rem;
  text-align: center;
  background: #070b12;
  color: var(--text);
}
.strip .cell.keep .mark { color: #b7e0cf; }
.strip .cell.maybe .mark { color: var(--accent); }
.strip .cell.reject .mark { color: #f0c4c4; }
.strip .cell.reject img { opacity: 0.35; }

.panel {
  min-height: 0;
  overflow: auto;
  padding: 0.8rem 1rem 1.2rem;
  background: var(--panel);
  border-left: 1px solid var(--border);
}
.filename { margin: 0; font-weight: 600; word-break: break-all; }
.sub { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.85rem; }
.more-card .tally { margin: 0; }

.desk-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 0.6rem;
  width: 100%;
  max-width: 100%;
}
.desk-tabs button {
  background: #101825;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  min-height: 2.1rem;
  font: inherit;
}
.desk-tabs button[aria-selected="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
.tab-panel[hidden] { display: none; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 0.7rem;
  padding: 0.5rem;
}
legend { color: var(--muted); font-size: 0.8rem; padding: 0 0.3rem; }

.row, .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.row button, .chips button {
  background: #101825;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  min-height: 2.2rem;
}
.row button.active[data-status="keep"],
.chips button.active { border-color: var(--accent); color: var(--accent); }
.row button.active[data-status="reject"] { border-color: var(--reject); color: #f0c4c4; }
.row button.active[data-status="maybe"] { border-color: var(--maybe); color: var(--accent); }
.row button.active[data-rating] { border-color: var(--accent); color: var(--accent); }
.row button:disabled { opacity: 0.45; cursor: not-allowed; }

.tagged {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-height: 1.4rem;
  margin-bottom: 0.4rem;
}
.tagged .tag {
  background: #101825;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 8px;
  padding: 0.15rem 0.45rem;
  font-size: 0.85rem;
}
.guest-add {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}
.guest-add input {
  flex: 1;
  min-width: 0;
  background: #101825;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font: inherit;
}
.guest-add button {
  background: #101825;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}
.guest-list {
  max-height: 9rem;
  overflow: auto;
}
.chip-wrap {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
}
.chip-wrap > button:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.chip-hide {
  background: #101825;
  color: var(--muted);
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  min-height: 2.2rem;
}
.chip-hide:hover { color: #f0c4c4; }

label {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  margin: 0.25rem 0;
  font-size: 0.92rem;
}
.cover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0 0.5rem;
}
.cover-actions button {
  background: #101825;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  min-height: 2.2rem;
}
.cover-actions button.is-gray {
  color: var(--muted);
  border-color: var(--muted);
  opacity: 0.85;
}
.cover-actions button:disabled {
  cursor: default;
  opacity: 0.55;
}
label.stack { flex-direction: column; margin-top: 0.5rem; }
textarea {
  width: 100%;
  background: #101825;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem;
  font: inherit;
}
textarea:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.hint,
.site-copy-status {
  margin: 0.35rem 0 0.2rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.site-copy-status[hidden] { display: none; }

.help-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 18, 0.55);
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 3.4rem 1rem 1rem;
}
.help-backdrop[hidden] { display: none; }
.help {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  max-width: 24rem;
  width: min(24rem, 100%);
}
.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}
.help h2 { margin: 0; font-size: 1rem; font-family: var(--serif); }
.help p { margin: 0.25rem 0; color: var(--muted); }

@media (max-width: 900px) {
  html, body { overflow: auto; height: auto; }
  .shell { grid-template-columns: 1fr; height: auto; }
  .work {
    min-height: 0;
    height: auto;
    overflow: visible;
    padding-bottom: 0;
  }
  .stage { display: none; }
  body.lightbox-open { overflow: hidden; }
  body.lightbox-open .stage {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 50;
    min-height: 100dvh;
    background: rgba(7, 11, 18, 0.94);
  }
  .nav { width: 2.5rem; height: 2.5rem; }
  .panel { border-left: 0; border-top: 1px solid var(--border); overflow-x: hidden; }
  .desk-tabs button {
    padding: 0.28rem 0.45rem;
    min-height: 2rem;
    font-size: 0.88rem;
  }
  #helpBtn,
  .help-backdrop { display: none !important; }
}

@media (max-width: 430px) {
  .people-sweep {
    border-left: 0;
    margin-left: 0;
    padding-left: 0.6rem;
  }
  .people-sweep-names { max-width: 9.5rem; }
  .top {
    gap: 0.28rem;
    padding: 0.32rem 0.4rem;
  }
  .brand { font-size: 0.82rem; letter-spacing: 0.1em; }
  .meta { font-size: 0.82rem; }
  .zoom-row button,
  #moreBtn {
    padding: 0.22rem 0.42rem;
    min-height: 1.9rem;
    font-size: 0.82rem;
  }
}
