:root {
  --ui-bg: #22313f;
  --ui-accent: #2c3e50;
  --btn-gray: #d7dbe0;
  --btn-green: #22a06b;
  --btn-orange: #de792c;
}

html,
body {
  height: 100%;
}

body {
  background: #0b0d10;
}

.app {
  min-height: 100vh;
}

.side {
  background: var(--ui-bg);
  color: #f2f6f9;
  border-radius: .5rem;
  padding: 1rem;
}

.side h6 {
  opacity: .95;
}

.side .btn {
  width: 100%;
  font-weight: 700;
  border-radius: .35rem;
  letter-spacing: .2px;
}

.btn-gray {
  background: var(--btn-gray);
  color: #111;
  border: 1px solid #2b2b2b;
}

.btn-green {
  background: var(--btn-green);
  color: #fff;
  border: 1px solid #0d5037;
}

.btn-orange {
  background: var(--btn-orange);
  color: #fff;
  border: 1px solid #6e3f14;
}

.divider {
  height: 1px;
  background: rgba(255, 255, 255, .18);
  margin: .75rem 0 1rem 0;
}

.side input[type="file"] {
  display: none !important;
}

.stage {
  background: #000;
  border-radius: .5rem;
  border: 1px solid #222;
  min-height: 70vh;
  position: relative;
  overflow: hidden;
}

.stage-wrap {
  height: calc(100vh - 120px);
}

#preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.dropzone {
  border: 2px dashed #9aa0a6;
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: background .15s, border-color .15s;
  color: #f9f7f7;
  font-size: .95rem;
}

.dropzone.dragover {
  background: #f3f4f6;
  border-color: #111827;
}

.stage-wrap.dragover {
  outline: 2px dashed #9aa0a6;
  outline-offset: 6px;
}

.stage-wrap {
  position: relative;
}

.fab-trash {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: var(--bs-danger, #dc3545);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  opacity: 0.95;
  transition: transform .12s ease, opacity .12s ease, box-shadow .12s ease;
}

.fab-trash:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
}

.fab-trash:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.fab-info {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--btn-gray);
  color: #111;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  opacity: 0.95;
  transition: transform .12s ease, opacity .12s ease, box-shadow .12s ease;
  z-index: 1056;
}

.fab-info:hover {
  opacity: 1;
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
}

.fab-info:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.modal-open .fab-info {
  display: none;
}


#roiControlPanel {
  position: fixed;
  bottom: 20px;
  left: 45%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  display: none;
}

#luminanceChart {
  position: fixed;
  bottom: 5px;
  left: 50%;
  transform: translateX(60px);
  width: 450px;
  height: 200px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #444;
  border-radius: 8px;
  display: none;
  padding: 10px;
}

#luminanceChart canvas {
  width: 100%;
  height: 100%;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.roi-title {
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  margin: 0 0 8px 0;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.control-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 120px;
}

.control-btn {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 8px;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 1.1rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  user-select: none;
  -webkit-user-select: none;
}

.control-btn:hover {
  transform: scale(1.1);
  background: white;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

.control-btn:active,
.control-btn.pressed {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.7);
}

.control-btn.up {
  grid-column: 2;
  grid-row: 1;
}

.control-btn.left {
  grid-column: 1;
  grid-row: 2;
}

.control-btn.center {
  grid-column: 2;
  grid-row: 2;
  background: rgba(255, 255, 255, 0.4);
  font-size: 0.8rem;
  cursor: default;
  pointer-events: none;
}

.control-btn.right {
  grid-column: 3;
  grid-row: 2;
}

.control-btn.down {
  grid-column: 2;
  grid-row: 3;
}

.control-btn.rotate-left {
  grid-column: 1;
  grid-row: 3;
  font-size: 0.95rem;
}

.control-btn.rotate-right {
  grid-column: 3;
  grid-row: 3;
  font-size: 0.95rem;
}

#imageSwitchContainer {
  display: none;
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
}

.switch-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  padding: 0.5rem 1rem;
  border-radius: 25px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.switch-inner span {
  font-size: 0.85rem;
  font-weight: 500;
}

.switch-inner .form-check {
  margin: 0;
}

.switch-inner .form-check-input {
  cursor: pointer;
}

/* Model switch container */
.model-switch-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.35rem;
  min-height: 38px;
}

.model-switch-container span {
  font-size: 0.9rem;
  color: #f2f6f9;
  opacity: 0.9;
  user-select: none;
}

.model-switch-container .form-check {
  margin: 0;
}

.model-switch-container .form-check-input {
  cursor: pointer;
}

/* Luminescence button animation */
#btnLoadFluo {
  transition: all 0.3s ease;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  padding: 0;
  margin: 0;
}

#btnLoadFluo.show {
  max-height: 100px;
  opacity: 1;
  padding: 0.375rem 0.75rem;
  margin-top: 0.5rem;
}

.rotate-indicator {
  position: fixed;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  display: none;
  z-index: 1000;
  white-space: nowrap;
}

.rotate-indicator.active {
  display: block;
}

.crop-delete-btn {
  position: absolute;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  pointer-events: auto;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  padding-bottom: 2px;
  opacity: 0.5;
  color: white;
  transition: opacity 0.2s ease;
}

.crop-delete-btn:hover {
  opacity: 1;
  filter: brightness(1.2);
  transform: scale(1.1);
}

#luminanceSliderContainer {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  padding: 12px 8px;
  border-radius: 8px;
}

#luminanceSlider {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 8px;
  height: 150px;
  cursor: pointer;
}

#luminanceValue {
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  min-width: 40px;
  text-align: center;
}

@keyframes popupFadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.evaluation-popup button:hover {
  filter: brightness(1.1);
}

@keyframes popupFadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.evaluation-popup {
  position: fixed;
  background: var(--ui-bg, #1a1a2e);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 10000;
  animation: popupFadeIn 0.15s ease;
  min-width: 200px;
}

.evaluation-popup .popup-label {
  color: #fff;
  font-size: 13px;
}

.evaluation-popup .popup-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.evaluation-popup .btn-yes {
  background: #4caf50;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.evaluation-popup .btn-no {
  background: #f44336;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.evaluation-popup .btn-yes:hover,
.evaluation-popup .btn-no:hover {
  filter: brightness(1.1);
}

.evaluation-popup .btn-cancel {
  background: #666;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.evaluation-popup .btn-cancel:hover {
  filter: brightness(1.1);
}

.evaluation-popup .feedback {
  color: #4caf50;
  font-size: 14px;
}

#demoPanel {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 100;
}

#demoPanel .btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}