:root {
  --bg: linear-gradient(135deg, #ffe9f0 0%, #fff7d6 50%, #d6f0ff 100%);
  --text: #2a2333;
  --muted: #6b6378;
  --accent: #ff5a8a;
  --accent-soft: rgba(255, 90, 138, 0.12);
  --accent-no: #b8a8c9;
  --going: #f0a85f;
  --labor: #d854a3;
  --card: rgba(255, 255, 255, 0.72);
  --shadow: 0 10px 40px rgba(60, 30, 80, 0.08);
  --radius: 1.25rem;
  --line-pending: #e3dbeb;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 2rem 1rem;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.75rem;
}

h1 {
  font-size: clamp(1.5rem, 4vw + 1rem, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.status {
  font-size: clamp(4.5rem, 16vw, 9rem);
  font-weight: 900;
  line-height: 1;
  padding: 1.25rem 2rem;
  border-radius: 2rem;
  background: var(--card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  transition: color 0.3s ease, transform 0.3s ease;
  min-width: 60vw;
  letter-spacing: -0.04em;
}

.status--waiting { color: var(--accent-no); }
.status--going   { color: var(--going); }
.status--labor   { color: var(--labor); }
.status--born    { color: var(--accent); transform: scale(1.04); }

.status--loading {
  color: var(--muted);
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  font-weight: 600;
}

.note {
  color: var(--text);
  font-size: 1.1rem;
  font-style: italic;
  margin-top: -0.75rem;
  background: var(--card);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  max-width: 90%;
}

.born-at {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: -0.75rem;
}

/* ─── Domino's-style stage tracker ─────────────────────── */
.tracker {
  width: 100%;
  max-width: 540px;
  padding: 1.25rem 1rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.tracker__list {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.25rem;
  position: relative;
}

.tracker__step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.tracker__step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 1.4rem;
  left: 60%;
  width: 80%;
  height: 3px;
  background: var(--line-pending);
  border-radius: 2px;
  z-index: -1;
  transition: background 0.5s ease;
}

.tracker__step.is-completed::after,
.tracker__step.is-active::after {
  background: var(--accent);
}

.tracker__node {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  background: #f3eef7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: transform 0.35s ease, background 0.35s ease,
    box-shadow 0.35s ease;
}

.tracker__step.is-completed .tracker__node {
  background: white;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.tracker__step.is-active .tracker__node {
  background: var(--accent);
  transform: scale(1.18);
  box-shadow: 0 6px 16px rgba(255, 90, 138, 0.35);
}

.tracker__step.is-active .tracker__label {
  color: var(--text);
  font-weight: 700;
}

.tracker__label {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  font-weight: 500;
  line-height: 1.2;
  padding: 0 0.1rem;
}

@media (max-width: 480px) {
  .tracker__label { font-size: 0.7rem; }
  .tracker__node { width: 2.4rem; height: 2.4rem; font-size: 1.2rem; }
  .tracker__step:not(:last-child)::after {
    top: 1.2rem;
    left: 65%;
    width: 70%;
  }
}

/* ─── Baby preview card ────────────────────────────────── */
.preview {
  background: var(--card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.25rem;
  box-shadow: var(--shadow);
  max-width: 320px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.preview h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}

.preview__frame {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 1rem;
  overflow: hidden;
  background: #f3eef7;
  position: relative;
}

.preview__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.preview__img.is-loaded {
  opacity: 1;
}

.preview__caption {
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  margin: 0;
}

.reroll {
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.reroll:hover,
.reroll:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.reroll:active {
  transform: translateY(1px);
}

/* ─── Animal fact card ─────────────────────────────────── */
.fact {
  background: var(--card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
  max-width: 540px;
}

.fact h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 0.6rem;
  font-weight: 600;
}

.fact p {
  font-size: 1.1rem;
  line-height: 1.55;
}

footer {
  text-align: center;
  padding-top: 2rem;
}

.admin-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s;
  font-family: inherit;
  padding: 0.5rem 1rem;
}

.admin-link:hover,
.admin-link:focus-visible {
  opacity: 1;
  outline: none;
}

/* ─── Admin dialog ─────────────────────────────────────── */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: 0 20px 60px rgba(40, 20, 60, 0.25);
  max-width: 380px;
  width: 92%;
  color: var(--text);
}

dialog::backdrop {
  background: rgba(20, 10, 30, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

dialog h2 {
  margin-bottom: 1.25rem;
  font-size: 1.25rem;
}

dialog form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field__label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

dialog input[type="password"],
dialog input[type="text"] {
  padding: 0.65rem 0.85rem;
  border: 1px solid #e2dae9;
  border-radius: 0.6rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: white;
}

dialog input[type="password"]:focus,
dialog input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.stage-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  border: none;
  padding: 0;
}

.stage-picker legend {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.stage-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.8rem;
  border: 1.5px solid #e2dae9;
  border-radius: 0.7rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, font-weight 0.05s;
  user-select: none;
}

.stage-option:hover {
  border-color: #c8b8d8;
}

.stage-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.stage-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.stage-option__icon {
  font-size: 1.15rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.actions button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 0.6rem;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.1s, opacity 0.2s;
}

.actions button:active {
  transform: translateY(1px);
}

#cancel {
  background: #f0ebf5;
  color: var(--text);
}

#save {
  background: var(--accent);
  color: white;
}

#save:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.error {
  color: #d83a5a;
  font-size: 0.85rem;
  margin: -0.25rem 0;
}

@keyframes pop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  60% {
    transform: scale(1.12);
    opacity: 1;
  }
  100% {
    transform: scale(1.04);
    opacity: 1;
  }
}

.status--just-flipped {
  animation: pop 0.55s ease;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
