:root {
  --bg: #f5f0ea;
  --surface: #faf7f2;
  --surface2: #efe9e0;
  --border: rgba(0, 0, 0, 0.08);
  --accent: #e06a1a;
  --text: #1a1a18;
  --muted: #8a8278;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3 { font-family: "DM Sans", sans-serif; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: 100vh;
  width: 100vw;
}

.stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 30% 20%, #fbf8f3 0%, var(--bg) 55%, #ece5db 100%);
}

#globe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#globe.dragging { cursor: grabbing; }
#globe.pin-hover { cursor: pointer; }

/* ---------- Brand ---------- */
.brand {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 5;
}
.brand-mark {
  font-family: "Bebas Neue", sans-serif;
  font-size: 22px;
  letter-spacing: 2px;
  color: #fff;
  background: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  line-height: 1;
}
.brand-text h1 {
  font-family: "Bebas Neue", sans-serif;
  font-size: 26px;
  letter-spacing: 1.5px;
  margin: 0;
  line-height: 1;
}
.brand-text p {
  margin: 2px 0 0;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Add button ---------- */
.add-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(224, 106, 26, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.add-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(224, 106, 26, 0.45); }
.add-btn:active { transform: translateY(0); }
.add-btn .plus { font-size: 18px; line-height: 1; margin-top: -2px; }

.hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: rgba(250, 247, 242, 0.7);
  padding: 6px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  transition: opacity 0.5s ease;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 22px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-head h2 {
  font-family: "Bebas Neue", sans-serif;
  font-size: 22px;
  letter-spacing: 1px;
  margin: 0;
}
.count {
  font-family: "DM Mono", monospace;
  font-size: 13px;
  color: var(--accent);
  background: var(--surface2);
  padding: 2px 9px;
  border-radius: 999px;
}
.builds {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}
.build-row {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 12px 12px 12px 13px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease;
}
.build-row:hover, .build-row.active {
  background: var(--surface2);
}
.build-row .row-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.build-row .num {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  min-width: 20px;
}
.build-row .name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.build-row .loc {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--accent);
  margin: 3px 0 0 28px;
}
.build-row .model {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0 28px;
}
.sidebar-empty {
  padding: 24px 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Popup ---------- */
.popup {
  position: fixed;
  z-index: 50;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: popIn 0.14s ease;
}
@keyframes popIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.popup-photo-wrap {
  position: relative;
  height: 150px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.popup-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.popup-photo-fallback { width: 96px; height: 96px; }
.popup.has-photo .popup-photo { display: block; }
.popup.has-photo .popup-photo-fallback { display: none; }
.popup-body { padding: 14px 16px 16px; }
.popup-tag {
  display: inline-block;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  background: var(--surface2);
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.popup-name {
  font-size: 17px;
  margin: 0 0 2px;
  font-weight: 700;
}
.popup-loc {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
}
.popup-model {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.popup-comment {
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  color: var(--text);
}

/* ---------- Modal / Form ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(26, 26, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}
.modal-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: 30px;
  letter-spacing: 1px;
  margin: 0 0 6px;
}
.modal-sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 22px;
}
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field label {
  display: block;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field .muted { text-transform: none; letter-spacing: 0; }
.counter { float: right; color: var(--muted); }
.field input[type="text"],
.field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  font-family: "DM Sans", sans-serif;
  font-size: 15px;
  color: var(--text);
  resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224, 106, 26, 0.15);
}
.field input[type="file"] { font-size: 13px; color: var(--muted); }
.form-error {
  background: rgba(178, 59, 59, 0.1);
  color: #b23b3b;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}
.submit-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  font-size: 15px;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.12s ease;
}
.submit-btn:hover { opacity: 0.92; }
.submit-btn:disabled { opacity: 0.55; cursor: default; }

.thanks { text-align: center; padding: 10px 0; }
.thanks-dot {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #1a7f4b;
  color: #fff;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.thanks h3 { font-size: 22px; margin: 0 0 8px; }
.thanks p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 20px; }

[hidden] { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 38vh;
  }
  .builds { display: flex; flex-direction: column; }

  .brand { top: 14px; left: 14px; gap: 8px; }
  .brand-mark { font-size: 17px; padding: 4px 7px; }
  .brand-text h1 { font-size: 17px; letter-spacing: 1px; }
  .brand-text p { font-size: 9px; }

  /* Compact circular FAB on mobile to avoid crowding the brand. */
  .add-btn {
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    font-size: 0;
  }
  .add-btn .plus { font-size: 24px; margin: 0; }

  .hint {
    bottom: 10px;
    font-size: 10px;
    white-space: nowrap;
    padding: 5px 10px;
  }
}

@media (max-width: 380px) {
  .brand-text p { display: none; }
}
