:root {
  --text: #e8edff;
  --muted: #95a5c8;
  --line: #2b3c5e;
  --surface: #131d31;
  --surface-soft: #17233a;
  --primary: #0a5bff;
  --shadow: 0 20px 44px rgba(1, 7, 18, 0.45);
}

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

body {
  font-family: "Outfit", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background: linear-gradient(160deg, #0c1322 0, #111c31 48%, #0f182b 100%);
  transition: background 0.25s ease, color 0.25s ease;
}

body.theme-fade { animation: theme-fade 0.45s ease; }
@keyframes theme-fade { 0% { opacity: 1; } 45% { opacity: 0.72; } 100% { opacity: 1; } }

.page { width: min(1320px, 94vw); margin: 0 auto; padding: 26px 0 40px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { text-decoration: none; color: inherit; font-family: "Sora", sans-serif; font-size: 1.9rem; font-weight: 800; display: inline-flex; align-items: center; gap: 10px; }
.brand-bubble { width: 34px; height: 34px; border-radius: 8px; background: url("../assets/flatbuddy-logo.png") center/cover no-repeat; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.back-btn { text-decoration: none; color: #d6e3ff; border: 1px solid rgba(127, 162, 232, 0.35); background: rgba(20, 34, 60, 0.9); border-radius: 999px; padding: 10px 16px; font-weight: 700; }

.theme-toggle { width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(127, 162, 232, 0.35); background: rgba(20, 34, 60, 0.9); display: grid; place-items: center; position: relative; cursor: pointer; }
.theme-icon { position: absolute; font-size: 1.2rem; transition: transform 0.35s ease, opacity 0.35s ease; }
.theme-sun { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.theme-moon { opacity: 1; transform: rotate(0deg) scale(1); }
body[data-theme="light"] .theme-sun { opacity: 1; transform: rotate(0deg) scale(1); }
body[data-theme="light"] .theme-moon { opacity: 0; transform: rotate(90deg) scale(0.6); }
.theme-toggle.is-rotating { animation: spin 0.45s ease; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(180deg); } }

.layout {
  margin-top: 20px;
  display: grid;
  grid-template-columns: minmax(380px, 460px) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.lottie-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  position: relative;
  align-self: stretch;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lottie-panel h3 {
  display: none;
}

.lottie-panel p {
  display: none;
}

.lottie-panel lottie-player {
  width: min(100%, 620px);
  height: 620px;
  margin: 0 auto;
  transform: scale(1.18);
  transform-origin: center;
}

.shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 24px;
  justify-self: stretch;
  width: 100%;
}
.intro p { margin-top: 6px; color: var(--muted); }

.stepper {
  margin-top: 18px;
  list-style: none;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0;
  gap: 8px;
}

.step {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.step p {
  font-size: 0.8rem;
  color: #acbcdb;
  text-align: center;
  min-height: 32px;
}

.step-indicator {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: default;
}

.step-indicator-inner {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  position: relative;
  background: #222f4a;
  border: 1px solid #2f4063;
  color: #aebcda;
  transition: all 0.3s ease;
}

.step-number,
.step-check,
.active-dot {
  position: absolute;
}

.step-number {
  font-size: 0.84rem;
  font-weight: 700;
  opacity: 1;
}

.active-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #fff;
  opacity: 0;
}

.step-check {
  font-size: 0.88rem;
  font-weight: 800;
  color: #fff;
  opacity: 0;
}

.step.active .step-indicator-inner {
  background: #5227ff;
  border-color: #5227ff;
}

.step.active .step-number {
  opacity: 0;
}

.step.active .active-dot {
  opacity: 1;
}

.step.complete .step-indicator-inner {
  background: #5227ff;
  border-color: #5227ff;
}

.step.complete .step-number {
  opacity: 0;
}

.step.complete .step-check {
  opacity: 1;
}

.step-connector {
  flex: 1 1 auto;
  height: 2px;
  border-radius: 999px;
  background: #384763;
  overflow: hidden;
}

.step-connector-inner {
  display: block;
  height: 100%;
  width: 0;
  background: #5227ff;
  transition: width 0.35s ease;
}

.step-connector.complete .step-connector-inner {
  width: 100%;
}

.step-panel { margin-top: 18px; }
.hidden { display: none; }

.form h2 { font-family: "Sora", sans-serif; font-size: 1.55rem; }
.section-sub { margin-top: 6px; color: var(--muted); margin-bottom: 14px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid.mini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; border: 1px solid #2d4065; background: var(--surface-soft); border-radius: 12px; padding: 10px; }
.field span,
.field legend { color: #afbfdf; font-size: 0.84rem; }

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #30466f;
  background: #1a2742;
  color: var(--text);
  border-radius: 10px;
  font: inherit;
  padding: 10px 12px;
  outline: none;
}

.field textarea { min-height: 96px; resize: vertical; }
.field.full { grid-column: 1 / -1; }

.radio-group { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.radio-option { position: relative; }
.radio-option input { position: absolute; opacity: 0; pointer-events: none; }
.radio-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid #3a517c;
  background: #1b2a46;
  color: #c9d8f5;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.radio-option input:checked + span {
  border-color: rgba(10, 91, 255, 0.58);
  background: linear-gradient(135deg, #0a5bff, #0f74ff);
  color: #fff;
  box-shadow: 0 8px 18px rgba(10, 91, 255, 0.25);
}

.map-box {
  border: 1px solid #2d4065;
  background: #15213a;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

.minor-btn,
.minor-link {
  border: 1px solid #385487;
  background: #1c2e50;
  color: #d3e2ff;
  border-radius: 10px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
}

.map-preview {
  width: 100%;
  height: 250px;
  border: 1px solid #31476f;
  border-radius: 12px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.tag-option {
  position: relative;
}

.tag-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tag-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #3b517b;
  background: #1b2a46;
  color: #c7d8f5;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.tag-option input:checked + span {
  border-color: rgba(10, 91, 255, 0.58);
  background: linear-gradient(135deg, #0a5bff, #0f74ff);
  color: #fff;
}

.actions { margin-top: 14px; }
.actions.dual { display: flex; justify-content: space-between; gap: 10px; }
.next-btn,
.back-btn-secondary { border: none; border-radius: 10px; padding: 11px 14px; font: inherit; font-weight: 700; cursor: pointer; }
.next-btn { color: #fff; background: linear-gradient(135deg, #0a5bff, #0f74ff); }
.next-btn:disabled { opacity: 0.7; cursor: not-allowed; filter: grayscale(0.08); }
.back-btn-secondary { color: #d4e1ff; background: #253a5f; }
.success { margin-top: 10px; color: #34d399; font-weight: 600; }
.error { margin-top: 8px; color: #fda4af; font-weight: 600; }

.upload-wrap {
  border: 1px solid #2d4065;
  background: #15213a;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
}

.upload-wrap input[type="file"] {
  width: 100%;
  font: inherit;
  color: var(--muted);
  background: #1a2a48;
  border: 1px solid #355180;
  border-radius: 10px;
  padding: 8px;
}

.upload-wrap input[type="file"]::file-selector-button {
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #0a5bff, #0f74ff);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 8px 12px;
  margin-right: 10px;
  cursor: pointer;
}

.upload-wrap input[type="file"]::file-selector-button:hover {
  filter: brightness(1.06);
}

.dropzone {
  border: 1px dashed #4468a8;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  background: #182947;
}

.dropzone p {
  margin-top: 6px;
  color: var(--muted);
}

.dropzone.dragover {
  border-color: #4d89ff;
  background: #1a3157;
}

.preview-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.img-card {
  border: 1px solid #355180;
  background: #1a2a48;
  border-radius: 12px;
  overflow: hidden;
}

.img-card img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
}

.img-actions {
  display: flex;
  gap: 6px;
  padding: 8px;
}

.img-actions button {
  border: 1px solid #43679f;
  background: #213963;
  color: #d7e5ff;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
}

.video-preview {
  width: 100%;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid #355180;
  max-height: 300px;
}

body[data-theme="light"] {
  --text: #1b2742;
  --muted: #5f7395;
  --line: #d4e1f6;
  --surface: #ffffff;
  --surface-soft: #f7faff;
  --shadow: 0 20px 44px rgba(8, 34, 74, 0.12);
  background: radial-gradient(circle at 10% 12%, #ffffff 0, #eff4ff 42%), linear-gradient(160deg, #eff4ff 0, #e8f0ff 100%);
}

body[data-theme="light"] .theme-toggle,
body[data-theme="light"] .back-btn { background: rgba(255, 255, 255, 0.9); color: #153466; border-color: rgba(10, 91, 255, 0.25); }
body[data-theme="light"] .step p { color: #5f7395; }
body[data-theme="light"] .step-indicator-inner { background: #eef4ff; border-color: #cadbf4; color: #1f4d94; }
body[data-theme="light"] .step-connector { background: #d4e1f6; }

body[data-theme="light"] .field,
body[data-theme="light"] .map-box { border-color: #d4e1f6; background: #f7faff; }
body[data-theme="light"] .field span,
body[data-theme="light"] .field legend { color: #60759a; }
body[data-theme="light"] .field input,
body[data-theme="light"] .field select,
body[data-theme="light"] .field textarea { border-color: #d2dff3; background: #fbfdff; }
body[data-theme="light"] .radio-option span,
body[data-theme="light"] .tag-option span { border-color: #ccd9ef; background: #f5f9ff; color: #446089; }
body[data-theme="light"] .radio-option input:checked + span,
body[data-theme="light"] .tag-option input:checked + span {
  border-color: rgba(10, 91, 255, 0.55);
  background: linear-gradient(135deg, #0a5bff, #0f74ff);
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(10, 91, 255, 0.2);
}
body[data-theme="light"] .minor-btn,
body[data-theme="light"] .minor-link { border-color: #c8d9f3; background: #f3f8ff; color: #1b417e; }
body[data-theme="light"] .map-preview { border-color: #d2dff3; }
body[data-theme="light"] .upload-wrap { border-color: #d4e1f6; background: #f7faff; }
body[data-theme="light"] .dropzone { border-color: #c8d9f3; background: #f1f7ff; }
body[data-theme="light"] .img-card { border-color: #c8d9f3; background: #f2f8ff; }
body[data-theme="light"] .img-actions button { border-color: #c8d9f3; background: #e9f3ff; color: #1b417e; }
body[data-theme="light"] .video-preview { border-color: #c8d9f3; }
body[data-theme="light"] .upload-wrap input[type="file"] { border-color: #c8d9f3; background: #fbfdff; color: #60759a; }

@media (max-width: 900px) {
  .stepper { flex-wrap: wrap; justify-content: center; }
  .step-connector { display: none; }
  .layout { grid-template-columns: 1fr; }
  .lottie-panel { position: static; min-height: 0; }
  .lottie-panel lottie-player { width: min(100%, 420px); height: 420px; transform: none; }
  .shell { width: 100%; justify-self: stretch; }
}

@media (max-width: 700px) {
  .grid,
  .grid.mini { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .actions.dual { flex-direction: column; }
  .preview-grid { grid-template-columns: 1fr; }
}
