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

body {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: #111;
  color: #eee;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #1e1e1e;
  border-bottom: 1px solid #333;
}

#counter {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
  color: #aaa;
}

.nav-btn, .login-btn {
  padding: 6px 14px;
  background: #333;
  border: 1px solid #555;
  color: #eee;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}

.nav-btn:hover, .login-btn:hover {
  background: #444;
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ── Main image area ── */
main {
  flex: 1;
  min-height: 0;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-container {
  position: relative;
  margin: 0 auto;
  background: #000;
  min-height: 200px;
  /* width + height set by JS in _fitContainer */
}

img-comparison-slider {
  width: 100%;
  height: 100%;
}

img-comparison-slider img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  background: #000;
}

/* Before / After labels */
.img-label {
  position: absolute;
  top: 12px;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  border-radius: 3px;
  pointer-events: none;
  z-index: 10;
  user-select: none;
}
.label-before { left: 12px; }
.label-after  { right: 12px; }

/* SVG overlay — sits above the slider */
#annot-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* default: view mode */
  overflow: visible;
}

/* ── Admin toolbar ── */
.toolbar {
  display: none; /* hidden until .admin-logged-in */
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: #1e1e1e;
  border-top: 1px solid #333;
  flex-wrap: wrap;
}

.admin-logged-in .toolbar {
  display: flex;
}

.mode-group {
  display: flex;
  gap: 4px;
}

.mode-btn {
  padding: 5px 12px;
  background: #2a2a2a;
  border: 1px solid #555;
  color: #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
}

.mode-btn.active {
  background: #555;
  color: #fff;
  border-color: #888;
}

.tool-buttons {
  display: none; /* shown only in annotate mode */
  gap: 6px;
}

.tool-btn {
  padding: 5px 10px;
  background: #2a2a2a;
  border: 1px solid #555;
  color: #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
}

.tool-btn.active {
  background: #555;
  color: #fff;
  border-color: #888;
}

.color-swatches {
  display: flex;
  gap: 6px;
  align-items: center;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.swatch.active {
  border-color: #fff;
  outline: 2px solid #555;
}

/* ── Login modal ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #222;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 300px;
  width: 90%;
  max-width: 360px;
}

.modal-content h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-content input {
  padding: 9px 12px;
  background: #2a2a2a;
  border: 1px solid #555;
  color: #eee;
  border-radius: 4px;
  font-size: 0.9rem;
  width: 100%;
}

.modal-content input:focus {
  outline: none;
  border-color: #888;
}

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

.modal-actions button {
  flex: 1;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  border: 1px solid #555;
  background: #555;
  color: #fff;
}

.modal-actions .btn-secondary {
  background: #2a2a2a;
  color: #aaa;
}

.error {
  color: #ff6b6b;
  font-size: 0.82rem;
}

.hidden {
  display: none !important;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  header {
    padding: 6px 10px;
    gap: 6px;
  }

  .nav-btn, .login-btn {
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  #counter {
    font-size: 0.8rem;
  }

  main {
    padding: 0;          /* remove gap so image uses full width */
    align-items: flex-start; /* image anchors to top, gap goes to bottom */
  }

  .image-container {
    min-height: unset;   /* remove 200px floor on mobile */
  }

  .toolbar {
    padding: 8px 12px;
    gap: 10px;
  }
}
