:root {
  --bg: #f7f8fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e6eaf2;
  --soft: #f2f5fb;
  --accent: #1e293b;
  --shadow: 0 0.625rem 1.5625rem rgba(15, 23, 42, 0.06);
  --radius: 1rem;
  --focus: 0 0 0 0.25rem rgba(37, 99, 235, 0.15);
}

/* --- CORE RESET --- */
* {
  box-sizing: border-box;
}

body {
  background-color: #0f172a;
  background-image:
    radial-gradient(at 0% 0%, hsla(263, 45%, 25%, 0.4) 0px, transparent 70%), radial-gradient(at 100% 100%, hsla(180, 50%, 20%, 0.25) 0px, transparent 70%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.25' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
  background-blend-mode: normal, normal, overlay;
  background-attachment: fixed;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, sans-serif;

  /* LOCK VIEWPORT: Prevents the whole page from scrolling */
  margin: 0;
  padding: 0;
  height: 100dvh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  height: 100%;
  max-height: 1440px;
  padding: 1.5rem;
}

/* --- THE CARD --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%; /* Card fills the app container */
  overflow: hidden; /* Contains the scroll within .content */
  position: relative;
}

/* --- HEADER (Fixed) --- */
.master-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  text-align: center;
  z-index: 30;
}

.master-header h2 {
  color: #2d3748;
  font-size: 1.1rem;
  margin: 0;
}

/* --- CONTENT (Scrollable) --- */
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1; /* Takes all available space between header and footer */
  padding: 1.5rem;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- BOTTOM CONTAINER (Fixed) --- */
#wizard-container-bottom {
  flex-shrink: 0; /* Prevents footer from squishing */
  border-top: 1px solid var(--line);
  z-index: 40;
}

.actions {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  background: #fff;
}

#integrated-footer {
  background: #1e293b;
  color: #97a5ba;
  padding: 0.75rem 1rem;
  font-size: 0.6rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  /* Respect iPhone home bar */
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
}

/* --- MOBILE OVERRIDES --- */
@media (max-width: 480px) {
  .app {
    padding: 0;
  }
  .card {
    border-radius: 0;
    border: none;
  }
  .content {
    padding: 1rem;
  }
}

/* --- FORMS & WIZARD PAGES --- */
.page {
  animation: fadeUp 0.2s ease both;
  display: none;
  max-width: 32.5rem;
  width: 100%;
}
.page.active {
  display: flex;
  flex-direction: column;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.grid {
  display: grid;
  gap: 1rem;
  width: 100%;
}
label {
  color: var(--muted);
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}
.field {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  display: flex;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
}
.field:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus);
}
input,
select {
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 0.875rem;
  outline: 0;
  width: 100%;
}

/* --- BUTTONS --- */
.btn {
  border-radius: 0.75rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  transition: all 0.2s;
  border: none;
  white-space: normal; /* Allows text to wrap */
  line-height: 1.2; /* Prevents lines from being too far apart */
  text-align: center;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  max-width: 264px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn.primary:hover {
  background: #0f172a; /* Slightly darker on hover */
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}
.btn.premium {
  background-color: #0f172a;
  background-image: radial-gradient(at 0% 0%, hsla(263, 85%, 60%, 0.4) 0px, transparent 85%), radial-gradient(at 100% 100%, hsla(180, 85%, 50%, 0.25) 0px, transparent 85%);
  color: #fff;
  width: 100%;
  max-width: 264px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.btn.premium:hover {
  transform: scale(1.02);
  filter: brightness(1.1);
}

/* Remove spin buttons */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
