* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
/* Login Screen */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}
.login-card {
  background: #fff;
  padding: 40px 36px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  width: 340px;
  text-align: center;
}
.login-title {
  font-size: 1.4rem;
  color: #1a1a2e;
  margin-bottom: 4px;
}
.login-sub {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 24px;
}
.login-input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}
.login-btn {
  width: 100%;
  padding: 12px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 4px;
}
.login-btn:hover { background: #2563eb; }
.login-error {
  color: #e53e3e;
  font-size: 12px;
  margin-top: 10px;
  min-height: 16px;
}
/* App header with user info */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
  background: #1a1a2e;
  padding: 8px 16px;
  border-radius: 10px;
}
.app-header h1 {
  text-align: left;
  margin-bottom: 0;
  color: #fff;
}
.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
}
.user-company {
  color: #fff;
  font-weight: 600;
}
.user-usage, .user-usage-daily {
  color: #3b82f6;
  background: #e8f1fc;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.7rem;
}
.user-usage-daily {
  color: #666;
  background: #f0f0f0;
}
.btn-logout {
  padding: 5px 12px;
  font-size: 0.7rem;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.btn-logout:hover { background: rgba(255,255,255,0.3); }

.btn-settings {
  padding: 5px 12px;
  font-size: 0.7rem;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.btn-settings:hover { background: rgba(255,255,255,0.3); }

/* Settings Modal */
.settings-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 1000;
  display: flex; justify-content: center; align-items: center;
}
.settings-modal {
  background: #fff; border-radius: 12px; width: 560px; max-height: 88vh;
  overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.settings-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid #eee;
}
.settings-modal-header h2 { font-size: 18px; color: #1a1a2e; font-weight: 600; }
.settings-close {
  background: none; border: none; font-size: 26px; cursor: pointer; color: #999;
  line-height: 1; padding: 0 4px;
}
.settings-close:hover { color: #333; }
.settings-modal-body { padding: 24px; }
.settings-section {
  margin-bottom: 20px; padding: 18px 20px;
  background: #f9fafb; border: 1px solid #eef0f3; border-radius: 10px;
}
.settings-section h3 {
  font-size: 15px; color: #1a1a2e; margin-bottom: 4px; font-weight: 600;
}
.settings-desc { font-size: 12.5px; color: #6b7280; margin-bottom: 14px; }
.settings-row {
  display: flex; align-items: center; gap: 14px; margin-bottom: 12px;
}
.settings-row:last-child { margin-bottom: 0; }
.settings-row > label { font-size: 13px; color: #4b5563; min-width: 96px; font-weight: 500; }
.settings-toggle {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 8px 12px; background: #fff; border: 1px solid #e5e7eb;
  border-radius: 8px; min-width: auto !important;
}
.settings-toggle input { width: 16px; height: 16px; cursor: pointer; }
.settings-toggle span { font-size: 13.5px; color: #1a1a2e; font-weight: 500; }
.settings-file-input {
  font-size: 12.5px; flex: 1; padding: 6px 8px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
}
.settings-range { flex: 1; accent-color: #3b82f6; }
.settings-row #watermarkOpacityVal {
  min-width: 42px; text-align: right; font-size: 13px; color: #1a1a2e; font-weight: 600;
}
.settings-select {
  padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 6px;
  font-size: 13.5px; background: #fff; cursor: pointer; min-width: 140px;
}
.settings-select:focus, .settings-text-input:focus {
  outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.settings-text-input {
  flex: 1; padding: 9px 12px; border: 1px solid #e5e7eb; border-radius: 6px;
  font-size: 13.5px; background: #fff;
}
.watermark-preview {
  width: 72px; height: 72px; border: 1px dashed #d1d5db; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: #fff; flex-shrink: 0;
}
.watermark-preview img { max-width: 100%; max-height: 100%; }
.settings-modal-footer {
  padding: 14px 24px; border-top: 1px solid #eee; text-align: right;
  background: #fafbfc; border-radius: 0 0 12px 12px;
}
.btn-settings-save {
  padding: 10px 28px; background: #3b82f6; color: #fff; border: none;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.btn-settings-save:hover { background: #2563eb; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  height: 100vh;
  overflow: hidden;
}

.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 10px 16px;
}

h1 {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #222;
  margin-bottom: 2px;
}

.version {
  text-align: center;
  color: rgba(255,255,255,0.5);
  font-size: 0.65rem;
  margin-bottom: 2px;
}

.subtitle {
  text-align: center;
  color: #888;
  margin-bottom: 10px;
  font-size: 0.8rem;
}

.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

/* Main two-column layout */
.main-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 10px;
  min-height: calc(90vh - 50px);
  align-items: start;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.left-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.right-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 10px;
  max-height: calc(100vh - 20px);
}

/* Image boxes */
.image-box {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e0e0e0;
}

.image-box h3 {
  padding: 6px 12px;
  font-size: 0.7rem;
  color: #999;
  border-bottom: 1px solid #eee;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drop-hint {
  text-transform: none;
  color: #bbb;
  font-weight: normal;
  font-size: 0.65rem;
}

#roomBox {
  cursor: pointer;
  transition: border-color 0.2s;
}

#roomBox:hover,
#roomBox.dragover {
  border-color: #3b82f6;
}

.room-placeholder {
  padding: 20px;
  text-align: center;
  color: #aaa;
}

.room-placeholder .upload-icon {
  font-size: 2rem;
  margin-bottom: 4px;
}

.room-placeholder p {
  font-size: 0.8rem;
}

.image-wrap {
  position: relative;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-wrap img {
  width: 100%;
  max-height: 28vh;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}



.check-group {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 4px;
}

.style-check-full {
  grid-column: 1 / -1;
  text-align: center;
  justify-content: center;
}

.style-check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.75rem;
  color: #555;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  white-space: nowrap;
}

.style-check:has(input:checked) {
  border-color: #3b82f6;
  background: #eef4ff;
  color: #3b82f6;
}

.style-check:has(input[type="checkbox"]:checked)::before {
  content: "✓ ";
  font-weight: bold;
}

.style-check input[type="checkbox"],
.style-check input[type="radio"] {
  display: none;
}

.btn-generate {
  width: 100%;
  padding: 10px;
  background: #3b82f6;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-generate:hover {
  background: #2563eb;
}

.btn-cancel {
  width: 100%;
  padding: 10px;
  background: #fff;
  border: 1px solid #e53e3e;
  border-radius: 6px;
  color: #e53e3e;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-cancel:hover {
  background: #fff5f5;
}


.btn-reset {
  width: 100%;
  padding: 6px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  color: #999;
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-reset:hover {
  border-color: #e53e3e;
  color: #e53e3e;
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-download {
  width: 100%;
  padding: 7px;
  text-align: center;
  font-size: 0.8rem;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  background: #3b82f6;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.btn-download:hover {
  background: #2563eb;
  border-color: #2563eb;
}


.dl-small {
  float: right;
  padding: 1px 8px;
  font-size: 0.6rem;
  border: 1px solid #3b82f6;
  border-radius: 4px;
  background: #3b82f6;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.dl-small:hover {
  background: #2563eb;
}

.result-inner {
  display: flex;
  flex-direction: row;
  gap: 6px;
  padding: 4px;
  align-items: flex-start;
  max-height: calc(85vh - 80px);
  overflow: visible;
}

.result-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
}

.result-main .image-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.result-main .btn-download {
  width: auto;
  padding: 6px 30px;
}

.result-box {
  display: flex;
  flex-direction: column;
  position: relative;
}

.result-box .result-inner {
  flex: 1;
}

.history-col {
  width: 100px;
  min-width: 100px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}

.history-item {
  position: relative;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: visible;
  cursor: pointer;
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.history-item:hover {
  border-color: #3b82f6;
}

.history-item.active {
  border-color: #3b82f6;
  border-width: 2px;
}

.history-item img {
  width: 100%;
  height: auto;
  display: block;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.history-item.active img {
  opacity: 1;
}

.history-delete {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  font-size: 0.7rem;
  line-height: 16px;
  text-align: center;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}
.history-item:hover .history-delete {
  opacity: 1;
}
.history-delete:hover {
  background: rgba(220,38,38,0.8);
}

.history-item .dl-small {
  position: absolute;
  top: 2px;
  right: 2px;
  padding: 0px 4px;
  font-size: 0.5rem;
}

.history-label {
  font-size: 0.55rem;
  color: #888;
  text-align: center;
  padding: 1px 0;
  background: #f8f8f8;
  border-top: 1px solid #eee;
}

/* Result box */
.result-box {
  flex: 1;
  min-height: 0;
}

.result-box .image-wrap {
  min-height: 100px;
  height: 100%;
}

.result-box .image-wrap img {
  max-width: 100%;
  max-height: calc(85vh - 120px);
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

/* Placeholder */
.placeholder {
  padding: 60px 30px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-guide {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.guide-step {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #999;
  font-size: 0.9rem;
}

.guide-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.guide-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.guide-text {
  font-weight: 600;
  color: #555;
}
.guide-preview {
  font-size: 0.75rem;
  color: #aaa;
  background: #f5f5f5;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px dashed #ddd;
}
.guide-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.guide-tag {
  font-size: 0.7rem;
  padding: 3px 8px;
  border: 1px solid #ddd;
  border-radius: 12px;
  color: #aaa;
}
.guide-tag.active {
  border-color: #3b82f6;
  color: #3b82f6;
  background: #eef4ff;
}
.guide-btn-preview {
  display: inline-block;
  font-size: 0.75rem;
  padding: 6px 20px;
  background: #3b82f6;
  color: #fff;
  border-radius: 6px;
  opacity: 0.6;
}

/* Step badges on left column */
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  margin-right: 6px;
  vertical-align: middle;
}
.step-badge-white {
  background: rgba(255,255,255,0.35);
  color: #fff;
  margin-right: 6px;
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: #e8e8e8;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #22c55e);
  border-radius: 3px;
  width: 0%;
  transition: width 0.5s ease;
}

.box-body {
  padding: 8px 10px;
}

.box-body textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #eee;
  border-radius: 4px;
  background: #fafafa;
  color: #333;
  font-size: 0.85rem;
  resize: vertical;
  font-family: inherit;
  min-height: 60px;
}

.box-body textarea:focus {
  outline: none;
  border-color: #3b82f6;
  background: #fff;
}

/* Progress section */
.progress-section .box-body {
  padding: 10px 12px;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.progress-label {
  font-size: 0.7rem;
  color: #888;
  min-width: 28px;
}

.progress-status {
  font-size: 0.75rem;
  color: #888;
  text-align: center;
  margin-top: 4px;
}


/* Error */
.error {
  padding: 10px 14px;
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 6px;
  color: #c53030;
  text-align: center;
  font-size: 0.85rem;
}

/* Lightbox overlay */
#lightboxOverlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#lightboxOverlay.show {
  display: flex;
}

#lightboxOverlay img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
}

#lightboxOverlay button {
  padding: 8px 30px;
  background: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}


/* Tablet: switch to single column */
@media (max-width: 1000px) {
  .container { padding: 10px 8px; }
  h1 { font-size: 1.2rem; }

  .main-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .left-col {
    flex-direction: column;
    gap: 6px;
    max-height: none;
    overflow-y: visible;
  }

  .right-col {
    min-height: 300px;
  }

  .history-col {
    width: 100%;
    min-width: 100%;
    flex-direction: row;
    max-height: 100px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .history-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .history-list img {
    width: 80px;
    height: 60px;
  }
}

/* Mobile */
@media (max-width: 640px) {
  body { overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .container { padding: 6px; max-width: 100vw; overflow-x: hidden; overflow-y: auto; }
  h1 { font-size: 0.9rem; }
  .version { display: none; }
  .subtitle { font-size: 0.65rem; margin-bottom: 6px; }

  .app-header {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .app-header > div:first-child {
    flex: 1;
  }

  .user-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    font-size: 0.65rem;
  }

  .user-company { font-size: 0.65rem; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-usage, .user-usage-daily { font-size: 0.6rem; padding: 2px 5px; }
  .btn-settings, .btn-logout { font-size: 0.6rem; padding: 4px 8px; }

  .login-card {
    width: 90vw;
    padding: 24px 20px;
  }

  .main-layout {
    grid-template-columns: 1fr;
    gap: 6px;
    height: auto;
    min-height: 0;
  }

  .left-col {
    max-height: none;
    overflow-y: visible;
    height: auto;
  }

  .right-col {
    height: auto;
    min-height: 0;
  }

  .image-box {
    min-height: 200px;
  }

  .btn-generate {
    padding: 12px;
    font-size: 1rem;
  }

  .settings-modal {
    width: 95vw;
    max-height: 90vh;
  }

  .settings-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .settings-row label {
    min-width: auto;
  }

  .history-col {
    width: 100%;
    min-width: 100%;
    flex-direction: row;
    max-height: 80px;
  }

  .history-list {
    flex-direction: row;
  }

  .history-list img {
    width: 60px;
    height: 45px;
  }

  .box-body textarea { font-size: 0.8rem; }
  .btn-restart { display: none; }

  .check-group {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }

  .style-check {
    font-size: 0.75rem;
    padding: 6px 8px;
  }

  .style-check-full {
    grid-column: 1 / -1;
  }

  .image-box {
    padding: 8px;
  }

  .image-box h3 {
    font-size: 0.8rem;
    margin-bottom: 4px;
  }
}

/* Restart button */
.btn-restart {
  position: fixed;
  bottom: 12px;
  left: 12px;
  padding: 6px 14px;
  font-size: 0.75rem;
  background: #666;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.6;
  z-index: 1000;
  transition: opacity 0.2s;
}
.btn-restart:hover {
  opacity: 1;
}

/* === Before/After compare slider === */
.compare-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
  user-select: none;
  line-height: 0;
}
/* Result image is the base (always shown) */
.compare-base {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 180px);
  width: auto;
  height: auto;
  object-fit: contain;
}
/* Original (before) image is overlayed in compare mode, clipped to the LEFT portion */
.compare-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  clip-path: inset(0 50% 0 0);
  display: none;
}
.compare-wrapper.active .compare-overlay {
  display: block;
}
.compare-wrapper:not(.active) .compare-slider {
  display: none;
}
.compare-slider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 5;
}
.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: #4a90e2;
  font-weight: bold;
  letter-spacing: -2px;
  cursor: ew-resize;
}
.compare-wrapper::before {
  content: "BEFORE";
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.6rem;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 3px;
  z-index: 6;
  letter-spacing: 0.5px;
}
.compare-wrapper::after {
  content: "AFTER";
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(74, 144, 226, 0.85);
  color: #fff;
  font-size: 0.6rem;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 3px;
  z-index: 6;
  letter-spacing: 0.5px;
}
.compare-wrapper:not(.active)::before,
.compare-wrapper:not(.active)::after {
  display: none;
}
.result-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
/* Floating compare icon button */
.btn-compare-float {
  position: absolute;
  bottom: 4px;
  right: 4px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  color: #fff;
  border: none;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.2s;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.btn-compare-float:hover {
  background: rgba(59,130,246,0.9);
}
.btn-compare-float.active {
  background: #3b82f6;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-content {
  background: #fff;
  border-radius: 10px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}
.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
  margin: 0;
  padding: 0;
  border: none;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #888;
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
}
.modal-close:hover {
  color: #333;
}
.modal-body {
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
}
.modal-photo-wrap {
  position: relative;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 4px;
  overflow: hidden;
}
.modal-photo-wrap img {
  display: block;
  max-width: 100%;
  max-height: 30vh;
  object-fit: contain;
}

/* Placement mode tabs */
.placement-tabs {
  display: flex;
  border-bottom: 1px solid #eee;
}
.placement-tab {
  flex: 1;
  padding: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  background: #f5f5f5;
  color: #888;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.placement-tab:first-child {
  border-radius: 8px 0 0 0;
}
.placement-tab:last-child {
  border-radius: 0 8px 0 0;
}
.placement-tab.active {
  background: #fff;
  color: #4a90e2;
  border-bottom: 2px solid #4a90e2;
}
.placement-tab:not(.active):hover {
  background: #eee;
}
.placement-summary {
  margin-top: 6px;
  font-size: 0.7rem;
  color: #666;
}
.placement-summary-item {
  display: inline-block;
  padding: 2px 6px;
  margin: 2px;
  background: #e8f1fc;
  border-radius: 3px;
  font-size: 0.65rem;
  color: #4a90e2;
}

/* Open placement modal button */
.btn-open-placement {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  font-size: 0.75rem;
  background: #4a90e2;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-open-placement:hover {
  background: #357abd;
}
.placement-count-badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #fff;
  color: #4a90e2;
  border-radius: 9px;
  font-size: 0.65rem;
  font-weight: bold;
  line-height: 18px;
  text-align: center;
}

/* === Placement editor === */
.ref-wall-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.photo-detecting {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 0.75rem;
  z-index: 5;
}
.ref-wall-status {
  font-size: 0.75rem;
  color: #666;
}
.ref-wall-status strong {
  color: #4a90e2;
}
.ref-wall-detecting {
  font-size: 0.7rem;
  color: #999;
}
/* Wall type selector buttons */
.wall-type-selector {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 0.7rem;
  margin-bottom: 6px;
}
.wall-type-btn {
  padding: 4px 10px;
  font-size: 0.7rem;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}
.wall-type-btn.active {
  background: #4a90e2;
  color: #fff;
  border-color: #4a90e2;
}
/* Highlight the reference wall edge */
.placement-room.ref-back  { border-top: 4px solid #4a90e2 !important; }
.placement-room.ref-left  { border-left: 4px solid #4a90e2 !important; }
.placement-room.ref-right { border-right: 4px solid #4a90e2 !important; }
.placement-room.ref-back .wall-top   { color: #4a90e2; font-weight: bold; }
.placement-room.ref-left .wall-left  { color: #4a90e2; font-weight: bold; }
.placement-room.ref-right .wall-right { color: #4a90e2; font-weight: bold; }
.wall-top {
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
}
.wall-bottom {
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
}
.furniture-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.furniture-btn {
  padding: 4px 8px;
  font-size: 0.7rem;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.furniture-btn:hover {
  background: #f0f0f0;
}
.furniture-btn.active {
  background: #4a90e2;
  color: #fff;
  border-color: #4a90e2;
}
.placement-room {
  position: relative;
  width: 100%;
  background: #fafafa;
  border: 2px solid #888;
  border-radius: 4px;
  cursor: crosshair;
  overflow: hidden;
}
.room-size-inputs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: #555;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.room-size-inputs input {
  width: 56px;
  padding: 2px 4px;
  font-size: 0.7rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #f5f5f5;
  color: #333;
}
.room-size-label {
  color: #666;
}
.wall-label {
  position: absolute;
  font-size: 0.6rem;
  color: #888;
  pointer-events: none;
  user-select: none;
}
.wall-left {
  left: 4px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: left center;
}
.wall-right {
  right: 4px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  transform-origin: right center;
}
.placement-items {
  position: absolute;
  inset: 0;
}
.placement-item {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.55rem;
  border-radius: 2px;
  cursor: grab;
  user-select: none;
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  text-shadow: 0 1px 1px rgba(0,0,0,0.4);
  overflow: hidden;
  text-align: center;
  line-height: 1;
  padding: 1px;
  z-index: 2;
}
.placement-item.is-rug {
  z-index: 1;
}
/* Bed pillow indicator */
.bed-pillow {
  position: absolute;
  top: 0;
  left: 10%;
  width: 80%;
  height: 20%;
  background: rgba(255,255,255,0.7);
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.9);
}
.bed-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.placement-item:hover {
  filter: brightness(1.1);
}
.placement-item.selected {
  outline: 2px solid #ffeb3b;
  outline-offset: 1px;
  z-index: 5;
}
.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffeb3b;
  border: 1px solid #333;
  border-radius: 2px;
  cursor: nwse-resize;
  z-index: 6;
}
.resize-tl { top: -5px; left: -5px; }
.resize-tr { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-bl { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-br { bottom: -5px; right: -5px; }
.item-controls {
  position: absolute;
  transform: translate(-50%, calc(-50% - 32px));
  display: flex;
  gap: 2px;
  z-index: 10;
  pointer-events: auto;
  align-items: center;
  background: rgba(255,255,255,0.95);
  padding: 3px 4px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  white-space: nowrap;
}
.item-controls .size-label {
  font-size: 0.6rem;
  color: #444;
  padding-right: 4px;
  border-right: 1px solid #ddd;
  margin-right: 2px;
}
.item-controls button {
  min-width: 22px;
  height: 20px;
  font-size: 0.6rem;
  padding: 0 3px;
  background: #fff;
  border: 1px solid #888;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-controls button:hover {
  background: #ffeb3b;
}
.room-size-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  color: #333;
}

.btn-clear-modify {
  margin-top: 4px;
  padding: 4px 10px;
  font-size: 0.7rem;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  float: right;
}
.btn-clear-modify:hover {
  background: #f0f0f0;
}
.btn-clear-placements {
  margin-top: 6px;
  padding: 4px 10px;
  font-size: 0.7rem;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}
.btn-clear-placements:hover {
  background: #f0f0f0;
}
