* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #1b1b1b;
}

#appRoot {
  display: flex;
  height: 100vh;
  width: 100vw;
}

#mapFrameWrapper {
  flex: 1 1 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #26282b;
  overflow: hidden;
}

#mapFrame {
  position: relative;
  /* Fallback size so the MapView never constructs against a 0x0 container -
     resizeMapFrame() overrides this with explicit px dimensions once the
     wrapper has laid out, but the view must never start at zero size. */
  width: 100%;
  height: 100%;
}

#viewDiv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#mapLoadingBar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  z-index: 20;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

#mapLoadingBar.active {
  opacity: 1;
}

#mapLoadingBar::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  background: #ff9800;
  box-shadow: 0 0 8px 1px rgba(255, 152, 0, 0.9);
  animation: mapLoadingSweep 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes mapLoadingSweep {
  0% { left: -35%; }
  100% { left: 100%; }
}

#customZoomControls {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  border-radius: 3px;
  overflow: hidden;
}

#customZoomControls button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: #fff;
  color: #1b1b1b;
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
}

#customZoomControls button:hover {
  background: #f0f0f0;
}

#customZoomControls button.zoom-fine {
  height: 24px;
  font-size: 0.85rem;
}

#customZoomControls #customZoomInFineBtn {
  border-top: 2px solid #d9d9d9;
}

#customZoomControls button + button {
  border-top: 1px solid #d9d9d9;
}

.title-overlay {
  position: absolute;
  inset: 0;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  pointer-events: none;
}

.title-overlay.align-left {
  justify-content: flex-start;
}

.title-overlay.align-center {
  justify-content: center;
}

.title-overlay.align-right {
  justify-content: flex-end;
}

.title-overlay span {
  background: rgba(255, 255, 255, 0.85);
  padding: 4px 10px;
  border-radius: 4px;
  font-family: "Cinzel", serif;
  font-weight: 500;
  font-size: 1.3rem;
  color: #000;
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
  max-width: 90%;
}

.title-overlay span:empty {
  display: none;
}

.draw-hint-overlay {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  z-index: 16;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.draw-hint-overlay span {
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  max-width: 80%;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.title-position-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  margin-top: -4px;
}

.address-row {
  display: flex;
  gap: 10px;
}

.address-row label {
  min-width: 0;
}

.address-row input,
.address-row select {
  min-width: 0;
  width: 100%;
}

.address-city {
  flex: 3;
}

.address-state {
  flex: 1.2;
}

.address-zip {
  flex: 1.2;
}

.inline-radio {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  font-weight: normal;
}

.shipping-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  margin-bottom: 6px;
  font-weight: normal;
  font-size: 0.9rem;
  cursor: pointer;
}

.shipping-option:has(input:checked) {
  border-color: #2b6cb0;
  background: #eef5fc;
}

#panel {
  flex: 0 0 340px;
  max-width: 340px;
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  background: #fafafa;
  border-left: 1px solid #d9d9d9;
}

#panel h1 {
  font-size: 1.25rem;
  margin: 0 0 8px;
}

.hint {
  font-size: 0.85rem;
  color: #555;
  margin: 4px 0 0;
}

.step {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.draft-banner {
  background: #fff8e1;
  border: 1px solid #f0d78c;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 16px;
}

.draft-banner p {
  margin: 0 0 10px;
  font-size: 0.85rem;
}

.faq-section {
  margin: 16px 0;
}

.faq-section details {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.faq-section summary {
  cursor: pointer;
  font-weight: 500;
}

.faq-section p {
  margin: 8px 0 2px;
  color: #444;
}

.step-label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

#previewSection {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

#previewFrame {
  width: 100%;
  max-height: 70vh;
  overflow: auto;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  background: #f4f4f4;
}

#previewCanvas {
  max-width: 100%;
  height: auto;
  display: block;
}

#confirmOrderBtn {
  background: #1a5c30;
  border-color: #1a5c30;
}

#backToEditBtn {
  background: #fff;
  color: #2b6e3f;
}

#searchContainer {
  width: 100%;
}

.color-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.color-picker input[type="color"] {
  width: 40px;
  height: 28px;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}

.color-picker select {
  font-size: 0.85rem;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.marker-style-row {
  justify-content: flex-start;
  gap: 10px;
}

.marker-style-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.marker-size-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.marker-size-label {
  font-size: 0.7rem;
  color: #555;
  line-height: 1;
}

.marker-style-controls select#markerSize {
  flex: 0 0 auto;
  width: 3.2em;
}

.range-with-value {
  display: flex;
  align-items: center;
  gap: 6px;
}

.range-with-value span {
  font-size: 0.8rem;
  color: #555;
  min-width: 2.4em;
  text-align: right;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

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

.color-swatch.swatch-white {
  border-color: #ccc;
}

.color-swatch.selected {
  border-color: #1b1b1b;
}

.size-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.size-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.size-option input {
  flex-shrink: 0;
}

.size-option span {
  white-space: nowrap;
}

#fullScreenBtn {
  background: #fff;
  color: #2b6e3f;
  margin-bottom: 10px;
}

.custom-size-row {
  display: flex;
  gap: 12px;
  margin: 4px 0 10px 22px;
}

.custom-size-row label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  gap: 4px;
}

.custom-size-row select {
  font-size: 0.85rem;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#cartSummary {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e0e0e0;
}

#cartItemsList {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  font-size: 0.85rem;
}

#cartItemsList li {
  padding: 4px 0;
}

.link-button {
  border: none;
  background: none;
  color: #b3261e;
  padding: 0;
  font-size: 0.8rem;
  text-decoration: underline;
}

.link-button:hover {
  color: #7d1a15;
}

.download-preview-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.85rem;
  color: #2b6e3f;
  text-decoration: underline;
}

.download-preview-link:hover {
  color: #1e4d2b;
}

button {
  cursor: pointer;
  border: 1px solid #2b6e3f;
  background: #2b6e3f;
  color: #fff;
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 0.9rem;
}

button:disabled {
  cursor: not-allowed;
  background: #b9b9b9;
  border-color: #b9b9b9;
}

#clearBtn {
  background: #fff;
  color: #2b6e3f;
}

#clearBtn:disabled {
  color: #b9b9b9;
  border-color: #b9b9b9;
}

form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  gap: 4px;
}

input, textarea {
  font-size: 0.9rem;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
}

#submitBtn {
  margin-top: 6px;
}

#submitStatus {
  min-height: 1.2em;
}

#submitStatus.error {
  color: #b3261e;
}

#drawStatus.error {
  color: #b3261e;
}

#submitStatus.success {
  color: #2b6e3f;
}

@media (max-width: 720px) {
  #appRoot {
    flex-direction: column;
  }

  #panel {
    flex: 0 0 auto;
    max-width: 100%;
    max-height: 55vh;
    border-left: none;
    border-top: 1px solid #d9d9d9;
  }

  #viewDiv {
    height: 45vh;
  }
}
